At this point, please make your own fork of the repository so you can follow along with the hands-on portion of the demo. You only need to copy the main branch (see figure below):
Github Actions are workflows that can be automatically triggered. Examples include:
Checking code quality.
Running automated tests.
Building documentation/other websites.
Building code artifacts/docker images.
Code Quality Check with Github Actions
We can use an existing job flake8-lint to run a simple Github Action that will automatically check the code quality of our work going forward!
We will be using the simple action below. You can name an action whatever you want and we can specify which actions we would like to trigger our job. In our case, all pushes and pull requests will trigger the job which is convenient to ensure that new submissions maintain our code quality.
Then, we specify the jobs to run. Our only job here is named flake8-lint. This job runs on an ubuntu-latest “runner” (a virtual machine specified by Github) and we can provide the job with a name/label as well. Then, we specify the step in our job:
name:Python Code Qualityon:[push,pull_request]jobs:flake8-lint:runs-on:ubuntu-latestname:Python Code Qualitysteps:-name:Check out source repositoryuses:actions/checkout@v2-name:Set up Python environmentuses:actions/setup-python@v2with:python-version:"3.x"-name:flake8 Lint Checkuses:py-actions/flake8@v1with:path:"mycybergis"args:"--ignore=E501,E722,F403,F405"
Running Our Action
Copy and paste the action from the yaml code block above. On the Github webpage for your fork, click “Add file” in the top-right, then select “Create new file” (you can also add this other ways).
Paste the yaml code block into the editor and name your file .github/workflows/CodeQuality.yaml. By placing this yaml file in .github/workflows, Github will recognize the file as an Action.
Commit your changes and go to the Actions tab on your repo to see the action being run!
Checking On Your Action
On the Actions tab you should be able to see the results of your Action’s run.