-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c103444
commit ccb1a74
Showing
1 changed file
with
113 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a single version of Python | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||
|
||
name: Python CI | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
branches: ["main"] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
linting: | ||
runs-on: ubuntu-latest | ||
steps: | ||
#---------------------------------------------- | ||
# check-out repo and set-up python | ||
#---------------------------------------------- | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
#---------------------------------------------- | ||
# load pip cache if cache exists | ||
#---------------------------------------------- | ||
- uses: actions/cache@v4 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip | ||
restore-keys: ${{ runner.os }}-pip | ||
#---------------------------------------------- | ||
# install and run linters | ||
#---------------------------------------------- | ||
- run: python -m pip install black flake8 isort | ||
- run: | | ||
flake8 . | ||
black . --check | ||
isort . | ||
test: | ||
needs: linting | ||
|
||
strategy: | ||
fail-fast: true | ||
matrix: | ||
os: [ubuntu-latest, macos-latest] | ||
python-version: ['3.13'] | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
#---------------------------------------------- | ||
# check-out repo and set-up python | ||
#---------------------------------------------- | ||
- name: "[Python] checkout repository" | ||
uses: actions/checkout@v4 | ||
- name: "[Python] Setup python ${{ matrix.python-version }}" | ||
id: setup-python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
#---------------------------------------------- | ||
# ----- install & configure poetry ----- | ||
#---------------------------------------------- | ||
- name: "[Python] Install Poetry" | ||
uses: snok/install-poetry@v1 | ||
with: | ||
virtualenvs-create: true | ||
virtualenvs-in-project: true | ||
virtualenvs-path: .venv | ||
installer-parallel: true | ||
|
||
#---------------------------------------------- | ||
# load cached venv if cache exists | ||
#---------------------------------------------- | ||
- name: "[Python] Load cached venv" | ||
id: cached-poetry-dependencies | ||
uses: actions/cache@v4 | ||
with: | ||
path: .venv | ||
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} | ||
|
||
#---------------------------------------------- | ||
# install dependencies if cache does not exist | ||
#---------------------------------------------- | ||
- name "[Python] Install dependencies" | ||
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | ||
run: poetry install --no-interaction --no-root | ||
|
||
#---------------------------------------------- | ||
# install your root project, if required | ||
#---------------------------------------------- | ||
- name: Install project | ||
run: poetry install --no-interaction | ||
|
||
#---------------------------------------------- | ||
# run test suite | ||
#---------------------------------------------- | ||
- name "[Python] Run tests" | ||
run: poetry run pytest --alluredir=build/allure-results --color no | ||
|
||
- name "[Python] Create coverage report" | ||
run: poetry run coverage report | ||
|
||
- name: "[Python] Store allure test results" | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: allure-results | ||
path: | ||
allure-results | ||
retention-days: 1 |