-
Notifications
You must be signed in to change notification settings - Fork 79
185 lines (159 loc) · 5.98 KB
/
tests.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
name: tests
on:
push:
branches:
- master
pull_request: null
merge_group: null
env:
PY_COLORS: "1"
IMAGE_NAME: conda-forge-tick
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
tests:
name: tests
runs-on: "ubuntu-latest"
permissions:
actions: write # for deleting cache entries
contents: read
strategy:
# continue running the tests even if one of the groups fails
fail-fast: false
matrix:
# if change the number of groups here, also change it next to --splits below
group: [1, 2]
defaults:
run:
shell: bash -leo pipefail {0}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: mamba-org/setup-micromamba@f8b8a1e23a26f60a44c853292711bacfd3eac822 # v1
with:
environment-file: conda-lock.yml
environment-name: cf-scripts
condarc-file: autotick-bot/condarc
- name: configure conda and install code
run: |
pip install --no-deps --no-build-isolation -e .
- name: test versions
run: |
cd ..
python -c "import conda_forge_tick; assert conda_forge_tick.__version__ != '0.0.0'"
cd -
pip uninstall conda-forge-tick --yes
rm -rf dist/*
python -m build --sdist . --outdir dist
pip install --no-deps --no-build-isolation dist/*.tar.gz
cd ..
python -c "import conda_forge_tick; assert conda_forge_tick.__version__ != '0.0.0'"
cd -
pip uninstall conda-forge-tick --yes
python -m pip install -v --no-deps --no-build-isolation -e .
- name: start MongoDB
uses: MongoCamp/mongodb-github-action@e76ad215d47c31a99b4b0b1fde05f6cd1185df1a # e76ad215d47c31a99b4b0b1fde05f6cd1185df1a
with:
mongodb-version: "latest"
- name: test mongodb is OK
run: |
python -c "from pymongo import MongoClient; import os; print(MongoClient(os.environ['MONGODB_CONNECTION_STRING']))"
env:
MONGODB_CONNECTION_STRING: "mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000"
- name: set up docker buildx
uses: docker/setup-buildx-action@v3
- name: build docker image
uses: docker/build-push-action@16ebe778df0e7752d2cfcbd924afdbbd89c1a755 # v6
with:
context: .
push: false
load: true
tags: ${{ env.IMAGE_NAME }}:test
cache-from: type=gha
cache-to: type=gha,mode=max
- name: restore test durations
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
with:
path: .test_durations
key: test-durations-${{ github.ref }}-${{ github.sha }}
restore-keys: |
test-durations-${{ github.ref }}-
test-durations-
- name: run pytest
run: |
export TEST_BOT_TOKEN_VAL=unpassword
export BOT_TOKEN=${TEST_BOT_TOKEN_VAL}
# note: we do not use pytest-xdist (-n auto) here for now because they interfere with hiding the
# MONGODB_CONNECTION_STRING sensitive environment variable
if [[ -f .test_durations ]]; then
cp .test_durations .test_durations.${{ matrix.group }}
fi
pytest \
-v \
--splits 2 --group ${{ matrix.group }} \
--store-durations \
--durations-path=.test_durations.${{ matrix.group }} \
--randomly-seed=${{ github.run_id }} \
--splitting-algorithm least_duration \
--cov=conda_forge_tick \
--cov=tests \
--cov-config=.coveragerc \
--cov-report=term-missing \
--cov-report=xml \
--durations=10 \
--ignore=tests/model \
tests
env:
MONGODB_CONNECTION_STRING: "mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000"
RUN_URL: ""
- name: upload test durations
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4
with:
name: test-durations-${{ matrix.group }}
path: .test_durations.${{ matrix.group }}
- name: upload coverage
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4
with:
name: coverage-${{ matrix.group }}
path: .coverage
test-coverage-and-durations:
name: test-coverage-and-durations
needs: tests
runs-on: "ubuntu-latest"
defaults:
run:
shell: bash -leo pipefail {0}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: mamba-org/setup-micromamba@f8b8a1e23a26f60a44c853292711bacfd3eac822 # v1
with:
environment-file: conda-lock.yml
environment-name: cf-scripts
condarc-file: autotick-bot/condarc
- name: download coverage artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
pattern: coverage-*
- name: combine coverage
run: |
coverage combine coverage-*/.coverage*
coverage xml
- name: upload codecov
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: cache test durations
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
with:
path: .test_durations
key: test-durations-${{ github.ref }}-${{ github.sha }}
restore-keys: |
test-durations-${{ github.ref }}-
test-durations-
- name: download test duration artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
pattern: test-durations-*
- name: combine test durations
run: |
jq '. + input' test-durations-*/.test_durations.* > .test_durations