Adding per-commit CI test runs #2
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: CI | ||
on: | ||
push: | ||
branches: | ||
- dev | ||
- main | ||
pull_request: | ||
commit: | ||
concurrency: | ||
# Concurrency group that uses the workflow name and PR number if available | ||
# or commit SHA as a fallback. If a new build is triggered under that | ||
# concurrency group while a previous build is running it will be canceled. | ||
# Repeated pushes to a PR will cancel all previous builds, while multiple | ||
# merges to main will not cancel. | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} | ||
cancel-in-progress: true | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
# 3.10: currently used by Seedsigner | ||
# 3.12: latest stable Python as upper test bound | ||
python-version: ["3.10", "3.12"] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
sudo apt-get install libzbar0 | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt -r tests/requirements.txt | ||
pip install . | ||
- name: Test with pytest | ||
run: | | ||
mkdir artifacts | ||
python -m pytest \ | ||
--color=yes \ | ||
--cov=seedsigner \ | ||
--cov-append \ | ||
--cov-branch \ | ||
--cov-report term \ | ||
--cov-report html \ | ||
--cov-report html:./artifacts/cov_html \ | ||
--cov-report xml \ | ||
--durations 5 \ | ||
-vv | ||
- name: Generate screenshots | ||
run: | | ||
python -m pytest tests/screenshot_generator/generator.py | ||
cp -r ./seedsigner-screenshots ./artifacts/ | ||
- name: Archive CI Artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ci-artifacts | ||
path: artifacts/** | ||
retention-days: 10 | ||
# Upload also when tests fail. The workflow result (red/green) will | ||
# be not effected by this. | ||
if: always() |