-
Notifications
You must be signed in to change notification settings - Fork 10
71 lines (60 loc) · 2.29 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: Testing
on:
push:
branches:
- main
- dev
- experimental
pull_request:
types: [opened, reopened, synchronize, ready_for_review]
jobs:
unit-test-job:
name: Unit tests
runs-on: ubuntu-latest
steps:
- 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: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Build docker images
run: |
ls -la
docker buildx bake --file "./docker/test/docker-compose.yml" --file "./.github/workflows/docker-compose-cache.json"
# For docker layer caching also see this article [1]
# - name: Build docker images
# uses: docker/build-push-action@v5
# with:
# push: false # only build
# context: .
# cache-from: type=gha
# cache-to: type=gha,mode=max
- name: Create and migrate DB
run: docker compose run --entrypoint "" mampf sh -c "rake db:create db:migrate db:test:prepare"
working-directory: docker/test
- 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 rails spec"
- name: Send test coverage report 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