Skip to content

Commit acf59e8

Browse files
ci(medcat-service): Change GHA to build and test the image before push (#551)
1 parent e50eb43 commit acf59e8

3 files changed

Lines changed: 38 additions & 40 deletions

File tree

.github/workflows/medcat-service_docker.yml

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ defaults:
1717
run:
1818
working-directory: ./medcat-service
1919
jobs:
20-
build:
20+
build-test-push:
2121
if: github.event.pull_request.user.login != 'dependabot[bot]' && github.repository == 'CogStack/cogstack-nlp'
2222
runs-on: ubuntu-latest
23-
outputs:
24-
image_version: ${{ steps.meta.outputs.version }}
2523
steps:
2624
- name: Checkout
2725
uses: actions/checkout@v6
@@ -70,8 +68,29 @@ jobs:
7068
- name: Make medact-v2 available within build
7169
run: cp -r ../medcat-v2 medcat-v2
7270

73-
- name: Build and push Docker MedCATservice image
71+
- name: Build Docker MedCATservice image for testing
7472
id: docker_build
73+
uses: docker/build-push-action@v7
74+
with:
75+
context: ./medcat-service/
76+
load: true # https://docs.docker.com/build/ci/github-actions/test-before-push/
77+
allow: network.host
78+
tags: cogstacksystems/medcat-service:test
79+
labels: ${{ steps.meta.outputs.labels }}
80+
cache-from: type=registry,ref=cogstacksystems/medcat-service:buildcache
81+
cache-to: type=registry,ref=cogstacksystems/medcat-service:buildcache,mode=max
82+
build-args: |
83+
REINSTALL_CORE_FROM_LOCAL=true
84+
85+
- name: Run integration tests (matrix variants)
86+
run: |
87+
export IMAGE_TAG=test
88+
for variant in v1 v2 DeID; do
89+
echo "🧪 Running Examples test for variant: ${variant}"
90+
bash scripts/test_examples.sh "${variant}"
91+
done
92+
93+
- name: Push Docker MedCATservice image
7594
uses: docker/build-push-action@v7
7695
with:
7796
context: ./medcat-service/
@@ -83,7 +102,7 @@ jobs:
83102
cache-to: type=registry,ref=cogstacksystems/medcat-service:buildcache,mode=max
84103
build-args: |
85104
REINSTALL_CORE_FROM_LOCAL=true
86-
105+
87106
- name: Extract metadata (tags, labels) for Docker MedCATservice-gpu
88107
id: meta-gpu
89108
uses: docker/metadata-action@v6
@@ -101,8 +120,6 @@ jobs:
101120
# Create version tag based on tag prefix
102121
type=match,pattern=medcat-service/v(\d+\.\d+\.\d+),group=1
103122
flavor: latest=false
104-
build-args: |
105-
REINSTALL_CORE_FROM_LOCAL=true
106123

107124
- name: Build and push Docker Jupyter singleuser image with GPU support
108125
id: docker_build_gpu
@@ -118,34 +135,7 @@ jobs:
118135
cache-to: type=registry,ref=cogstacksystems/medcat-service-gpu:buildcache,mode=max
119136
build-args: |
120137
REINSTALL_CORE_FROM_LOCAL=true
121-
138+
122139
- name: Image digest
123140
run: echo ${{ steps.docker_build.outputs.digest }}
124141
working-directory: "./"
125-
integration_test:
126-
runs-on: ubuntu-latest
127-
needs: build
128-
strategy:
129-
matrix:
130-
variant: [v1, v2, DeID]
131-
steps:
132-
133-
- name: Check out code
134-
uses: actions/checkout@v6
135-
136-
- name: Run Test with example model pack
137-
run: |
138-
echo "🧪 Running Examples test..."
139-
export IMAGE_TAG=${{ needs.build.outputs.image_version }} # Improve by running exact digest instead
140-
echo "Running with image tag ${IMAGE_TAG} and variant ${{ matrix.variant }}"
141-
bash scripts/test_examples.sh ${{ matrix.variant }}
142-
143-
- name: Report test result
144-
if: always()
145-
run: |
146-
if [ $? -eq 0 ]; then
147-
echo "✅ Integration test PASSED"
148-
else
149-
echo "❌ Integration test FAILED"
150-
exit 1
151-
fi

medcat-service/docker/run_example_simple.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fi
1717
# To run in a container run "export LOCALHOST_NAME=host.docker.internal"
1818
LOCALHOST_NAME=${LOCALHOST_NAME:-localhost}
1919

20-
echo "Running docker-compose"
20+
echo "Running docker-compose with ${DOCKER_COMPOSE_FILE}"
2121
docker compose -f ${DOCKER_COMPOSE_FILE} up -d
2222

2323
echo "Running test"

medcat-service/scripts/test_examples.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,26 @@ if [ -n "$IMAGE_TAG" ]; then
77
fi
88

99
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
10+
VARIANT=$1
1011

12+
if [ "$VARIANT" = "v1" ]; then
13+
COMPOSE_FILE="docker-compose.example.v1.yml"
14+
elif [ "$VARIANT" = "DeID" ]; then
15+
COMPOSE_FILE="docker-compose.example.deid.yml"
16+
else
17+
COMPOSE_FILE="docker-compose.example.yml"
18+
fi
1119

12-
cd ${SCRIPT_DIR}/../docker
13-
bash run_example_simple.sh $1
20+
cd "${SCRIPT_DIR}/../docker"
21+
bash run_example_simple.sh "${VARIANT}"
1422

15-
# Check if health check was successful
1623
if [ $? -eq 0 ]; then
1724
echo "✅ Success! Medcat service passed integration tests"
18-
docker compose -f docker-compose.example.yml down
25+
docker compose -f "${COMPOSE_FILE}" down
1926
exit 0
2027
else
2128
echo "❌ Failure. Medcat service failed tests"
29+
docker compose -f "${COMPOSE_FILE}" down
2230
exit 1
2331
fi
2432

0 commit comments

Comments
 (0)