Add unit tests back to pipeline & improve VSCode integration #463
Workflow file for this run
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
name: Testing | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
- experimental | |
pull_request: | |
types: [opened, reopened, synchronize, ready_for_review] | |
jobs: | |
unit-tests: | |
name: Unit tests | |
runs-on: ubuntu-latest | |
permissions: write-all | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Setup Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build docker images | |
working-directory: docker/test | |
run: | | |
docker buildx bake --file ./docker-compose.yml --file ./../../.github/workflows/docker-compose-cache.json | |
- name: Create and migrate DB | |
working-directory: docker/test | |
run: docker compose run --entrypoint "" mampf sh -c "rake db:create db:migrate db:test:prepare" | |
- name: Reindex sunspot | |
working-directory: docker/test | |
run: | | |
docker compose run --entrypoint="" mampf sh -c "RAILS_ENV=test rake sunspot:reindex" | |
- name: Run unit tests | |
working-directory: docker/test | |
run: docker compose run --entrypoint="" mampf sh -c "RAILS_ENV=test bundle exec rspec --format RSpec::Github::Formatter" | |
- name: Report test coverage to codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
files: ./coverage/coverage.xml | |
fail_ci_if_error: true | |
verbose: true | |
# [1] https://depot.dev/blog/docker-layer-caching-in-github-actions#docker-layer-caching-in-github-actions | |
# https://stackoverflow.com/questions/61491484/how-to-cache-docker-compose-build-inside-github-action | |
# https://docs.docker.com/build/ci/github-actions/cache/ | |
# https://github.com/docker/build-push-action/issues/493#issuecomment-961559685 | |
# https://github.com/orgs/community/discussions/25728 | |
# https://www.deploysentinel.com/blog/docker-buildx-cache-with-github-actions |