From Code to Performance

Exercise 4: Automating Builds with Github Actions

Objectives:Learn to set up a CI/CD pipeline using Github Actions to automate builds and tests.

Tasks

  1. In any existing repository, create a new file in the `.github/workflows` directory called ci.yml.
  2. Add a ci.yml with:

    name: Python Tests
    on: [push, pull_request]
    jobs:
    test:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout code
    uses: actions/checkout@v2
    - name: Set up Python
    uses: actions/setup-python@v2
    with:
    python-version: '3.8'
    - name: Install dependencies
    run: pip install -r requirements.txt
    - name: Run tests
    run: pytest
  1. After pushing the changes, you should see the workflow running in the Actions tab of your GitHub repository.
  1. Push to Github and verify that a workflow run starts automatically
  1. Break a test intentionally and push again to observe the failed status.