Bilal Ahmad

~Engineers solve problems, I solve engineer's problems 🤘

Adding CI workflow using Github Actions

Github Actions is one of the best things to come out of Github. If you dont know about it you can read here. Basically it makes your CI/CD extremeely easy to configure and manage. You can set up workflows to tell the github to build, test, package, release or deploy code in any repository in your preferred order. And you can have multiple workflows for a single repository also.

Here is an example how to set it up:

Create workflow directory:

Create .github/workflows directory in the root of your repository.

Make the yaml file that will include the steps:

Create a yaml file inside the above folder that will define steps you want to run along with thier order and configuration. You can read the docs of what can be included here.

As an example here, I am making the workflow to package and run unit test cases in the yaml.

name: Run unit test cases
on: [push, pull_request]
jobs:
build:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
    - uses: actions/checkout@v2
    - name: set up python
    - uses: actions/setup-python@v1
    - name: install requirements
    run: |
        python -m pip install --upgrade pip
        pip install -r requirements.txt
    - name: run tests
    run: |
        pytest

Commit and check your repo on github output of running tests (or your workflow)

automated-workflow

Other fancy things 😎

back