Add Docker pipeline for RabbitMQ testcontainers with configurable image source and PR-specific images #1274
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: CI | |
| permissions: | |
| contents: read | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| format: | |
| name: Format | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Check formatting | |
| run: pnpm format --check | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Run linter | |
| run: pnpm lint | |
| sort-package-json: | |
| name: Sort package.json | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Check package.json sorting | |
| run: pnpm sort-package-json --check | |
| typecheck: | |
| name: Type Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Run type check | |
| run: pnpm typecheck | |
| knip: | |
| name: Knip | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Run knip | |
| run: pnpm exec knip --reporter github-actions | |
| test: | |
| name: Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Run tests | |
| run: pnpm test -- --coverage --reporter=default --reporter=github-actions | |
| - name: Upload Coverage Report | |
| if: always() | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: coverage-report | |
| path: ./**/coverage/ | |
| retention-days: 30 | |
| test-integration: | |
| name: Integration Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check if Dockerfile changed | |
| id: dockerfile-changed | |
| run: | | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| if git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -E '^Dockerfile$|^\.github/workflows/docker-rabbitmq\.yml$'; then | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| echo "Dockerfile or docker workflow changed in this PR" | |
| else | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| echo "Dockerfile did not change in this PR" | |
| fi | |
| else | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Wait for Docker image build | |
| if: steps.dockerfile-changed.outputs.changed == 'true' | |
| run: | | |
| echo "Waiting for Docker image to be built..." | |
| # Give the Docker workflow more time to start and build the image before polling | |
| sleep 180 | |
| # Poll for image availability | |
| for i in {1..30}; do | |
| if docker pull ghcr.io/${{ github.repository }}/rabbitmq:pr-${{ github.event.pull_request.number }} 2>/dev/null; then | |
| echo "Image is available" | |
| exit 0 | |
| fi | |
| echo "Waiting for image... attempt $i/30" | |
| sleep 20 | |
| done | |
| echo "Warning: Image may not be ready, will try to use it anyway" | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Run integration tests | |
| run: pnpm test:integration -- --coverage --reporter=default --reporter=github-actions | |
| env: | |
| # Use PR-specific image if Dockerfile changed, otherwise use latest | |
| # Format includes fallback to run_number to avoid empty tags | |
| RABBITMQ_IMAGE: ghcr.io/${{ github.repository }}/rabbitmq:${{ steps.dockerfile-changed.outputs.changed == 'true' && format('pr-{0}', github.event.pull_request.number || github.run_number) || 'latest' }} | |
| - name: Upload Integration Coverage Report | |
| if: always() | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: integration-coverage-report | |
| path: ./**/coverage/ | |
| retention-days: 30 |