Lesson 04 GitHub Actions Pipeline
Theme:

Homework — GitHub Actions Pipeline

Lesson 04 · Cloud Infrastructure & DevOps · 3 tasks

Task 1 — Add a code-coverage gate

Extend the test job to produce a combined coverage report and fail if coverage drops below 80%. The pipeline should not pass if any commit reduces test coverage below that threshold.

Modify the test steps to run pytest with pytest-cov:

pytest --cov=cloud-devops/sample-app/api \
       --cov=cloud-devops/sample-app/worker \
       --cov-report=term-missing \
       --cov-fail-under=80

The --cov-fail-under=80 flag causes pytest to exit with a non-zero code if the combined coverage is below 80%, which makes the CI job fail.

Self-check:

Task 2 — Add a path-filter so doc-only edits skip CI

Add paths-ignore to both the push and pull_request triggers so that commits containing only Markdown files or documentation do not fire the pipeline.

on:
  push:
    branches: [main]
    paths-ignore:
      - '**.md'
      - 'docs/**'
  pull_request:
    branches: [main]
    paths-ignore:
      - '**.md'
      - 'docs/**'

Self-check:

Task 3 — Add a “Summary” step to the build job

Use the $GITHUB_STEP_SUMMARY environment variable to append a brief Markdown block at the end of each build matrix job. The summary should list the image tag that was built.

Add a final step to the build job:

- name: Write build summary
  run: |
    echo "### Built images" >> $GITHUB_STEP_SUMMARY
    echo "" >> $GITHUB_STEP_SUMMARY
    echo "- \`${{ matrix.service }}:ci-${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY

Self-check:

View solutions →