Set up test configuration (#792) #1334
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: pytest | |
on: | |
pull_request_target: | |
branches: | |
- "**" | |
push: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Create dirs and files | |
run: | | |
mkdir -p ../{alts,albs-frontend,albs-node,albs-sign-file,albs-sign-node,alma-tests-cacher} | |
touch ../albs-sign-file/.env | |
ln -sf tests/test-vars.env vars.env | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
target: web-server-tests | |
load: true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Start services | |
run: docker compose up -d test_db | |
- name: Run unit tests (pytest) | |
run: docker compose run --rm -v /tmp:/tmp web_server_tests bash -c " | |
pytest -v --cov | |
--cov-report xml:/tmp/coverage.xml --junitxml=/tmp/pytest.xml | |
--cov-report term-missing:skip-covered | tee /tmp/pytest-coverage.txt" | |
- name: Stop services | |
run: docker compose down --volumes | |
- name: Pytest coverage comment | |
uses: MishaKav/pytest-coverage-comment@main | |
id: coverageComment | |
with: | |
pytest-coverage-path: /tmp/pytest-coverage.txt | |
pytest-xml-coverage-path: /tmp/coverage.xml | |
title: Coverage report for changed files | |
badge-title: Total coverage | |
hide-badge: false | |
hide-report: false | |
report-only-changed-files: true | |
hide-comment: false | |
remove-link-from-badge: false | |
junitxml-path: /tmp/pytest.xml | |
- name: Create the Badge | |
if: ${{ github.ref == 'refs/heads/master' && steps.coverageComment.outputs.coverage }} | |
uses: schneegans/dynamic-badges-action@v1.7.0 | |
with: | |
auth: ${{ secrets.GIST_SECRET }} | |
gistID: 7894f3c3bd830eb5456d45c9dacc0f93 | |
filename: pytest-coverage-comment__web-server__main.json | |
label: Test Coverage | |
message: ${{ steps.coverageComment.outputs.coverage }} | |
color: ${{ steps.coverageComment.outputs.color }} | |
namedLogo: pytest |