This repository has been archived by the owner on Apr 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
201 lines (184 loc) · 6.57 KB
/
test-pr.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
name: 'Run Tests'
on:
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
version-bump:
name: 'Version Bump'
runs-on: ubuntu-latest
steps:
- name: 'Check out code'
uses: actions/checkout@v3
with:
token: ${{ secrets.JENKINS_GITHUB_PAT }}
# fetch-depth 0 means deep clone the repo
fetch-depth: 0
- name: 'Update version'
run: |
set -x
git config user.name devops
git config user.email [email protected]
./package/version.sh bump $(git show origin/${GITHUB_BASE_REF}:package/version)
./package/version.sh sub
if git add --update && git commit --message "Set Version: $(cat package/version)"; then
git push origin HEAD:${GITHUB_HEAD_REF}
fi
code-quality-checks:
needs: version-bump
name: 'Code Quality Checks'
runs-on: ubuntu-latest
steps:
- name: 'Check out code'
uses: actions/checkout@v3
- name: 'Install Poetry'
uses: Gr1N/setup-poetry@v8
- name: 'Run code quality checks'
run: make check
- name: 'Run pyupgrade'
run: make pyupgrade
build-docs:
needs: code-quality-checks
name: 'Build Documentation'
runs-on: ubuntu-latest
steps:
- name: 'Check out code'
uses: actions/checkout@v3
- name: 'Install Poetry'
uses: Gr1N/setup-poetry@v8
- name: 'Build documentation'
run: make docs
unit-tests:
needs: code-quality-checks
name: 'Unit Tests'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: 'Check out code'
uses: actions/checkout@v3
- name: 'Install Poetry'
uses: Gr1N/setup-poetry@v8
- name: 'Run unit tests'
run: make cov-unit
profile:
needs: code-quality-checks
name: 'Profiling'
runs-on: [self-hosted, linux, normal]
timeout-minutes: 10
strategy:
matrix:
python-version: ['3.10']
steps:
- name: 'Check out code'
uses: actions/checkout@v3
- name: 'Build Docker image'
run: |
COMMIT=$(git rev-parse --short=7 HEAD)
K_VERSION=$(cut --delim=v --field=2 deps/k_release)
docker build . \
--build-arg PYTHON_VERSION=${{ matrix.python-version }} \
--build-arg K_VERSION=${K_VERSION} \
--tag runtimeverificationinc/pyk-ci:${COMMIT}
docker run \
--name pyk-ci \
--rm \
--interactive \
--tty \
--detach \
--workdir /home/user \
runtimeverificationinc/pyk-ci:${COMMIT}
docker cp . pyk-ci:/home/user
docker exec pyk-ci chown -R user:user /home/user
- name: 'Set Python version'
run: docker exec --user user pyk-ci poetry env use ${{ matrix.python-version }}
- name: 'Build and run integration tests'
run: |
docker exec --user user pyk-ci make profile
docker exec --user user pyk-ci bash -c "find /tmp/pytest-of-${USER}/pytest-current/ -type f -name '*.prof' | sort | xargs tail -n +1"
- name: 'Tear down Docker container'
if: always()
run: |
docker stop --time=0 pyk-ci
integration-tests:
needs: code-quality-checks
name: 'Integration Tests'
runs-on: [self-hosted, linux, normal]
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11']
steps:
- name: 'Check out code'
uses: actions/checkout@v3
- name: 'Build Docker image'
run: |
COMMIT=$(git rev-parse --short=7 HEAD)
K_VERSION=$(cut --delim=v --field=2 deps/k_release)
docker build . \
--build-arg PYTHON_VERSION=${{ matrix.python-version }} \
--build-arg K_VERSION=${K_VERSION} \
--tag runtimeverificationinc/pyk-ci:${COMMIT}
docker run \
--name pyk-ci \
--rm \
--interactive \
--tty \
--detach \
--workdir /home/user \
runtimeverificationinc/pyk-ci:${COMMIT}
docker cp . pyk-ci:/home/user
docker exec pyk-ci chown -R user:user /home/user
- name: 'Set Python version'
run: docker exec --user user pyk-ci poetry env use ${{ matrix.python-version }}
- name: 'Build and run integration tests'
run: docker exec --user user pyk-ci make cov-integration COV_ARGS='-n8 --timeout 500'
- name: 'Tear down Docker container'
if: always()
run: |
docker stop --time=0 pyk-ci
build-on-nix:
needs: code-quality-checks
name: 'Build on Nix'
strategy:
matrix:
os: [ubuntu-latest, macos-13]
target: [pyk-python310, pyk-python311]
runs-on: ${{ matrix.os }}
steps:
- name: 'Check out code'
uses: actions/checkout@v3
- name: 'Install Nix/Cachix'
uses: cachix/install-nix-action@v19
with:
install_url: https://releases.nixos.org/nix/nix-2.13.3/install
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- uses: cachix/cachix-action@v12
with:
name: k-framework
authToken: '${{ secrets.CACHIX_PUBLIC_KEY }}'
- name: 'Build pyk'
run: GC_DONT_GC=1 nix build --print-build-logs .#${{ matrix.target }}
build-docker:
needs: integration-tests
name: 'Build docker image for release'
runs-on: [self-hosted, linux, normal]
timeout-minutes: 10
steps:
- name: 'Check out code'
uses: actions/checkout@v4
- name: 'Build Docker image for release'
run: |
COMMIT=$(git rev-parse --short=7 HEAD)
K_VERSION=$(cut --delim=v --field=2 deps/k_release)
PYK_VERSION=$(cat package/version)
docker build . \
-f package/Dockerfile \
--build-arg K_VERSION=${K_VERSION} \
--build-arg PYK_VERSION=${PYK_VERSION} \
--tag runtimeverificationinc/kframework-pyk:${COMMIT}
docker run --rm runtimeverificationinc/kframework-pyk:${COMMIT}
docker run --rm runtimeverificationinc/kframework-pyk:${COMMIT} kompile --version