Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: "Build"
on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- develop
push:
branches:
- develop

jobs:
tests:
name: NHAIS Adaptor Tests
uses: ./.github/workflows/test.yml
with:
path: .
secrets: inherit
#
# translator-tests:
# name: "GP2GP Translator Tests"
# uses: ./.github/workflows/test.yml
# with:
# name: GP2GP Translator
# path: ./gp2gp-translator
# secrets: inherit
#
# generate-build-id:
# name: "Generate Build Id"
# needs: [ common-modules-tests, facade-tests, translator-tests ]
# runs-on: ubuntu-latest
# outputs:
# build-id: ${{ steps.generate.outputs.buildId }}
# steps:
# - name: Checkout Repository
# uses: actions/checkout@v4
#
# - id: generate
# working-directory: ./scripts
# shell: bash
# env:
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: |
# chmod +x ./create_build_id.sh
#
# if [[ "${{ github.event_name }}" == "pull_request" ]]; then
# GIT_BRANCH=PR
# elif [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]]; then
# GIT_BRANCH=main
# fi
#
# BUILD_ID=$(./create_build_id.sh $GIT_BRANCH ${{ github.run_number }} ${{ github.sha }})
# echo "Generated the build tag: $BUILD_ID"
# echo "buildId=$BUILD_ID" >> "$GITHUB_OUTPUT"
#
# publish-docker-images:
# name: "Publish docker images to ECR"
# needs: [ generate-build-id ]
# strategy:
# matrix:
# config:
# - directory: gpc-facade
# repository: pss_gpc_facade
# build-context: .
# - directory: gp2gp-translator
# repository: pss_gp2gp-translator
# build-context: .
# - directory: snomed-schema
# repository: pss_snomed_schema
# build-context: .
# - directory: db-migration
# repository: pss_db_migration
# build-context: .
# - directory: mhs-adaptor-mock
# repository: pss-mock-mhs
# build-context: ./docker/mhs-adaptor-mock
# uses: ./.github/workflows/publish.yml
# with:
# directory: ${{ matrix.config.directory }}
# repository: ${{ matrix.config.repository }}
# build-context: ${{ matrix.config.build-context }}
# build-id: ${{ needs.generate-build-id.outputs.build-id }}
# secrets: inherit
#
# comment:
# if: github.event_name == 'pull_request'
# name: "Create Build ID Comment"
# needs: [ generate-build-id, publish-docker-images]
# continue-on-error: true
# permissions: write-all
# runs-on: [ ubuntu-latest ]
# steps:
# - name: Check out code
# uses: actions/checkout@v4
# - name: Comment PR
# uses: thollander/actions-comment-pull-request@v3
# with:
# message: |
# Images built and published to ECR using a Build Id of ${{ needs.generate-build-id.outputs.build-id }}
# comment_tag: images-built
# mode: upsert
#
162 changes: 162 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
name: Test Workflow
on:
workflow_call:
inputs:
path:
required: true
type: string

jobs:
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup Java 11
uses: actions/setup-java@v4
with:
java-version: 11
distribution: temurin

- name: Execute Unit Tests
run: ./gradlew test --parallel --build-cache
working-directory: ${{ inputs.path }}

- name: Collect Artifacts
if: always()
run: |
mkdir -p artifacts
cp -r ./${{ inputs.path }}/build/reports ./artifacts

- name: Upload Artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: Unit Test Report
path: ./artifacts/**
compression-level: 9

- name: Test Job Summary
if: always()
uses: test-summary/action@v2
with:
paths: "${{ inputs.path }}/build/test-results/test/TEST-*.xml"

- name: Temporary Artifacts Cleanup
run: rm -rf ./artifacts

component-tests:
name: Component Tests
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup Java 11
uses: actions/setup-java@v4
with:
java-version: 11
distribution: temurin

- name: Execute Component Tests
run: ./gradlew componentTest --build-cache
working-directory: ${{ inputs.path }}

- name: Collect Artifacts
if: always()
run: |
mkdir -p artifacts
cp -r ./${{ inputs.path }}/build/reports ./artifacts

- name: Upload Artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: Component Test Report
path: ./artifacts/**
compression-level: 9

- name: Test Job Summary
if: always()
uses: test-summary/action@v2
with:
paths: "${{ inputs.path }}/build/test-results/componentTest/TEST-*.xml"

- name: Temporary Artifacts Cleanup
run: rm -rf ./artifacts

integration_tests:
name: Integration Tests
permissions:
id-token: write
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'

# - name: Configure AWS Credentials
# uses: aws-actions/configure-aws-credentials@v4
# with:
# role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_ROLE_TO_ASSUME }}
# role-session-name: gp2gp_github_action_build_workflow
# aws-region: ${{ secrets.AWS_REGION }}

- name: Setup Required Docker Images
working-directory: ${{ inputs.path }}
run: docker compose up mongodb activemq fake-mesh -d

- name: Execute Integration Tests
working-directory: ${{ inputs.path }}
run: ./gradlew integrationTest

- name: Dump Docker Logs
if: always()
run: |
mkdir -p ./logs
container_names=$(docker ps -a --format '{{.Names}}')
for container in $container_names; do
docker logs "$container" > ./logs/"$container".log
echo "Logs saved for container: $container"
done
working-directory: ./scripts
shell: bash

- name: Collect Artifacts
if: always()
run: |
mkdir -p artifacts
cp -r ./${{ inputs.path }}/build/reports ./artifacts
cp -r ./scripts/logs ./artifacts

- name: Upload Artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: Integration Test Report & Docker Logs
path: ./artifacts/**
compression-level: 9

- name: Test Job Summary
if: always()
uses: test-summary/action@v2
with:
paths: "./${{ inputs.path }}/build/test-results/integrationTest/TEST-*.xml"

- name: Stop Docker Dependencies
if: always()
run: |
docker compose down --rmi=local --remove-orphans
docker compose rm
working-directory: ./docker

- name: Temporary Artifacts Cleanup
run: rm -rf ./artifacts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
public class MongoDbContainer extends GenericContainer<MongoDbContainer> {

public static final int MONGODB_PORT = 27017;
public static final String DEFAULT_IMAGE_AND_TAG = "mongo:3.2.4";
public static final String DEFAULT_IMAGE_AND_TAG = "mongo:8.0";
Copy link
Collaborator Author

@MartinWheelerMT MartinWheelerMT Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was updated due to TestContainers reporting the following issue due docker versioning on the GitHub runners:

[DEPRECATION NOTICE] Docker Image Format v1 and Docker Image manifest version 2, schema 1 support is disabled by default and will be removed in an upcoming release. Suggest the author of docker.io/library/mongo:3.2.4 to upgrade the image to the OCI Format or Docker Image manifest v2, schema 2`.

This change only affects the TestContainers startup stage for the integration tests.

private static MongoDbContainer container;

private MongoDbContainer() {
Expand Down
Loading