AP-735: use shared GHA workflows and run tests on built images to ens… #334
Workflow file for this run
This file contains hidden or 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: Build / Test / Push | |
| on: | |
| push: | |
| branches: | |
| - '**' | |
| workflow_dispatch: | |
| jobs: | |
| docker-build: | |
| uses: BerkeleyLibrary/.github/.github/workflows/docker-build.yml@v2.0.0 | |
| with: | |
| image: ghcr.io/${{ github.repository }} | |
| secrets: inherit | |
| test: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - docker-build | |
| container: | |
| image: ${{ needs.docker-build.outputs.image }} | |
| defaults: | |
| run: | |
| working-directory: /opt/app | |
| services: | |
| db: | |
| image: postgres | |
| env: | |
| POSTGRES_USER: root | |
| POSTGRES_PASSWORD: root | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up Docker Compose | |
| uses: docker/setup-compose-action@v2 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup the stack | |
| run: | | |
| docker compose up --wait | |
| - name: Run tests | |
| env: | |
| RAILS_ENV: test | |
| run: docker compose exec bundle exec rake check -t | |
| - name: Run style checks | |
| run: docker compose exec bundle exec rubocop | |
| - name: Validate database migrations | |
| env: | |
| RAILS_ENV: production | |
| SECRET_KEY_BASE: dummy_test_secret_key_base | |
| DISABLE_DATABASE_ENVIRONMENT_CHECK: 1 | |
| run: docker compose exec bundle exec rails --trace db:drop db:create db:migrate | |
| - name: Upload artifacts | |
| if: ${{ always() }} | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: artifacts | |
| path: artifacts/** | |
| push: | |
| needs: | |
| - docker-build | |
| - test | |
| uses: BerkeleyLibrary/.github/.github/workflows/docker-push.yml@v2.0.0 | |
| with: | |
| image: ghcr.io/${{ github.repository }} | |
| build-image-arm64: ${{ needs.docker-build.outputs.image-arm64 }} | |
| build-image-x64: ${{ needs.docker-build.outputs.image-x64 }} | |
| secrets: inherit |