Merge pull request #118 from glevv/dependabot/github_actions/github/c… #334
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: | |
- main | |
pull_request: | |
branches: | |
- main | |
env: | |
PYTHONUNBUFFERED: "1" | |
PYTHONHASHSEED: "1" | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: True | |
matrix: | |
python-version: [ "3.9", "3.10", "3.11", "3.12" ] | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1 | |
with: | |
egress-policy: audit | |
- name: Check out repository | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: Set up Python ${{ matrix.python-version }} | |
id: setup-python | |
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install Poetry | |
uses: snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a # v1.4.1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
installer-parallel: true | |
- name: Load cached venv | |
id: cached-poetry-dependencies | |
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
with: | |
path: .venv | |
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/pyproject.toml') }} | |
- name: Install dependencies | |
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
run: poetry install --no-interaction --no-root | |
- name: Activate env | |
run: | | |
source $VENV | |
- name: Run ruff | |
run: | | |
poetry run ruff check --output-format=github . | |
poetry run ruff format . --diff | |
- name: Run mypy | |
run: | | |
poetry run mypy . | |
- name: Run tests | |
run: | | |
poetry run pytest --cov=obscure_stats --cov-report term --cov-report xml:coverage.xml | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0 | |
if: matrix.python-version == '3.11' | |
with: | |
flags: smart-tests | |
verbose: true | |
file: ./coverage.xml | |
fail_ci_if_error: true | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |