forked from afuetterer/oaipmh-scythe
-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (94 loc) · 3.74 KB
/
test.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
name: Test
on:
workflow_call:
env:
PYTHONUNBUFFERED: 1
FORCE_COLOR: 1
permissions:
contents: read
jobs:
test:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-24.04
strategy:
matrix:
python-version: ['3.9', '3.12']
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: ${{ matrix.python-version }}
cache: pip
- name: Install pre-requisites (e.g. hatch)
run: python -m pip install --require-hashes --requirement=.github/requirements/ci.txt
- name: Run test suite
run: hatch run cov
- name: Generate coverage report
run: |
export TOTAL_COV=$(hatch run cov-total)
echo "TOTAL_COV=$TOTAL_COV" >> $GITHUB_ENV
hatch run cov-report-markdown
echo "### Total coverage: ${TOTAL_COV}%" >> $GITHUB_STEP_SUMMARY
cat coverage.md >> $GITHUB_STEP_SUMMARY
if: matrix.python-version == '3.12'
- 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: fcb87d45f4d7defdfeffa65eb1d65f63
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/oaipmh-scythe'
&& 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:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: '3.12'
cache: pip
- run: python -Im pip install --editable .[dev]
- run: python -Ic 'import oaipmh_scythe.__about__; print(oaipmh_scythe.__about__.__version__)'
- name: Set up pipdeptree
if: matrix.os == 'ubuntu-latest'
run: python -m pip install --require-hashes --requirement=.github/requirements/ci.txt
- 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 "$ python -m pipdeptree --local-only --exclude=pip,pipdeptree"
python -m pipdeptree --local-only --exclude=pip,pipdeptree
echo -e "\`\`\`\n</details>"
echo '<details><summary>Outdated Python packages</summary>'
echo -e "\n\`\`\`console"
echo "$ python -m pip list --outdated"
python -m pip list --outdated
echo -e "\`\`\`\n</details>"
} >> $GITHUB_STEP_SUMMARY
build-inspect:
name: Build and inspect the package
runs-on: ubuntu-24.04
steps:
- run: sudo apt-get install tree # workaround for "tree: command not found" in baipp
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: hynek/build-and-inspect-python-package@4aea7de65ba374f49b5f549cd471b61de2ef19d3 # v2.5.0