Skip to content

Commit

Permalink
Merge pull request #388 from ublefo/chore/more-ci-improvements
Browse files Browse the repository at this point in the history
chore: refactor workflow manifest and split steps
  • Loading branch information
macite authored Aug 2, 2022
2 parents 7638518 + 3b24771 commit 78cffc5
Showing 1 changed file with 67 additions and 12 deletions.
79 changes: 67 additions & 12 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,89 @@
name: Run Unit Tests
on: [push,pull_request]
on: [push, pull_request]

env:
RAILS_ENV: "test"
DF_STUDENT_WORK_DIR: "/student-work"
DF_INSTITUTION_HOST: "http://localhost:3000"
DF_INSTITUTION_PRODUCT_NAME: "OnTrack"
DF_SECRET_KEY_BASE: "test-secret-key-test-secret-key!"
DF_SECRET_KEY_ATTR: "test-secret-key-test-secret-key!"
DF_SECRET_KEY_DEVISE: "test-secret-key-test-secret-key!"
DF_TEST_DB_ADAPTER: "mysql2"
DF_TEST_DB_HOST: "mariadb"
DF_TEST_DB_DATABASE: "doubtfire-test"
DF_TEST_DB_USERNAME: "dfire"
DF_TEST_DB_PASSWORD: "pwd"
OVERSEER_ENABLED: "0"
DF_ENCRYPTION_PRIMARY_KEY: "AMLOMYA5GV8B4fTK3VKMhVGn8WdvUW8g"
DF_ENCRYPTION_DETERMINISTIC_KEY: "anlmuJ6cB3bN3biXRbYvmPsC5ALPFqGG"
DF_ENCRYPTION_KEY_DERIVATION_SALT: "hzPR8D4qpOnAg7VeAhkhWw6JmmzKJB10"

jobs:
unit-test-runner:
runs-on: ubuntu-latest
services:
mariadb:
image: mariadb
env:
MARIADB_USER: dfire
MARIADB_PASSWORD: pwd
MARIADB_DATABASE: doubtfire-test
MARIADB_USER: ${{ env.DF_TEST_DB_USERNAME }}
MARIADB_PASSWORD: ${{ env.DF_TEST_DB_PASSWORD }}
MARIADB_DATABASE: ${{ env.DF_TEST_DB_DATABASE }}
MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: yes # This is required or the healthcheck script can't connect to the db
options: --health-cmd "/usr/local/bin/healthcheck.sh --connect --innodb_initialized" --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Build base doubtfire-api development image
uses: docker/build-push-action@v3
with:
context: .
push: false
load: true
tags: doubtfire-api-development:local
- name: Populate database and run rake tests
- name: Populate database
uses: addnab/docker-run-action@v3
with:
image: doubtfire-api-development:local
options: -v ${{ github.workspace }}:/doubtfire -e RAILS_ENV=test -e DF_STUDENT_WORK_DIR=/student-work -e DF_INSTITUTION_HOST=http://localhost:3000 -e DF_INSTITUTION_PRODUCT_NAME=OnTrack -e DF_SECRET_KEY_BASE='test-secret-key-test-secret-key!' -e DF_SECRET_KEY_ATTR='test-secret-key-test-secret-key!' -e DF_SECRET_KEY_DEVISE='test-secret-key-test-secret-key!' -e DF_TEST_DB_ADAPTER=mysql2 -e DF_TEST_DB_HOST=mariadb -e DF_TEST_DB_DATABASE=doubtfire-test -e DF_TEST_DB_USERNAME=dfire -e DF_TEST_DB_PASSWORD=pwd -e OVERSEER_ENABLED=0 -e DF_ENCRYPTION_PRIMARY_KEY=AMLOMYA5GV8B4fTK3VKMhVGn8WdvUW8g -e DF_ENCRYPTION_DETERMINISTIC_KEY=anlmuJ6cB3bN3biXRbYvmPsC5ALPFqGG -e DF_ENCRYPTION_KEY_DERIVATION_SALT=hzPR8D4qpOnAg7VeAhkhWw6JmmzKJB10
run: |
echo "Populating database"
bundle exec rake db:populate
echo "Running rake tests"
TERM=xterm bundle exec rails test
options: >
-v ${{ github.workspace }}:/doubtfire
-e RAILS_ENV
-e DF_STUDENT_WORK_DIR
-e DF_INSTITUTION_HOST
-e DF_INSTITUTION_PRODUCT_NAME
-e DF_SECRET_KEY_BASE
-e DF_SECRET_KEY_ATTR
-e DF_SECRET_KEY_DEVISE
-e DF_TEST_DB_ADAPTER
-e DF_TEST_DB_HOST
-e DF_TEST_DB_DATABASE
-e DF_TEST_DB_USERNAME
-e DF_TEST_DB_PASSWORD
-e OVERSEER_ENABLED
-e DF_ENCRYPTION_PRIMARY_KEY
-e DF_ENCRYPTION_DETERMINISTIC_KEY
-e DF_ENCRYPTION_KEY_DERIVATION_SALT
run: bundle exec rake db:populate
- name: Run rake tests
uses: addnab/docker-run-action@v3
with:
image: doubtfire-api-development:local
options: >
-v ${{ github.workspace }}:/doubtfire
-e RAILS_ENV
-e DF_STUDENT_WORK_DIR
-e DF_INSTITUTION_HOST
-e DF_INSTITUTION_PRODUCT_NAME
-e DF_SECRET_KEY_BASE
-e DF_SECRET_KEY_ATTR
-e DF_SECRET_KEY_DEVISE
-e DF_TEST_DB_ADAPTER
-e DF_TEST_DB_HOST
-e DF_TEST_DB_DATABASE
-e DF_TEST_DB_USERNAME
-e DF_TEST_DB_PASSWORD
-e OVERSEER_ENABLED
-e DF_ENCRYPTION_PRIMARY_KEY
-e DF_ENCRYPTION_DETERMINISTIC_KEY
-e DF_ENCRYPTION_KEY_DERIVATION_SALT
run: TERM=xterm bundle exec rails test

0 comments on commit 78cffc5

Please sign in to comment.