Is there a way in Python to find the results of a Github CI? - pygithub

I am using PyGithub to run tests on every pull request in a repository.
I'd like to only run tests on pull requests that have passed my CI.
Is there a way to query the results of the CI in Python?
For example something like:
for pull in repository.get_pulls():
if pull.get_check().status == True:
#run test on pull
(something like get_check() is what I'm looking for)
Thanks so much!

This is it: https://pygithub.readthedocs.io/en/latest/github_objects/Commit.html#github.Commit.Commit.get_statuses
Which returns a: https://pygithub.readthedocs.io/en/latest/github_objects/CommitStatus.html#github.CommitStatus.CommitStatus
Which is a form of: https://docs.github.com/en/rest/commits/statuses

Related

How to use newman command to run 1 postman collection with different folder?

Postman collection and it's folder arrangement
I want to run this ITEM-API postman collection in jenkins. I have exported it with github repo. I have also done configuration. But here when will I run test, it will give result for all ITEM-API collection. But inside ITEM-API collection, there are different folders of API, for eg. CHARTS, IAMGES, SYNDICATION, INTEREST, etc. SO how can use newman command to run test for particular api. Let's say, I want to run test for CHARTS api, then how can I use newman command for that in jenkins or groovy file in github repo.
please please help.

Apollo on android: can't download schema or generate classes

I'm trying Apollo and graphql for the first time and I want to use this api and I'm following the official example here. However
running the schema download task
gradlew :app:downloadApolloSchema --endpoint='https://countries.trevorblades.com/' --schema='app/src/main/graphql/com/trevorblades/countries/schema.json'
results in
Execution failed for task ':app:downloadApolloSchema'.
> Expected URL scheme 'http' or 'https' but no colon was found
with both the repo I want to use and the example's.
If I try to manually download the schema using the button on the repo's page, place it in the correct directory and run
gradlew generateApolloSources
it results in
Failed to parse GraphQL schema introspection query from `[...]app\src\main\graphql\com\trevorblades\countries\schema.json`
again with both my repo and the one from the example.
I've the feeling that I'm missing something really trivial here, but I really can't figure it out.
any help will be appreciated.
Try the JS GraphQL IDEA plugin, which might make life a tad easier. And as it suggested here ...you might not pass a valid endpoint at all. Try --endpoint=https://countries.trevorblades.com/ or in " double-quotes . The error message is definitely concerning the --endpoint and not concerning the --schema. I have the suspicion that Windows might not like these ' single quotes
(obviously the same would also apply to --schema).
gradlew.bat :app:downloadApolloSchema --endpoint=https://countries.trevorblades.com/ --schema=app/src/main/graphql/com/trevorblades/countries/schema.json
or:
gradlew.bat :app:downloadApolloSchema --endpoint="https://countries.trevorblades.com/" --schema="app/src/main/graphql/com/trevorblades/countries/schema.json"

How to get cypress run result for each test?

I want to integrate cypress report with an internal tool and I was able to achieve by using after:run, which posts data by iterating over result Json, but I'm looking for something which will allow me to capture the execution result after each test case has ran and push it to internal tool. Similar to after each hook.
Is there any way I can achieve this?
------Update--------
Was able to achieve it by using mocha custom reports
Here is the solution I was looking
https://mochajs.org/api/tutorial-custom-reporter.html
I used mocha listeners to trigger an API call to post data.

Automatically committing Scrapy-scraped data to Github?

I have a Python Scrapy spider that I want to run at regular intervals on Heroku or similar.
It produces a JSON file that I would like to commit to a Github repo.
Given Heroku or other similar platform, how can I set it up to automatically commit, post-run?
You could write an item pipeline that keeps a static list of items.
Give this pipeline a function called spider_closed and use the dispatcher to attach that function as a signal handler for spider_closed signal.
In spider_closed use json.loads to serialize your data. Save it to a file. And commit it to github.
This repo has good code examples:
https://github.com/dm03514/CraigslistGigs/blob/master/craigslist_gigs/pipelines.py
This seems to be a good library to use for the git part:
https://pypi.python.org/pypi/GitPython/
HTH - if you need anymore help I'd be happy to update this response.

Using TeamCity build number in Buildmaster

Is it possible to grab the build number from TeamCity and use that as a build number in BuildMaster?
This could be done by triggering the BuildMaster API's Builds_CreateBuild method from TeamCity which accepts a numeric build number. It should be fairly straightforward to make a GET request to the BuildMaster JSON API from TeamCity, see this question for a simple way to do so: TeamCity Call Url Build Step
In order to create a new build including the build number you need to firstly enable the api under settings. There is no 'enable' button as such, you just need to provide an arbitrary key for the api authentication (any literal will do, but presumably make it complex for best security!).
The JSON syntax for the creating a build is as follows:
http://buildmaster-server/api/json/Builds_CreateBuild?API_Key=abcde12345&Build_Number=123&Release_Number=0.0
This will actually create a new build on your build master server. This can then be triggered via Team City using Powershell with the powershell script inline such as:
Invoke-WebRequest "http://buildmaster-server/api/json/Builds_CreateBuild?API_Key=abcde12345&Build_Number=%build.number%&Release_Number=0.0&Application_Id=2" -UseBasicParsing
You can add further variables and call hundreds of BuildMaster API's using the above method. Full API documentation can be found here: http://inedo.com/support/documentation/buildmaster/reference/api-methods

Resources