GitHub Checks allows you to quickly see the results of your CI tests from GitHub.
This is a simple, light-weight python implementation of the GitHub Checks API.
Examples
Once you have completed all the installation steps, here are a few examples of what your Checks implementation could look like:
Automatically run Checks for new commits:
Annotate files with messages explaining why they failed tests:
Installation
Note that you need a self-hosted server that will run your CI logic.
1: Creating a new GitHub app
In GitHub, do the following:
Click your profile in the right top corner, click Settings, click Developers Settings, click GitHub Apps and click New GitHub App.
Add a name and homepage URL (any URL will do). For User authorization callback URL and Webhook URL, use the server address you'll be using, with /hook at the end of the address.
Generate a strong, random secret and set it as Webhook secret (optional). While optional in GitHub, this project won't work without one.
Under Permissions, set the following:
Name
Permission
Checks
Read & write
Repository contents
Read
Repository metadata
Read
Under Subscribe to events, tick Check runs.
Click Create GitHub App.
If the creation was successful, you'll see an overview of your app. Copy the App ID as you'll need it for setting up the script.
Scroll to the bottom of the page to generate a private key. Save the file as pk.pem, as you'll need it for setting up the script.
2: Setting up the server
The server will run on port 443, using a simple Python 3 Flask server.
Install all dependencies by running the following command:
pip install -r requirements.txt
To create a locally signed SSL certificate, run the followingin the same folder as server.py:
Make sure you replace {{your_secret_here}} with your webhook secret set in GitHub (see 'Creating a GitHub app' section). You might want to consider changing port 443 to something else so that server.py doesn't have to run using sudo.
请发表评论