Skip to content

Commit bf8c7a6

Browse files
committed
Improve E2E workflow reliability and cross-platform compatibility
- Reorganize E2E test files from e2e_test_support_files/ to tests/e2e/ - Fix double slashes in workflow file paths - Standardize Docker image names to e2e/* format for consistency - Add cross-platform support for stat command (macOS and Linux) - Add artifact verification step to catch failures early - Update docker-compose.yml to use consistent image naming These changes ensure the E2E workflows fail fast with clear error messages and work correctly across different platforms.
1 parent 48e072b commit bf8c7a6

File tree

9 files changed

+116
-64
lines changed

9 files changed

+116
-64
lines changed

.github/workflows/e2e-on-release.yml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,33 @@ jobs:
2626

2727
- name: Extract version numbers from the spa-build-config.json file
2828
id: refs
29-
run: bash e2e_test_support_files/extract_tag_numbers.sh
29+
run: bash ./tests/e2e/extract_tag_numbers.sh
3030

3131
- name: Build and Run Containers
32-
run: docker compose -f e2e_test_support_files/docker-compose-build.yml up -d
32+
run: docker compose -f ./tests/e2e/docker-compose-build.yml up -d
3333

3434
- name: Wait for the backend to start
3535
run: while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost/openmrs/login.htm)" != "200" ]]; do sleep 10; done
3636

3737
- name: Commit and export Containers
38-
run: sh e2e_test_support_files/commit_and_export_images.sh
38+
run: sh ./tests/e2e/commit_and_export_images.sh
39+
40+
- name: Verify artifact was created
41+
run: |
42+
echo "Workspace: $GITHUB_WORKSPACE"
43+
ls -la .
44+
if [[ ! -f e2e_release_env_images.tar.gz ]]; then
45+
echo "ERROR: e2e_release_env_images.tar.gz not found"
46+
exit 1
47+
fi
3948
4049
- name: Upload artifact
4150
uses: actions/upload-artifact@v4
4251
with:
4352
name: e2e_release_env_images
4453
path: e2e_release_env_images.tar.gz
4554
retention-days: 1
55+
if-no-files-found: error
4656

4757
run-patient-management-e2e-tests:
4858
runs-on: ubuntu-latest
@@ -68,7 +78,7 @@ jobs:
6878
6979
- name: Spin up an OpenMRS Instance
7080
run: docker compose up -d
71-
working-directory: e2e_test_support_files
81+
working-directory: ./tests/e2e/
7282

7383
- name: Checkout to the Repo's Tag
7484
uses: actions/checkout@v4
@@ -129,7 +139,7 @@ jobs:
129139
130140
- name: Spin up an OpenMRS Instance
131141
run: docker compose up -d
132-
working-directory: e2e_test_support_files
142+
working-directory: ./tests/e2e/
133143

134144
- name: Checkout to the Repo's Tag
135145
uses: actions/checkout@v4
@@ -190,7 +200,7 @@ jobs:
190200
191201
- name: Spin up an OpenMRS Instance
192202
run: docker compose up -d
193-
working-directory: e2e_test_support_files
203+
working-directory: ./tests/e2e/
194204

195205
- name: Checkout to the Repo's Tag
196206
uses: actions/checkout@v4
@@ -251,7 +261,7 @@ jobs:
251261
252262
- name: Spin up an OpenMRS Instance
253263
run: docker compose up -d
254-
working-directory: e2e_test_support_files
264+
working-directory: ./tests/e2e/
255265

256266
- name: Checkout to the Repo's Tag
257267
uses: actions/checkout@v4
@@ -312,7 +322,7 @@ jobs:
312322
313323
- name: Spin up an OpenMRS Instance
314324
run: docker compose up -d
315-
working-directory: e2e_test_support_files
325+
working-directory: ./tests/e2e/
316326

317327
- name: Checkout to the Repo's Tag
318328
uses: actions/checkout@v4
@@ -348,7 +358,7 @@ jobs:
348358
name: report-cohort-builder
349359
path: e2e_repo/playwright-report/
350360
retention-days: 30
351-
361+
352362
run-dispensing-app-e2e-tests:
353363
runs-on: ubuntu-latest
354364
needs: build
@@ -373,7 +383,7 @@ jobs:
373383
374384
- name: Spin up an OpenMRS Instance
375385
run: docker compose up -d
376-
working-directory: e2e_test_support_files
386+
working-directory: ./tests/e2e/
377387

378388
- name: Checkout to the Repo's Tag
379389
uses: actions/checkout@v4

.github/workflows/e2e-tests-on-commit.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,50 @@ on:
66
pull_request:
77
branches: [main]
88

9-
jobs:
9+
jobs:
1010
build:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v4
1414

1515
- name: Build and Run Containers
16-
run: docker compose -f e2e_test_support_files/docker-compose-build.yml up -d
16+
run: docker compose -f ./tests/e2e/docker-compose-build.yml up -d
1717

1818
- name: Wait for the backend to start
1919
run: while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost/openmrs/login.htm)" != "200" ]]; do sleep 10; done
2020

2121
- name: Commit and export Containers
22-
run: sh e2e_test_support_files/commit_and_export_images.sh
22+
run: sh ./tests/e2e/commit_and_export_images.sh
23+
24+
- name: Verify artifact was created
25+
run: |
26+
echo "Workspace: $GITHUB_WORKSPACE"
27+
ls -la .
28+
if [[ ! -f e2e_release_env_images.tar.gz ]]; then
29+
echo "ERROR: e2e_release_env_images.tar.gz not found"
30+
exit 1
31+
fi
2332
2433
- name: Upload artifact
2534
uses: actions/upload-artifact@v4
2635
with:
2736
name: e2e_release_env_images
2837
path: e2e_release_env_images.tar.gz
2938
retention-days: 1
39+
if-no-files-found: error
3040

3141
run-e2e-tests:
3242
runs-on: ubuntu-latest
3343
needs: build
3444
strategy:
3545
matrix:
36-
repo:
46+
repo:
3747
- openmrs-esm-patient-management
3848
- openmrs-esm-patient-chart
3949
- openmrs-esm-form-builder
4050
- openmrs-esm-core
4151
- openmrs-esm-dispensing-app
42-
52+
4353
steps:
4454
- uses: actions/checkout@v4
4555

@@ -61,7 +71,7 @@ jobs:
6171
6272
- name: Spin up an OpenMRS Instance
6373
run: docker compose up -d
64-
working-directory: e2e_test_support_files
74+
working-directory: ./tests/e2e/
6575

6676
- name: Checkout to the repo's main branch
6777
uses: actions/checkout@v4

e2e_test_support_files/commit_and_export_images.sh

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

e2e_test_support_files/extract_tag_numbers.sh

Lines changed: 0 additions & 28 deletions
This file was deleted.
File renamed without changes.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
5+
6+
COMPOSE_FILE="${SCRIPT_DIR}/docker-compose-build.yml"
7+
8+
get_container_id() {
9+
local svc="$1"
10+
id="$(docker compose -f "$COMPOSE_FILE" ps -q "$svc" || true)"
11+
if [[ -z "$id" ]]; then
12+
echo "ERROR: no running container found for service '$svc' (docker compose -f $COMPOSE_FILE ps -q $svc returned empty)" >&2
13+
exit 1
14+
fi
15+
echo "$id"
16+
}
17+
18+
frontend_container_id="$(get_container_id frontend)"
19+
gateway_container_id="$(get_container_id gateway)"
20+
backend_container_id="$(get_container_id backend)"
21+
db_container_id="$(get_container_id db)"
22+
23+
# Commit containers to explicitly named images
24+
docker commit "${frontend_container_id}" e2e/frontend:latest
25+
docker commit "${gateway_container_id}" e2e/gateway:latest
26+
docker commit "${backend_container_id}" e2e/backend:latest
27+
docker commit "${db_container_id}" e2e/db:latest
28+
29+
tarfile="e2e_release_env_images.tar"
30+
gzipfile="${tarfile}.gz"
31+
32+
# Save the images we just created
33+
docker save e2e/frontend:latest e2e/gateway:latest e2e/backend:latest e2e/db:latest -o "$tarfile"
34+
35+
# compress and verify
36+
gzip -c "$tarfile" > "$gzipfile"
37+
38+
# Cross-platform file size reporting
39+
if [[ "$(uname)" == "Darwin" ]]; then
40+
# macOS
41+
echo "Created: $tarfile ($(stat -f '%z' "$tarfile") bytes)"
42+
echo "Created: $gzipfile ($(stat -f '%z' "$gzipfile") bytes)"
43+
else
44+
# Linux
45+
echo "Created: $tarfile ($(stat -c '%s' "$tarfile") bytes)"
46+
echo "Created: $gzipfile ($(stat -c '%s' "$gzipfile") bytes)"
47+
fi
48+
ls -lh "$tarfile" "$gzipfile"
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
gateway:
3-
image: gateway
3+
image: e2e/gateway:latest
44
restart: "unless-stopped"
55
depends_on:
66
- frontend
@@ -9,16 +9,16 @@ services:
99
- "8080:80"
1010

1111
frontend:
12-
image: frontend
12+
image: e2e/frontend:latest
1313
restart: "unless-stopped"
1414
depends_on:
1515
- backend
1616

1717
backend:
18-
image: backend
18+
image: e2e/backend:latest
1919
restart: "unless-stopped"
2020

2121
db:
22-
image: db
22+
image: e2e/db:latest
2323
restart: "unless-stopped"
2424

tests/e2e/extract_tag_numbers.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
# Define a function to extract and output a dependency value
4+
get_repository_tag() {
5+
local file="$1"
6+
local repo_name="$2"
7+
local app="$3"
8+
9+
local version=$(awk -F'"' -v app="${app}" '$0 ~ app {print $4}' "${file}")
10+
local ref="refs/tags/v$version"
11+
12+
# Check if the version number contains "pre" and modify the ref to main branch
13+
if [[ $version == *"pre"* ]]; then
14+
ref="main"
15+
fi
16+
17+
echo "$repo_name=$ref"
18+
}
19+
20+
file_path="frontend/spa-assemble-config.json"
21+
22+
# Call the function for each Repository with the app as the second argument
23+
get_repository_tag "${file_path}" "patient_chart" "@openmrs/esm-patient-chart-app" >> "$GITHUB_OUTPUT"
24+
get_repository_tag "${file_path}" "esm_core" "@openmrs/esm-login-app" >> "$GITHUB_OUTPUT"
25+
get_repository_tag "${file_path}" "form_builder" "@openmrs/esm-form-builder-app" >> "$GITHUB_OUTPUT"
26+
get_repository_tag "${file_path}" "patient_management" "@openmrs/esm-patient-registration-app" >> "$GITHUB_OUTPUT"
27+
get_repository_tag "${file_path}" "cohort_builder" "@openmrs/esm-cohort-builder-app" >> "$GITHUB_OUTPUT"
28+
get_repository_tag "${file_path}" "dispensing" "@openmrs/esm-dispensing-app" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)