Skip to content

Commit e612c8d

Browse files
authored
Merge branch 'main' into cross-rbase-v1
2 parents ad59ad8 + 1d7012a commit e612c8d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+4476
-1330
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
id: version
4343
if: ${{ ! env.CI_SKIP }}
4444
run: |
45-
echo "current version: "$(git tag --sort=committerdate | tail -1)
45+
echo "recent version tags: "$(git tag --sort=committerdate | tail -4)
4646
NEXT=$(python autotick-bot/compute_next_version.py)
4747
echo "next version: ${NEXT}"
4848
echo "NEXT=${NEXT}" >> "$GITHUB_OUTPUT"

.github/workflows/tests-reusable.yml

Lines changed: 158 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ jobs:
3939
defaults:
4040
run:
4141
shell: bash -leo pipefail {0}
42+
env:
43+
NUM_SPLITS: 2
4244

4345
steps:
4446
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -103,19 +105,6 @@ jobs:
103105
104106
python -m pip install -v --no-deps --no-build-isolation -e .
105107
106-
- name: start MongoDB
107-
uses: supercharge/mongodb-github-action@90004df786821b6308fb02299e5835d0dae05d0d # v1.12.0
108-
if: ${{ ! env.CI_SKIP }}
109-
with:
110-
mongodb-version: "latest"
111-
112-
- name: test mongodb is OK
113-
if: ${{ ! env.CI_SKIP }}
114-
run: |
115-
python -c "from pymongo import MongoClient; import os; print(MongoClient(os.environ['MONGODB_CONNECTION_STRING']))"
116-
env:
117-
MONGODB_CONNECTION_STRING: "mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000"
118-
119108
- name: set up docker buildx
120109
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
121110
if: ${{ ! env.CI_SKIP }}
@@ -143,14 +132,13 @@ jobs:
143132
if: ${{ ! env.CI_SKIP }}
144133
run: |
145134
export TEST_BOT_TOKEN_VAL=unpassword
146-
# note: we do not use pytest-xdist (-n auto) here for now because they interfere with hiding the
147-
# MONGODB_CONNECTION_STRING sensitive environment variable
148135
if [[ -f .test_durations ]]; then
149136
cp .test_durations .test_durations.${{ matrix.group }}
150137
fi
151138
pytest \
152139
-v \
153-
--splits 2 --group ${{ matrix.group }} \
140+
-n 3 \
141+
--splits ${NUM_SPLITS} --group ${{ matrix.group }} \
154142
--store-durations \
155143
--durations-path=.test_durations.${{ matrix.group }} \
156144
--splitting-algorithm least_duration \
@@ -162,9 +150,9 @@ jobs:
162150
--cov-report=xml \
163151
--durations=10 \
164152
--ignore=tests/model \
153+
-m "not mongodb" \
165154
tests
166155
env:
167-
MONGODB_CONNECTION_STRING: "mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000"
168156
RUN_URL: ""
169157
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
170158

@@ -184,9 +172,159 @@ jobs:
184172
path: .coverage
185173
include-hidden-files: true
186174

