mraba/gh-actions-updates: refresh build test actions versions #421
Workflow file for this run
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: Build and Test | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- v* | |
pull_request: | |
branches: | |
- main | |
- prep-** | |
workflow_dispatch: | |
inputs: | |
logLevel: | |
default: warning | |
description: "Log level" | |
required: true | |
tags: | |
description: "Test scenario tags" | |
jobs: | |
lint: | |
name: Check linting | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.8' | |
- name: Display Python version | |
run: python -c "import sys; import os; print(\"\n\".join(os.environ[\"PATH\"].split(os.pathsep))); print(sys.version); print(sys.executable);" | |
- name: Upgrade setuptools, pip and wheel | |
run: python -m pip install -U setuptools pip wheel | |
- name: Install tox | |
run: python -m pip install tox | |
- name: Set PY | |
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV | |
- uses: actions/cache@v1 | |
with: | |
path: ~/.cache/pre-commit | |
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} | |
- name: Run fix_lint | |
run: python -m tox -e fix_lint | |
test: | |
name: Test ${{ matrix.os.download_name }}-${{ matrix.python-version }}-${{ matrix.cloud-provider }} | |
needs: lint | |
runs-on: ${{ matrix.os.image_name }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- image_name: ubuntu-latest | |
download_name: manylinux_x86_64 | |
- image_name: macos-latest | |
download_name: macosx_x86_64 | |
- image_name: windows-2019 | |
download_name: win_amd64 | |
python-version: ["3.8"] | |
cloud-provider: [aws, azure, gcp] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Display Python version | |
run: python -c "import sys; print(sys.version)" | |
- name: Setup parameters file | |
shell: bash | |
env: | |
PARAMETERS_SECRET: ${{ secrets.PARAMETERS_SECRET }} | |
run: | | |
gpg --quiet --batch --yes --decrypt --passphrase="$PARAMETERS_SECRET" \ | |
.github/workflows/parameters/parameters_${{ matrix.cloud-provider }}.py.gpg > tests/parameters.py | |
- name: Upgrade setuptools, pip and wheel | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install --upgrade setuptools wheel | |
- name: Install tox | |
run: python -m pip install tox tox-gh-actions | |
- name: List installed packages | |
run: python -m pip freeze | |
- name: Run tests | |
run: python -m tox -e "py${PYTHON_VERSION/\./}" --skip-missing-interpreters false | |
env: | |
PYTHON_VERSION: ${{ matrix.python-version }} | |
PYTEST_ADDOPTS: -vvv --color=yes --tb=short | |
TOX_PARALLEL_NO_SPINNER: 1 | |
- name: Combine coverages | |
run: python -m tox -e coverage --skip-missing-interpreters false | |
shell: bash | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: coverage_${{ matrix.os.download_name }}-${{ matrix.python-version }}-${{ matrix.cloud-provider }} | |
path: | | |
.tox/.coverage | |
.tox/coverage.xml | |
combine-coverage: | |
if: ${{ success() || failure() }} | |
name: Combine coverage | |
needs: [test] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v3 | |
with: | |
path: artifacts | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.8' | |
- name: Display Python version | |
run: python -c "import sys; print(sys.version)" | |
- name: Upgrade setuptools and pip | |
run: python -m pip install -U setuptools pip wheel | |
- name: Install tox | |
run: python -m pip install tox | |
- name: Collect all coverages to one dir | |
run: | | |
python -c ' | |
from pathlib import Path | |
import shutil | |
src_dir = Path("artifacts") | |
dst_dir = Path(".") / ".tox" | |
dst_dir.mkdir() | |
for src_file in src_dir.glob("*/.coverage"): | |
dst_file = dst_dir / f".coverage.{src_file.parent.name[9:]}" | |
print(f"{src_file} copy to {dst_file}") | |
shutil.copy(str(src_file), str(dst_file))' | |
- name: Combine coverages | |
run: python -m tox -e coverage | |
- name: Publish html coverage | |
uses: actions/upload-artifact@v3 | |
with: | |
name: overall_cov_html | |
path: .tox/htmlcov | |
- name: Publish xml coverage | |
uses: actions/upload-artifact@v3 | |
with: | |
name: overall_cov_xml | |
path: .tox/coverage.xml | |
- uses: codecov/codecov-action@v4 | |
with: | |
file: .tox/coverage.xml |