-
Notifications
You must be signed in to change notification settings - Fork 2
80 lines (69 loc) · 3.08 KB
/
test-and-lint.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: Test and Lint
on:
pull_request:
push:
branches:
- main
env:
PROJECT_NAME: rejx
PYTHON_VERSION: 3.10.10
POETRY_VERSION: 1.7.1
jobs:
test_and_lint:
name: Lint and Test
runs-on: ubuntu-latest
outputs:
cache-key: ${{ steps.cache-keys.outputs.cache-key }}
steps:
- uses: actions/checkout@v4
###################################################################
# #
# Setup Project #
# #
###################################################################
- name: Setup Justfile
uses: extractions/setup-just@v1
- name: Check justfile linting
run: 'just --unstable --fmt --check || "justfile is not formatted!\nrun: `just fmt` and commit again"'
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: pip
- name: Setup Poetry for Python
uses: abatilo/actions-poetry@v2
with:
python-version: ${{ env.POETRY_VERSION }}
- name: Setup a local virtual environment (if no poetry.toml file)
run: |
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- uses: actions/cache@v3
name: Define a cache for the virtual environment based on the dependencies lock file
with:
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}
- name: Install the project dependencies
run: just setup
###################################################################
# #
# Linting and Format #
# #
###################################################################
- name: Lint code
run: just lint
###################################################################
# #
# Testing #
# #
###################################################################
- name: Run unit test
run: just test
###################################################################
# #
# CI/CD Bots #
# #
###################################################################
# https://pypi.org/project/pytest-md-report/
- name: Run tests with reports
run: poetry run pytest --md-report --md-report-flavor gfm --md-report-output report.md