Skip to content

Commit

Permalink
chore: setup test database (#101)
Browse files Browse the repository at this point in the history
Signed-off-by: maxwellgithinji <[email protected]>
  • Loading branch information
maxwellgithinji authored Aug 24, 2023
1 parent 101215c commit 22bc6b5
Showing 1 changed file with 46 additions and 4 deletions.
50 changes: 46 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
packages: read
statuses: write
security-events: write

steps:
- uses: actions/checkout@v3
- name: Set up JDK 8
Expand Down Expand Up @@ -65,12 +65,54 @@ jobs:
VALIDATE_XML: true
DEFAULT_BRANCH: develop
JAVA_FILE_NAME: checkstyle.xml


- name: Download and Extract SQL Archive
run: |
curl -LJO "https://github.com/savannahghi/kenya-emr-releases/releases/download/v18.6.2/KenyaEMR.Release.Archive.xz"
tar -xf KenyaEMR.Release.Archive.xz
- name: Setup MySQL Server
uses: shogo82148/actions-setup-mysql@v1
with:
mysql-version: "5.6"

- name: Create Database and Restore Data
run: |
mysql -h localhost -uroot -e "CREATE DATABASE IF NOT EXISTS $MYSQL_DATABASE;"
mysql -h localhost -uroot $MYSQL_DATABASE < kenya-emr-release-content/databases/openmrs.sql
env:
MYSQL_DATABASE: openmrs

- name: Download Liquibase 2.0.5
run: |
mkdir -p liquibase
curl -LJO https://github.com/liquibase/liquibase/releases/download/liquibase-parent-2.0.5/liquibase-2.0.5-bin.tar.gz
tar -xzf liquibase-2.0.5-bin.tar.gz -C liquibase
- name: Run Liquibase Migrations
run: |
java -jar liquibase/liquibase.jar \
--classpath=liquibase/liquibase.jar \
--driver=com.mysql.jdbc.Driver \
--url=jdbc:mysql://localhost:3306/$MYSQL_DATABASE \
--username=root \
update \
--changeLogFile=api/src/main/resources/liquibase.xml
env:
MYSQL_DATABASE: openmrs

- name: Cleanup Downloaded Files
run: |
rm -rf kenya-emr-release-content
rm KenyaEMR.Release.Archive.xz
rm -rf liquibase
rm liquibase-2.0.5-bin.tar.gz
- name: Install Dependencies
run: mvn clean install -Dartifact.version=1.0.0 -DskipTests=true -Dmaven.javadoc.skip=true --batch-mode --show-version --file pom.xml

- name: Test and Generate Coverage Report
run: mvn -B verify -P coverage --no-transfer-progress -Dartifact.version=1.0.0
run: mvn -B verify -P coverage --no-transfer-progress -Dartifact.version=1.0.0 -Ddb.name="openmrs" -Ddb.user="root"

- name: Post Coverage Report to CodeCov
uses: codecov/codecov-action@v3
Expand Down

0 comments on commit 22bc6b5

Please sign in to comment.