-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Update checkout action to version v3 - Use new docker layer caching version - Simplify commands to handle docker compose shell commands - Update codecov action
- Loading branch information
Showing
2 changed files
with
52 additions
and
33 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Unit tests | ||
on: push | ||
jobs: | ||
unit-test-job: | ||
name: Execute unit tests & upload to Codecov | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
|
||
# Pull the latest image to build, and avoid caching pull-only images. | ||
# (docker pull is faster than caching in most cases.) | ||
- name: Pull docker images | ||
run: docker-compose pull | ||
working-directory: docker/development | ||
|
||
# In this step, this action saves a list of existing images, | ||
# the cache is created without them in the post run. | ||
# It also restores the cache if it exists. | ||
# https://github.com/jpribyl/action-docker-layer-caching | ||
- uses: jpribyl/[email protected] | ||
continue-on-error: true | ||
|
||
- name: Build and start docker containers | ||
working-directory: docker/development | ||
run: | | ||
docker compose up --build --detach | ||
- name: Create and prepare test database | ||
working-directory: docker/development | ||
run: | | ||
docker compose exec mampf sh -c "RAILS_ENV=test rails db:create" | ||
docker compose exec mampf sh -c "RAILS_ENV=test rails db:migrate" | ||
docker compose exec mampf sh -c "RAILS_ENV=test rails db:test:prepare" | ||
- name: Reindex sunspot | ||
working-directory: docker/development | ||
run: | | ||
docker compose exec mampf sh -c "RAILS_ENV=test rake sunspot:reindex" | ||
- name: Run unit tests | ||
working-directory: docker/development | ||
run: docker compose exec mampf sh -c "RAILS_ENV=test rails spec" | ||
|
||
- name: Send test coverage report to Codecov | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
directory: ./coverage | ||
fail_ci_if_error: true | ||
verbose: true |