-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (130 loc) · 4.96 KB
/
test.yml
File metadata and controls
137 lines (130 loc) · 4.96 KB
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
name: Test
on:
schedule:
# run once a month at midnight of the first day of the month
- cron: 0 0 1 * *
workflow_call:
workflow_dispatch: # run manually from actions tab
# Set permissions at the job level.
permissions: {}
env:
PYTHONUNBUFFERED: 1
FORCE_COLOR: 1
UV_LOCKED: true # do not update the lockfile during `uv sync` and `uv run` commands
jobs:
test:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-24.04
strategy:
matrix:
python-version: ['3.10', '3.12', '3.13']
steps:
- name: Set up just
uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v3
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up uv
uses: astral-sh/setup-uv@f94ec6bedd8674c4426838e6b50417d36b6ab231 # v5.3.1
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
prune-cache: false
- name: Install project, including dev dependencies
run: just sync
- name: Run test suite
run: just cov
env:
TERM: dumb # keep rich from printing escape sequences, which made testing CLI outputs messy
- name: Run e2e tests
run: just e2e-test
if: matrix.python-version == '3.13'
- name: Generate coverage report
run: |
export TOTAL_COV=$(hatch run cov-total)
echo "TOTAL_COV=$TOTAL_COV" >> $GITHUB_ENV
just cov-report-markdown
echo "### Total coverage: ${TOTAL_COV}%" >> $GITHUB_STEP_SUMMARY
cat coverage.md >> $GITHUB_STEP_SUMMARY
if: matrix.python-version == '3.13'
- name: Generate coverage badge
uses: schneegans/dynamic-badges-action@e9a478b16159b4d31420099ba146cdc50f134483 # v1.7.0
with:
# GIST_TOKEN is a GitHub personal access token with scope "gist".
auth: ${{ secrets.GIST_TOKEN }}
gistID: adc66df152c473c1aa136557ee8181ca
filename: coverage-badge.json
label: Coverage
namedLogo: python
message: ${{ env.TOTAL_COV }}%
minColorRange: 50
maxColorRange: 90
valColorRange: ${{ env.TOTAL_COV }}
# only update coverage badge
# when push to main branch of the project -> not in forks
if: >-
env.TOTAL_COV
&& github.repository == 'afuetterer/python-re3data'
&& github.ref == 'refs/heads/main'
dev-setup:
# Ref: structlog (MIT License) <https://github.com/hynek/structlog/blob/main/.github/workflows/ci.yml>
name: Install [dev] on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Set up just
uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v3
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up uv
uses: astral-sh/setup-uv@f94ec6bedd8674c4426838e6b50417d36b6ab231 # v5.3.1
with:
python-version: '3.13'
enable-cache: true
prune-cache: false
- run: just sync
- run: python -Ic 'import re3data; print(re3data.__version__)'
- run: re3data --version
- name: Write info to step summary
if: matrix.os == 'ubuntu-latest'
run: |
{
echo -e "### ✓ All dependencies installed successfully\n\n"
echo '<details><summary>Installed Python packages (dependency tree)</summary>'
echo -e "\n\`\`\`console"
echo "$ uv tree --no-group={dev,test}"
uv tree --no-group={dev,test}
echo -e "\`\`\`\n</details>"
echo '<details><summary>Outdated Python packages</summary>'
echo -e "\n\`\`\`console"
echo "$ uv pip list --outdated"
uv pip list --outdated
echo -e "\`\`\`\n</details>"
} >> $GITHUB_STEP_SUMMARY
build-inspect:
name: Build and inspect the package
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: hynek/build-and-inspect-python-package@b5076c307dc91924a82ad150cdd1533b444d3310 # v2.12.0
docker:
name: Build and run the docker image
runs-on: ubuntu-24.04
env:
NO_COLOR: 1
steps:
- name: Set up just
uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v3
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up uv
uses: astral-sh/setup-uv@f94ec6bedd8674c4426838e6b50417d36b6ab231 # v5.3.1
- name: Get package version
id: package-version
run: echo "version=$(just project-version)" >> $GITHUB_OUTPUT
- uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
- name: Build and push
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0
with:
load: true
tags: afuetterer/python-re3data:test
build-args: VERSION=${{ steps.package-version.outputs.version }}
- run: docker run --rm afuetterer/python-re3data:test --help