Skip to content

Commit

Permalink
Improve unit test workflow file
Browse files Browse the repository at this point in the history
- 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
Splines committed Mar 31, 2023
1 parent 89d0f35 commit 6167afc
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 33 deletions.
33 changes: 0 additions & 33 deletions .github/workflows/unit-tests-and-codecov.yml

This file was deleted.

48 changes: 48 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Unit tests
on: push
jobs:
unit-test-job:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: recursive

- name: Pull docker image
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/action-docker-layer-caching@v0.1.1
continue-on-error: true

- name: Build docker image
run: docker compose build
working-directory: docker/development

- name: Create database
working-directory: docker/development
run: |
docker compose exec mampf RAILS_ENV=test rails db:create
docker compose exec mampf RAILS_ENV=test rails db:migrate
docker compose exec mampf RAILS_ENV=test rails db:test:prepare
- name: Reindex sunspot
working-directory: docker/development
run: |
docker compose run mampf RAILS_ENV=test rake sunspot:reindex
- name: Run unit tests
working-directory: docker/development
run: docker compose exec mampf 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

0 comments on commit 6167afc

Please sign in to comment.