-
Notifications
You must be signed in to change notification settings - Fork 254
165 lines (158 loc) · 5.7 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: build
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install Black and Flake8
run: |
pip install black==22.3 flake8==5.0.4 flake8-future-import flake8-logging-format flake8-import-order flake8-quotes flake8-black
- name: Run Flake8
run: |
black --version
flake8 --version
flake8
- name: Install clang-format 12
run: |
wget -O clang-format https://github.com/DMOJ/clang-tools-static-binaries/releases/download/master-5ea3d18c/clang-format-12_linux-amd64
chmod a+x ./clang-format
- name: Run clang-format
run: find dmoj/ \( -name '*.h' -or -name '*.cpp' -or -name '*.c' \) -not -name _cptbox.cpp -print0 | xargs -0 ./clang-format --dry-run -Werror --color
mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies and mypy
run: |
pip install cython mypy types-termcolor types-requests types-PyYAML
pip install -r requirements.txt
- name: Verify mypy types
run: |
mypy --version
mypy dmoj
test-sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install build dependencies
run: pip install cython
- name: Create sdist
run: python setup.py sdist
- name: Install test dependencies
run: sudo apt-get install -y libseccomp-dev
- name: Test sdist
run: |
pip install dist/*.tar.gz
dmoj-autoconf
amd64:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ]
steps:
- uses: actions/checkout@v3
- name: Download docker image
run: docker pull dmoj/runtimes-tier3
- name: Install python
run: |
curl -L "https://github.com/DMOJ/runtimes-python/releases/latest/download/python${{ matrix.python-version }}-amd64.tar.gz" |
tar -xz
- name: Create docker scripts
run: |
cat > run <<'EOF'
#!/bin/bash -e
export PYTHONUNBUFFERED=1
export LANG=C.UTF-8
export PYTHONIOENCODING=utf8
cd /code
export PYTHON="/code/python${{ matrix.python-version }}/bin/python${{ matrix.python-version }}"
"$PYTHON" -m pip install --upgrade pip wheel
"$PYTHON" -m pip install cython coverage
"$PYTHON" -m pip install -e .[test]
chmod o+w .
runuser -u judge -w PATH /code/run-su
EOF
cat > run-su <<'EOF'
#!/bin/bash -e
. ~/.profile
cd /code
"$PYTHON" -m coverage run -m unittest discover dmoj/tests/
"$PYTHON" -m coverage run --append .docker.test.py
"$PYTHON" -m coverage combine
"$PYTHON" -m coverage xml
EOF
chmod a+x run run-su
- uses: actions/cache@v2
with:
path: ~/docker-cache
key: ${{ runner.os }}-python-${{ matrix.python-version }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}
- name: Create cache
run: |
mkdir -p "$HOME/docker-cache/pip"
sudo chown root:root -R "$HOME/docker-cache"
- name: Execute tests in docker
run: docker run -e PYTHON_VERSION="${{ matrix.python-version }}" -v "$(pwd):/code" -v "$HOME/docker-cache:/root/.cache" --cap-add=SYS_PTRACE dmoj/runtimes-tier3
- name: Upload coverage data
uses: codecov/codecov-action@v1
- name: Prepare cache for storage
run: sudo chown -R "$USER:$USER" "$HOME/docker-cache"
arm64:
runs-on: [self-hosted, Linux, ARM64]
strategy:
matrix:
python-version: [ '3.11' ]
steps:
- uses: actions/checkout@v3
- name: Download docker image
run: docker pull dmoj/runtimes-tier3
- name: Create docker scripts
run: |
cat > run <<'EOF'
#!/bin/bash -e
cp -r /source /code
cd /code
curl -L "https://github.com/DMOJ/runtimes-python/releases/latest/download/python${{ matrix.python-version }}-aarch64.tar.gz" | tar -xz
export PYTHONUNBUFFERED=1
export LANG=C.UTF-8
export PYTHONIOENCODING=utf8
export PYTHON="/code/python${{ matrix.python-version }}/bin/python${{ matrix.python-version }}"
"$PYTHON" -m pip install --upgrade pip wheel
"$PYTHON" -m pip install cython coverage
"$PYTHON" -m pip install -e .[test]
chmod o+w .
code=0
runuser -u judge -w PATH /source/run-su || code=$?
cp /code/coverage.xml /source || true
exit "$code"
EOF
cat > run-su <<'EOF'
#!/bin/bash -e
. ~/.profile
cd /code
"$PYTHON" -m coverage run -m unittest discover dmoj/tests/
"$PYTHON" -m coverage run --append .docker.test.py
"$PYTHON" -m coverage combine
"$PYTHON" -m coverage xml
EOF
chmod a+x run run-su
- name: Execute tests in docker
run: |
docker run -e PYTHON_VERSION="${{ matrix.python-version }}" -v "$(pwd):/source" -v "$HOME/docker-cache:/root/.cache" \
--entrypoint=/usr/bin/tini --cap-add=SYS_PTRACE dmoj/runtimes-tier3 /source/run
- name: Upload coverage data
uses: codecov/codecov-action@v1