Skip to content

ok3mad/github-cicd-course

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub CI/CD practice

Sources for practice lecture about containers used in NSWI026 MFF UK and SEPA4M33SEP, FEL CVUT. This should be a simple example for CI/CD, it's not recommended for a production usage.

Tasks

  1. Take a look on basic usage of GitHub workflows.

  2. Take a look on script in task_a. Try it locally:

    • (Optional) Prepare an env python3 -m venv venv, activate it source venv/bin/activate and install dependencies pip3 install -r requirements.txt.
    • (Optional) Try to execute tests pytest task_a.py.

On push events

  1. Make one test failing and fill a GitHub workflow to execute tests.
    • Change .github/workflows/task-a-cd.yml and push it to your GitHub.
  2. Try to speed up testing using cache on one of following methods.
  3. Generate an html report for PyTest with --html=report.html and upload it to GitHub using actions/upload-artifact
  4. Run tests on multiple operating systems and Python versions using matrix option.
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        python-version: ["3.10", "3.11", "pypy3.10"]
        exclude:
          - os: macos-latest
            python-version: "3.10"
          - os: windows-latest
            python-version: "3.10"
    • Don't forget to use matrix value ${{ matrix.os }} in jobs.test.runs-on and ${{ matrix.python-version }} in jobs.test.steps[2].with.python-version
    • Rename artifact to Report-${{ matrix.os }}-${{ matrix.python-version }} get rid of name conflicts
    • Take a look on reports, check Platform section if everything works as expected

On pull request

  1. Change "task-a-cd.yml" to task-a-ci.yml and change to be executed on a pull-request, take a look on pull_request.
  2. Run this pull request only on changes tu folder task_a, take a look on paths.

On manual event

  1. Try a manual workflow "task-b manual".
  2. Build a docker image, using docker/build-push-action, you could reuse following lines
    • Create an workflow input tag for image tag
    • Tag image like ghcr.io/${{ github.repository }}:${{ inputs.tag }}
  3. Build a dependent job test
    • It should depend on docker job
    • It should run docker container from previous step as service container
    • Call curl 127.0.0.1:8080/index.html to fetch index.html

Build our flight-log

  1. Get own repository for FlightLog

About

Sources for practice lecture about containers used in NSWI026 MFF UK and SEPA4M33SEP, FEL CVUT. This should be a simple example for CI/CD, it's not recommended for a production usage.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 67.6%
  • Dockerfile 19.6%
  • HTML 12.8%