GitHub Actions Configuration
The default OpenMRS-recommended GitHub Actions definition for OpenMRS backend modules should look like the below. This is designed to replicate the build process used on Travis-CI, first downloading all requirements and compiling the module before running any tests. Tests are then run afterwards. Tweaks might need to be made to accomodate specific modules build processes, but this should work for Maven-based builds.
GitHub Actions Maven Build
# this build is designed to replicate the Travis CI workflow
name: Build with Maven
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:
jobs:
build:
strategy:
matrix:
platform: [ ubuntu-latest ]
java-version: [ 8 ]
runs-on: ${{ matrix.platform }}
env:
PLATFORM: ${{ matrix.platform }}
JAVA_VERSION: ${{ matrix.java-version }}
steps:
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java-version }}
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Install dependencies
run: mvn clean install -DskipTests=true -Dmaven.javadoc.skip=true --batch-mode --show-version --file pom.xml
- name: Build with Maven
run: mvn test --batch-mode --file pom.xml
For OpenMRS ESM modules, we use the following.
GitHub Actions MF Build
name: Node.js CI
on:
push:
branches: [master]
pull_request:
branches: [master]
release:
types:
- created
env:
ESM_NAME: "@openmrs/esm-template-app"
JS_NAME: "openmrs-esm-template-app.js"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: "14.x"
- run: npm install
- run: npm run lint
- run: npm run coverage
- run: npm run typescript
- run: npm run build --if-present
- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: dist
path: |
dist
pre_release:
runs-on: ubuntu-latest
needs: build
if: ${{ github.event_name == 'push' }}
steps:
- uses: actions/checkout@v2
- name: Download Artifacts
uses: actions/download-artifact@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: "14.x"
registry-url: "https://registry.npmjs.org"
- run: npm install
- run: sed -i -e "s/\(\"version\":\\s\+\"\([0-9]\+\.\?\)\+\)/\1-pre.${{ github.run_number }}/" 'package.json'
- run: npm publish --access public --tag next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
release:
runs-on: ubuntu-latest
needs: build
if: ${{ github.event_name == 'release' }}
steps:
- uses: actions/checkout@v2
- name: Download Artifacts
uses: actions/download-artifact@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: "14.x"
registry-url: 'https://registry.npmjs.org'
- run: npm install
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
For OpenMRS OWAs, we use the following to build on each PR:
GitHub Actions OWA Build PR
# this build is designed to replicate the Travis CI workflow
name: Test Pull Request
on:
pull_request:
branches: [ 'master' ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 14.x ]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm test
And this to build on each request, which also deploys the SNAPSHOT OWA to our Maven server:
GitHub Actions OWA Build HEAD
Finally, we use this configuration for a release:
GitHub Actions OWA Release
Note that the OWA release deployments will need likely need to be tweaked for every OWA.