-
Notifications
You must be signed in to change notification settings - Fork 5
150 lines (136 loc) · 4.32 KB
/
build.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# Basic workflow
name: build
# Use more columns for terminal output
env:
COLUMNS: 120
PYTHONIOENCODING: utf8
# Controls when the action will run
# Workflow begins with push or PR events
# Focuses on the master branch only
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Create one single job
# This job performs all of the necessary checks
jobs:
build:
# Use the latest version of Ubuntu, MacOS, and Windows
# Use the latest and most stable version of Python
# Important: test coverage monitoring and reporting
# through a badge and the GitHub Actions job summary
# only takes place with the Linux operating system.
# Important: the MacOS and Windows operating systems
# have test coverage calculation take place but they
# do not report the test coverage beyond its display
# inside of the GitHub Actions panel for that job.
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.12"]
include:
- os: macos-latest
python-version: "3.12"
- os: windows-latest
python-version: "3.12"
# Define the workflow steps
steps:
# Checkout the code of the repository
- name: Check out Repository Code
uses: actions/checkout@v3
with:
fetch-depth: 0
# Setup Python for the current language version
- name: Setup Python ${{ matrix.python-version }}
if: always()
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# Install pip
- name: Install Pip
if: always()
run: |
python -m pip install --upgrade pip
# Install poetry
- name: Install Poetry
if: always()
uses: abatilo/[email protected]
with:
poetry-version: 1.8.3
# Install dependencies
- name: Install dependencies
if: always()
run: |
poetry install
# Run the linters
- name: Run Linters
if: always()
run: |
# install ruff directly instead of managing
# it as a dependency with Poetry since ruff
# does not (always) install correctly
# through Poetry on NixOS
pipx install ruff
poetry run task lint
# Run the tests
- name: Run Tests
if: always()
run: |
# do not run the Hypothesis-based fuzz tests
# because they sometimes take longer to run
# on Windows and MacOS and this creates errors
poetry run task test-not-fuzz
test:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install
- name: Run tests and generate coverage
run: |
poetry run pytest -s --cov=my_package --cov-report json:coverage.json
- name: Generate coverage and version badges
run: |
poetry run python scripts/badges.py
- name: Commit badge
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
git add README.md
git commit -m "Update coverage and version badges"
git push
runs-on: ubuntu-latest
- name: Check out repository
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12.3'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install
- name: Run tests and generate coverage
run: |
poetry run pytest -s --cov=my_package --cov-report json:coverage.json
- name: Generate coverage and version badges
run: |
poetry run python badges.py
- name: Commit badge
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
git add README.md
git commit -m "Update coverage and version badges"
git push