175+
tests-mongodb:
176+
name: tests-mongodb
177+
runs-on: "ubuntu-latest"
178+
permissions:
179+
actions: write # for deleting cache entries
180+
contents: read
181+
strategy:
182+
# continue running the tests even if one of the groups fails
183+
fail-fast: false
184+
matrix:
185+
# if change the number of groups here, also change it next to --splits below
186+
group: [1]
187+
defaults:
188+
run:
189+
shell: bash -leo pipefail {0}
190+
191+
steps:
192+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
193+
with:
194+
repository: "regro/cf-scripts"
195+
196+
- name: prep the lockfile
197+
if: ${{ !inputs.lockfile-is-artifact }}
198+
run: |
199+
mkdir input-lockfile
200+
mv conda-lock.yml input-lockfile/${{ inputs.lockfile }}
201+
202+
- name: download lockfile if it is an artifact
203+
if: ${{ inputs.lockfile-is-artifact }}
204+
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
205+
with:
206+
name: ${{ inputs.lockfile }}
207+
path: input-lockfile
208+
209+
- name: move lockfile to repo
210+
run: |
211+
mv input-lockfile/${{ inputs.lockfile }} conda-lock.yml
212+
rm -rf input-lockfile
213+
214+
- uses: mamba-org/setup-micromamba@0dea6379afdaffa5d528b3d1dabc45da37f443fc # v2.0.4
215+
with:
216+
environment-file: conda-lock.yml
217+
environment-name: cf-scripts
218+
condarc-file: autotick-bot/condarc
219+
220+
- name: stop me if needed
221+
run: |
222+
python autotick-bot/stop_me_if_needed.py
223+
224+
- name: configure conda and install code
225+
if: ${{ ! env.CI_SKIP }}
226+
run: |
227+
pip install --no-deps --no-build-isolation -e .
228+
229+
- name: Set up git
230+
if: ${{ ! env.CI_SKIP }}
231+
run: |
232+
git config --global user.name regro-cf-autotick-bot
233+
git config --global user.email [email protected]
234+
git config --global pull.rebase false
235+
236+
- name: test versions
237+
if: ${{ ! env.CI_SKIP }}
238+
run: |
239+
cd ..
240+
python -c "import conda_forge_tick; assert conda_forge_tick.__version__ != '0.0.0'"
241+
cd -
242+
243+
pip uninstall conda-forge-tick --yes
244+
rm -rf dist/*
245+
python -m build --sdist . --outdir dist
246+
pip install --no-deps --no-build-isolation dist/*.tar.gz
247+
cd ..
248+
python -c "import conda_forge_tick; assert conda_forge_tick.__version__ != '0.0.0'"
249+
cd -
250+
pip uninstall conda-forge-tick --yes
251+
252+
python -m pip install -v --no-deps --no-build-isolation -e .
253+
254+
- name: start MongoDB
255+
uses: supercharge/mongodb-github-action@90004df786821b6308fb02299e5835d0dae05d0d # v1.12.0
256+
if: ${{ ! env.CI_SKIP }}
257+
with:
258+
mongodb-version: "latest"
259+
260+
- name: test mongodb is OK
261+
if: ${{ ! env.CI_SKIP }}
262+
run: |
263+
python -c "from pymongo import MongoClient; import os; print(MongoClient(os.environ['MONGODB_CONNECTION_STRING']))"
264+
env:
265+
MONGODB_CONNECTION_STRING: "mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000"
266+
267+
- name: restore test durations
268+
uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
269+
if: ${{ ! env.CI_SKIP }}
270+
with:
271+
path: .test_durations
272+
key: test-durations-${{ github.ref }}-${{ github.sha }}
273+
restore-keys: |
274+
test-durations-${{ github.ref }}-
275+
test-durations-
276+
277+
- name: run pytest
278+
if: ${{ ! env.CI_SKIP }}
279+
run: |
280+
export TEST_BOT_TOKEN_VAL=unpassword
281+
# note: we do not use pytest-xdist (-n auto) here for now because they interfere with hiding the
282+
# MONGODB_CONNECTION_STRING sensitive environment variable
283+
if [[ -f .test_durations ]]; then
284+
cp .test_durations .test_durations.${{ matrix.group }}
285+
fi
286+
pytest \
287+
-v \
288+
--splits 1 --group ${{ matrix.group }} \
289+
--store-durations \
290+
--durations-path=.test_durations.mongodb \
291+
--splitting-algorithm least_duration \
292+
--clean-durations \
293+
--cov=conda_forge_tick \
294+
--cov=tests \
295+
--cov-config=.coveragerc \
296+
--cov-report=term-missing \
297+
--cov-report=xml \
298+
--durations=10 \
299+
--ignore=tests/model \
300+
-m "mongodb" \
301+
tests
302+
env:
303+
MONGODB_CONNECTION_STRING: "mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000"
304+
RUN_URL: ""
305+
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
306+
307+
- name: upload test durations
308+
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
309+
if: ${{ ! env.CI_SKIP }}
310+
with:
311+
name: test-durations-mongodb
312+
path: .test_durations.mongodb
313+
include-hidden-files: true
314+
315+
- name: upload coverage
316+
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
317+
if: ${{ ! env.CI_SKIP }}
318+
with:
319+
name: coverage-mongodb
320+
path: .coverage
321+
include-hidden-files: true
322+
187323
test-coverage-and-durations:
188324
name: test-coverage-and-durations
189-
needs: tests
325+
needs:
326+
- tests
327+
- tests-mongodb
190328
runs-on: "ubuntu-latest"
191329
defaults:
192330
run:
@@ -261,7 +399,8 @@ jobs:
261399
- name: combine test durations
262400
if: ${{ ! env.CI_SKIP }}
263401
run: |
264-
jq '. + input' test-durations-*/.test_durations.* > .test_durations
402+
# see https://stackoverflow.com/a/71416016/1745538
403+
jq 'reduce inputs as $i (.; . + $i)' test-durations-*/.test_durations.* > .test_durations
265404
266405
- name: upload test durations
267406
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ RUN conda activate base && \
3030
pip install --no-deps --no-build-isolation -e . && \
3131
cd - && \
3232
conda deactivate && \
33-
conda deactivate
33+
conda deactivate && \
34+
# remove .git dir once installed and version is set
35+
rm -rf $AUTOTICK_BOT_DIR/.git
3436

3537
# now make the conda user for running tasks and set the user
3638
RUN useradd --shell /bin/bash -c "" -m conda
@@ -40,6 +42,7 @@ ENV LOGNAME=conda
4042
ENV MAIL=/var/spool/mail/conda
4143
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/conda/bin
4244
RUN chown conda:conda $HOME && \
45+
chown -R conda:conda /opt/autotick-bot && \
4346
cp -R /etc/skel $HOME && \
4447
chown -R conda:conda $HOME/skel && \
4548
(ls -A1 $HOME/skel | xargs -I {} mv -n $HOME/skel/{} $HOME) && \

autotick-bot/compute_next_version.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import subprocess
33
import sys
44

5+
from conda.models.version import VersionOrder
6+
57
# get the current date for tagging below
68
now = datetime.datetime.utcnow()
79

@@ -18,15 +20,28 @@
1820
else:
1921
# we have a tag so bump
2022
curr_version = None
23+
curr_version_line = None
2124
for line in res.stdout.splitlines():
2225
line = line.strip()
2326
if line:
24-
curr_version = line
27+
try:
28+
_version = VersionOrder(line)
29+
except Exception:
30+
print(
31+
f"skipping tag that is not a version: {line}",
32+
file=sys.stderr,
33+
flush=True,
34+
)
35+
continue
36+
37+
if curr_version is None or _version > curr_version:
38+
curr_version = _version
39+
curr_version_line = line
2540
assert curr_version is not None
26-
print("found current version: %s" % line, file=sys.stderr, flush=True)
41+
print(f"found current version: {curr_version_line}", file=sys.stderr, flush=True)
2742

2843
# figure out if we bump the major, minor or patch version
29-
major_minor, patch = curr_version.rsplit(".", 1)
44+
major_minor, patch = curr_version_line.rsplit(".", 1)
3045
now_major_minor = f"{now.year}.{now.month}"
3146
if major_minor == now_major_minor:
3247
new_version = f"{major_minor}.{int(patch) + 1}"

0 commit comments

Comments
 (0)