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.
-
Take a look on basic usage of GitHub workflows.
-
Take a look on script in
task_a
.- (Optional) Prepare an env
python3 -m venv venv
, activate itsource venv/bin/activate
and install dependenciespip3 install -r requirements.txt
. - (Optional) Try to execute tests
pytest task_a.py
.
- (Optional) Prepare an env
- 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.
- Change
- Try to speed up testing using cache on one of following methods.
- Using
cache: 'pip'
inactions/setup-python
- Using
actions/cache
- Using
- Generate an html report with
--html=report.html
and upload it to GitHub usingactions/upload-artifact
- 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"
- Change "task-a-cd.yml" to
task-a-ci.yml
and change to be executed on a pull-request, take a look onpull_request
. - Run this pull request only on changes tu folder
task_a
, take a look onpaths
.
- Try a manual workflow "task-b manual".
- 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 }}
- 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 fetchindex.html
- Get own repository for FlightLog
- CI - Test application on pull-request
- CD - Build a docker image on push to master / develop