From a2c8dc3dd824ea6ffeccc1c4be31d5ef60d29f57 Mon Sep 17 00:00:00 2001 From: stevenjcumming <134282106+stevenjcumming@users.noreply.github.com> Date: Mon, 5 Aug 2024 13:48:59 -0400 Subject: [PATCH] move unit tests to separate workflow --- .github/workflows/unit_test_reporter.yml | 80 ++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 .github/workflows/unit_test_reporter.yml diff --git a/.github/workflows/unit_test_reporter.yml b/.github/workflows/unit_test_reporter.yml new file mode 100644 index 00000000000..21cb122d188 --- /dev/null +++ b/.github/workflows/unit_test_reporter.yml @@ -0,0 +1,80 @@ +name: Code Health Report +on: + pull_request: + branches: + - '*' + types: + - opened + - synchronize + - reopened +jobs: + unit_tests: + name: Test + env: + BUNDLE_ENTERPRISE__CONTRIBSYS__COM: ${{ secrets.BUNDLE_ENTERPRISE__CONTRIBSYS__COM }} + CI: true + RAILS_ENV: test + TERM: xterm-256color + DOCKER_BUILDKIT: 1 + COMPOSE_DOCKER_CLI_BUILD: 1 + runs-on: ubuntu-16-cores-latest + steps: + - uses: actions/checkout@v4 + + - uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USER }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4.0.2 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-gov-west-1 + + - name: Login to Amazon ECR + id: ecr-login + uses: aws-actions/amazon-ecr-login@v2.0.1 + with: + mask-password: true + + - name: Setup Environment + run: | + echo "VETS_API_USER_ID=$(id -u)" >> $GITHUB_ENV + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build Docker Image + uses: docker/build-push-action@v6 + env: + DOCKER_BUILD_SUMMARY: false + with: + build-args: | + BUNDLE_ENTERPRISE__CONTRIBSYS__COM=${{ env.BUNDLE_ENTERPRISE__CONTRIBSYS__COM }} + USER_ID=${{ env.VETS_API_USER_ID }} + context: . + push: false + load: true + tags: vets-api + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Setup Database + run: | + docker compose -f docker-compose.test.yml run web bash \ + -c "CI=true RAILS_ENV=test DISABLE_BOOTSNAP=true bundle exec parallel_test -n 13 -e 'bin/rails db:reset'" + + - name: Run Unit Tests + run: | + docker compose -f docker-compose.test.yml run web bash \ + -c "CI=true DISABLE_BOOTSNAP=true bundle exec parallel_rspec spec/models spec/lib spec/serializers spec/services spec/uploaders spec/sidekiq -n 13 -o '--tag ~type:request --tag ~type:controller --color --tty'" + + - name: Simplecov Report + if: success() || failure() + uses: shettytejas/simplecov-reporter@v1 + with: + title: Coverage Report for Unit Tests + result-path: coverage/unit_test_results.json + token: ${{ secrets.GITHUB_TOKEN }}