diff --git a/.github/workflows/unit-tests-and-codecov.yml b/.github/workflows/unit-tests-and-codecov.yml deleted file mode 100644 index 579b23fcc..000000000 --- a/.github/workflows/unit-tests-and-codecov.yml +++ /dev/null @@ -1,33 +0,0 @@ -on: [push] - -jobs: - rubocop: - runs-on: ubuntu-latest - name: Unit tests & Codecov report - steps: - - uses: actions/checkout@v2 - with: - submodules: recursive - - run: docker-compose pull - working-directory: docker/development - - uses: satackey/action-docker-layer-caching@v0.0.11 - continue-on-error: true - - run: docker-compose build - working-directory: docker/development - - name: create db - working-directory: docker/development - run: | - docker-compose run --entrypoint="" mampf sh -c "RAILS_ENV=test rails db:create" - docker-compose run --entrypoint="" mampf sh -c "RAILS_ENV=test rails db:migrate" - docker-compose run --entrypoint="" mampf sh -c "RAILS_ENV=test rails db:test:prepare" - - name: Reindex sunspot - working-directory: docker/development - run: | - docker-compose run --entrypoint="" mampf sh -c "RAILS_ENV=test rake sunspot:reindex" - - name: Run tests - working-directory: docker/development - run: docker-compose run --entrypoint="" mampf sh -c "RAILS_ENV=test rails spec" - - name: Send test coverage report to codecov.io - uses: codecov/codecov-action@v2 - with: - directory: ./coverage diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 000000000..6b9029d5e --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -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