Skip to content

LIME2-270: create automated e2e tests on push or PR to Mosul #73

LIME2-270: create automated e2e tests on push or PR to Mosul

LIME2-270: create automated e2e tests on push or PR to Mosul #73

Workflow file for this run

name: Build all configurations and deploy
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main
env:
MAVEN_GITHUB_ACTIONS_DEPLOY_TOKEN: ${{ secrets.MAVEN_GITHUB_ACTIONS_DEPLOY_TOKEN }}
jobs:
build-and-publish:
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '8' ]
outputs:
msf_mosul_artifact_version: ${{steps.get_version.outputs.mosul_artifact_version}}
msf_mosul_artifact_id: ${{steps.get_artifactId.outputs.mosul_artifact_id}}
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}
cache: 'maven'
- name: Set settings.xml
uses: s4u/maven-settings-action@v3.0.0
if: ${{ github.event_name == 'push' }}
with:
servers: |
[{
"id": "msf-ocg-github-lime-emr",
"username": "${{ secrets.MAVEN_GITHUB_ACTIONS_DEPLOY_USERNAME }}",
"password": "${{ secrets.MAVEN_GITHUB_ACTIONS_DEPLOY_TOKEN }}"
}]
- name: Build and Test
run: mvn --batch-mode --update-snapshots --activate-profiles validator clean package
- name: Get MSF Mosul version
working-directory: "${{ github.workspace }}/sites/mosul"
id: get_version
run: |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "mosul_artifact_version=$VERSION" >> $GITHUB_OUTPUT
- name: Get MSF Mosul artifactId
working-directory: "${{ github.workspace }}/sites/mosul"
id: get_artifactId
run: |
ARTIFACT_ID=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)
echo "mosul_artifact_id=$ARTIFACT_ID" >> $GITHUB_OUTPUT
- name: Publish MSF Mosul artifacts to GitHub
uses: ./.github/actions/upload-maven-artifacts
if: ${{ github.event_name == 'push' }}
with:
artifact-name: "Mosul"
artifact-path: "${{ github.workspace }}/sites/mosul"
maven-server-username: "${{ secrets.MAVEN_GITHUB_ACTIONS_DEPLOY_USERNAME }}"
maven-server-token: "${{ secrets.MAVEN_GITHUB_ACTIONS_DEPLOY_TOKEN }}"
- name: cache Mosul artifact for future use
if: ${{ github.event_name != 'push' }}
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/sites/mosul/target/${{ steps.get_artifactId.outputs.mosul_artifact_id }}-${{ steps.get_version.outputs.mosul_artifact_version }}.zip
key: ${{ github.sha }}
run-e2e-on-push:
uses: ./.github/workflows/run-e2e-tests.yml
with:
frontend-container-name: "ozone-frontend-1"
backend-container-name: "ozone-openmrs-1"
gateway-container-name: "ozone-proxy-1"
database-container-name: "ozone-mysql-1"
frontend-config-file-path: "./emr/mosul/${{ needs.build-and-publish.outputs.msf_mosul_artifact_id }}-${{ needs.build-and-publish.outputs.msf_mosul_artifact_version }}/binaries/openmrs/frontend/spa-assemble-config.json"
start-server-command: "curl -sSL -H 'Cache-Control: no-cache, no-store' -H 'Authorization: token $MAVEN_GITHUB_ACTIONS_DEPLOY_TOKEN' https://raw.githubusercontent.com/MSF-OCG/LIME-EMR-Tooling/dev/Procedures/local_lime_emr.sh | bash -s -- install mosul"
needs: build-and-publish
if: ${{ github.event_name == 'push' }}
run-e2e-on-pull-request:
uses: ./.github/workflows/run-e2e-tests.yml
with:
frontend-container-name: "ozone-frontend-1"
backend-container-name: "ozone-openmrs-1"
gateway-container-name: "ozone-proxy-1"
database-container-name: "ozone-mysql-1"
frontend-config-file-path: "./sites/mosul/target/${{ needs.build-and-publish.outputs.msf_mosul_artifact_id }}-${{ needs.build-and-publish.outputs.msf_mosul_artifact_version }}/binaries/openmrs/frontend/spa-assemble-config.json"
start-server-command: "cd ./sites/mosul/target/${{ needs.build-and-publish.outputs.msf_mosul_artifact_id }}-${{ needs.build-and-publish.outputs.msf_mosul_artifact_version }}/run/docker/scripts"
test-artifact-cache-path: ${{ needs.build-and-publish.outputs.msf_mosul_artifact_id }}-${{ needs.build-and-publish.outputs.msf_mosul_artifact_version }}
is-artifact-cached: true
needs: build-and-publish
if: ${{ github.event_name != 'push' }}