1+ #
2+ # Perform a regular build on any branch except main
3+
4+ name : build
5+
6+ on :
7+ push :
8+ pull_request :
9+ types : [opened, synchronize]
10+
11+ jobs :
12+ # Prepare the build
13+ prep :
14+ runs-on : ubuntu-latest
15+ permissions :
16+ contents : read
17+ outputs :
18+ abort : ${{ steps.debounce.outputs.abort }}
19+ version : ${{ steps.version.outputs.version }}
20+ steps :
21+ - name : Abort building on push with open PR
22+ id : debounce
23+ uses : MrMatAP/mrmat-build-avoider-action@1.0.19
24+ with :
25+ github-token : ${{ secrets.GITHUB_TOKEN }}
26+ - name : Version the project
27+ id : version
28+ uses : MrMatAP/mrmat-versioning-action@1.0.7
29+ with :
30+ ecosystem : python
31+ major : 1
32+ minor : 1
33+
34+ # A regular project build. Test results will explicitly be reported during a pull request build
35+ build :
36+ runs-on : ubuntu-latest
37+ needs : prep
38+ if : ${{ needs.prep.outputs.abort != 'true' }}
39+ permissions :
40+ contents : read
41+ pull-requests : write
42+ checks : write
43+ env :
44+ MRMAT_VERSION : ${{ needs.prep.outputs.version }}
45+ steps :
46+ - name : Checkout out our code
47+ uses : actions/checkout@v5.0.0
48+ - name : Set up uv and Python
49+ uses : astral-sh/setup-uv@v6.0.0
50+ with :
51+ enable-cache : true
52+ python-version : 3.13.7
53+ - name : Lint
54+ run : uv run --frozen mypy --no-incremental --junit-xml=${GITHUB_WORKSPACE}/build/lint.xml ${GITHUB_WORKSPACE}/src/mrmat_python_api_fastapi || true
55+ - name : Build
56+ run : uv build --wheel
57+ - name : Test
58+ run : uv run --frozen pytest --junit-xml=${GITHUB_WORKSPACE}/build/junit.xml --cov-report=xml:${GITHUB_WORKSPACE}/build/coverage.xml
59+ - name : Upload linting results
60+ if : ${{ github.event_name == 'pull_request' }}
61+ uses : actions/upload-artifact@v4
62+ with :
63+ name : Lint Results
64+ path : build/lint.xml
65+ retention-days : 1
66+ - name : Upload unit test results
67+ if : ${{ github.event_name == 'pull_request' }}
68+ uses : actions/upload-artifact@v4
69+ with :
70+ name : Unit Test Results
71+ path : build/junit.xml
72+ retention-days : 1
73+ - name : Upload coverage results
74+ if : ${{ github.event_name == 'pull_request' }}
75+ uses : actions/upload-artifact@v4
76+ with :
77+ name : Coverage Results
78+ path : build/coverage.xml
79+ retention-days : 1
80+ - name : Report on unit tests
81+ if : ${{ github.event_name == 'pull_request' }}
82+ uses : EnricoMi/publish-unit-test-result-action@v2
83+ with :
84+ check_name : " Unit Tests"
85+ comment_title : " Unit Test Results"
86+ files : build/junit.xml
87+ - name : Report on code coverage
88+ if : ${{ github.event_name == 'pull_request' }}
89+ uses : irongut/CodeCoverageSummary@v1.3.0
90+ with :
91+ filename : build/coverage.xml
92+
93+ # The release job only executes when pushing to the main branch
94+ release :
95+ if : ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
96+ runs-on : ubuntu-latest
97+ permissions :
98+ contents : write
99+ needs :
100+ - prep
101+ - build
102+ steps :
103+ - name : Create Release
104+ id : create_release
105+ uses : actions/create-release@latest
106+ env :
107+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
108+ with :
109+ tag_name : ${{ needs.prep.outputs.version }}
110+ release_name : Release ${{ needs.prep.outputs.version }}
111+ body : |
112+ Release ${{ needs.prep.outputs.version }}
113+ draft : false
114+ prerelease : false
0 commit comments