Skip to content

Commit 42550c7

Browse files
Change how mreg-cli is used for testing in the workflow (#569)
* Modify workflow to use new mreg-cli test script * Fix a typo in the Dockerfile * Add a helper script to use with git bisect * Delete some old files that are no longer in use
1 parent cee5c16 commit 42550c7

File tree

6 files changed

+59
-183
lines changed

6 files changed

+59
-183
lines changed

.github/workflows/container-image.yml

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
types: [opened, reopened, synchronize]
99
workflow_dispatch:
1010

11+
defaults:
12+
run:
13+
shell: bash
14+
1115
jobs:
1216
build:
1317
name: Build image
@@ -72,30 +76,28 @@ jobs:
7276
# There's a docker-compose.yml file in the mreg-cli repo that wants the image from ghcr.io,
7377
# but we want to use the newly built custom image
7478
run: docker tag mreg ghcr.io/unioslo/mreg:latest
75-
- name: Install uv
76-
uses: astral-sh/setup-uv@v3
77-
- name: Set up Python
78-
run: uv python install 3.11
79-
- name: Install git
80-
run: |
81-
sudo apt-get update
82-
sudo apt-get install -y git
83-
- name: Install mreg-cli
79+
- name: Checkout
80+
uses: actions/checkout@v4
81+
- name: Download mreg-cli
82+
run: git clone https://github.com/unioslo/mreg-cli.git
83+
- name: Check out a previous version of mreg-cli
84+
if: ${{ hashFiles('ci/MREG-CLI_COMMIT') != '' }}
8485
run: |
85-
git clone https://github.com/unioslo/mreg-cli.git
86+
cp -r mreg-cli/ci /tmp
87+
C=$(cat ci/MREG-CLI_COMMIT)
8688
cd mreg-cli
87-
uv venv
88-
uv pip install -e ".[dev]"
89+
git -c advice.detachedHead=false checkout $C
90+
cp --no-clobber /tmp/ci/* ci/
8991
- name: Run the tests
92+
run: mreg-cli/ci/run_testsuite_and_record_V2.sh
93+
- name: Comment on the commit that the tests worked
9094
run: |
91-
cd mreg-cli
92-
. .venv/bin/activate
93-
uv run ci/run_testsuite_and_record.sh
94-
- name: Upload the log as an artifact
95-
uses: actions/upload-artifact@v4
96-
with:
97-
name: new_testsuite_log.json
98-
path: mreg-cli/ci/new_testsuite_log.json
95+
C=$(cd mreg-cli && git rev-parse HEAD)
96+
jq -nc "{\"body\": \"Works with https://github.com/unioslo/mreg-cli/commit/$C\"}" | \
97+
curl -sL -X POST -d @- \
98+
-H "Content-Type: application/json" \
99+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
100+
"https://api.github.com/repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/comments"
99101
100102
test-with-curl:
101103
name: Test with curl

.github/workflows/docker-image.yml

Lines changed: 0 additions & 76 deletions
This file was deleted.

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# build stage
2-
FROM python:3.11-alpine as builder
2+
FROM python:3.11-alpine AS builder
33
WORKDIR /usr/src/mreg
44
ENV PYTHONDONTWRITEBYTECODE 1
55
ENV PYTHONUNBUFFERED 1

bisect-helper.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
# This script is intented to be used with "git bisect run".
4+
# For further information, see: man git bisect
5+
6+
# find out where I am
7+
cd $(dirname $0)
8+
DIR=$(pwd)
9+
10+
# clone mreg-cli
11+
if [[ ! -d /tmp/mreg-cli ]]; then
12+
cd /tmp
13+
git clone https://github.com/unioslo/mreg-cli.git
14+
fi
15+
16+
# checkout the correct version of mreg-cli
17+
if [[ -f $DIR/ci/MREG-CLI_COMMIT ]]; then
18+
C=$(cat $DIR/ci/MREG-CLI_COMMIT)
19+
cd /tmp/mreg-cli
20+
git -c advice.detachedHead=false checkout $C
21+
else
22+
cd /tmp/mreg-cli
23+
git checkout master
24+
fi
25+
26+
# build the mreg container image
27+
cd $DIR
28+
docker build -t ghcr.io/unioslo/mreg:latest .
29+
30+
# run the tests. pretend we're on GitHub to prevent interactive review
31+
GITHUB_ACTIONS=123 /tmp/mreg-cli/ci/run_testsuite_and_record_V2.sh
32+
EXITCODE=$?
33+
34+
# cleanup
35+
docker rmi ghcr.io/unioslo/mreg:latest
36+
exit $EXITCODE

ci/channels.scm

Lines changed: 0 additions & 10 deletions
This file was deleted.

ci/manifest.scm

Lines changed: 0 additions & 76 deletions
This file was deleted.

0 commit comments

Comments
 (0)