-
Notifications
You must be signed in to change notification settings - Fork 1
149 lines (131 loc) · 4.26 KB
/
github_actions.yml
File metadata and controls
149 lines (131 loc) · 4.26 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
138
139
140
141
142
143
144
145
146
147
148
149
name: CI
on:
push:
branches: [ "**" ]
pull_request:
branches: [ "**" ]
jobs:
test:
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[test]"
- name: Run tests with coverage
env:
OPENBLAS_NUM_THREADS: "1"
OMP_NUM_THREADS: "1"
MKL_NUM_THREADS: "1"
NUMEXPR_NUM_THREADS: "1"
# Enable slow Connolly/SC reference checks — best regression guard for SC numerics
ALPHAJUDGE_RUN_SLOW_SC_REFERENCE: "1"
run: |
pytest test/ \
-n auto --timeout=900 \
--cov=src/alphajudge \
--cov-report=term \
--cov-report=xml:coverage.xml \
--cov-report=html:htmlcov \
--junitxml=junit.xml
- name: Upload coverage artifacts
if: matrix.python-version == '3.12'
uses: actions/upload-artifact@v4
with:
name: coverage-html
path: htmlcov
if-no-files-found: error
retention-days: 14
- name: Upload coverage XML
if: matrix.python-version == '3.12'
uses: actions/upload-artifact@v4
with:
name: coverage-xml
path: coverage.xml
if-no-files-found: error
retention-days: 14
coverage-pages:
needs: test
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Download coverage HTML
uses: actions/download-artifact@v4
with:
name: coverage-html
path: htmlcov
- name: Configure Pages
uses: actions/configure-pages@v5
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: htmlcov
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
docker:
runs-on: ubuntu-latest
needs: test
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main' || (github.event_name == 'release' && github.event.action == 'published')
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build test stage (no push) for PR
if: github.event_name == 'pull_request'
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile
target: test
push: false
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Run tests by building test stage before push
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile
target: test
push: false
- name: Build and push :latest on push to main
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile
target: runtime
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/alphajudge:latest
- name: Build and push :<tag> on release
if: github.event_name == 'release' && github.event.action == 'published'
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile
target: runtime
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/alphajudge:${{ (github.event_name == 'release' && github.event.action == 'published') && github.event.release.tag_name || 'latest' }}