Skip to content

fix: 500 errors due to Openmrs Context request from background proces… #34

fix: 500 errors due to Openmrs Context request from background proces…

fix: 500 errors due to Openmrs Context request from background proces… #34

Workflow file for this run

name: Compile & Avail OMOD Artifact (GitHub Hosted)
on:
push:
branches: [ "palladium_upgrade" ]
pull_request:
branches: [ "palladium_upgrade" ]
workflow_dispatch:
jobs:
build_and_upload_omod:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'corretto'
cache: 'maven'
- name: Checkout mamba-core
uses: actions/checkout@v4
with:
repository: CDC-HIS/openmrs-module-mamba-core
ref: palladium_upgrade
path: mamba-core
# token: ${{ secrets.MAMBA_CORE_PAT }} # uncomment if repo is private
- name: Get mamba-core commit SHA
id: mamba_sha
working-directory: mamba-core
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Cache mamba-core installed artifacts
id: cache_mamba
uses: actions/cache@v4
with:
path: ~/.m2/repository/org/openmrs/module/mamba-core-api
key: mamba-core-${{ steps.mamba_sha.outputs.sha }}
- name: Build and install mamba-core
if: steps.cache_mamba.outputs.cache-hit != 'true'
run: mvn install -DskipTests -f mamba-core/pom.xml
# Pass 1: Run the ETL compiler so it generates the *.sql files and copies them
# into api/src/main/resources/mamba/ (via the copy-final-build-script install-phase step).
# On a fresh checkout that directory is empty (gitignored), so the api jar built in
# this pass does NOT contain the SQL files — but the files are now on disk for pass 2.
- name: Pass 1 — generate SQL files
run: mvn install -DskipTests
# Pass 2: Clean and rebuild. The api module now finds the generated SQL files in
# api/src/main/resources/mamba/ and includes them in the api jar, so the final
# OMOD artifact contains the stored-procedure scripts.
- name: Pass 2 — build OMOD with generated SQL
run: mvn clean install -DskipTests
- name: Find .omod file
id: find_omod
run: |
OMOD_PATH=$(find "${{ github.workspace }}/omod/target" -name "*.omod" | head -n 1)
if [ -z "$OMOD_PATH" ]; then
echo "Error: No .omod file found in omod/target after build."
exit 1
fi
echo "Found .omod at: $OMOD_PATH"
echo "omod_file_path=$OMOD_PATH" >> "$GITHUB_OUTPUT"
- name: Verify SQL scripts are inside the OMOD
run: |
set -euo pipefail
OMOD_FILE="${{ steps.find_omod.outputs.omod_file_path }}"
VERIFY_DIR=$(mktemp -d)
trap 'rm -rf "$VERIFY_DIR"' EXIT
unzip -q "$OMOD_FILE" -d "$VERIFY_DIR"
# Derive module name from OMOD filename (e.g. ethiohri-mamba-2.1.0.omod -> ethiohri-mamba)
MODULE_NAME=$(basename "$OMOD_FILE" | sed 's/-[0-9].*//')
API_JAR=$(find "$VERIFY_DIR/lib" -name "${MODULE_NAME}-api-*.jar" | head -1)
if [ -z "$API_JAR" ]; then
echo "Error: ${MODULE_NAME}-api jar not found inside OMOD lib/. Contents:"
ls "$VERIFY_DIR/lib"
exit 1
fi
echo "Checking api jar: $API_JAR"
if jar tf "$API_JAR" | grep -q "mamba/jdbc_create_stored_procedures.sql"; then
echo "OK: jdbc_create_stored_procedures.sql is present in the api jar inside the OMOD."
else
echo "Error: jdbc_create_stored_procedures.sql is missing from the api jar inside the OMOD."
jar tf "$API_JAR" | grep mamba || echo "(no mamba entries found)"
exit 1
fi
- name: Upload OMOD as artifact
uses: actions/upload-artifact@v4
with:
name: openmrs-module-${{ github.run_id }}
path: ${{ steps.find_omod.outputs.omod_file_path }}
retention-days: 7