Track RTT in nanos. #16
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: Docker Build - PR Validation | |
| on: | |
| pull_request: | |
| branches: [master, main] | |
| paths: | |
| - 'Dockerfile' | |
| - '.dockerignore' | |
| - 'docker-build.sh' | |
| - 'docker-run.sh' | |
| - 'subscriber.go' | |
| - 'go.mod' | |
| - 'go.sum' | |
| - 'Makefile' | |
| - '.github/workflows/docker-build-pr.yml' | |
| env: | |
| IMAGE_NAME: pubsub-sub-bench-pr | |
| jobs: | |
| docker-build-test: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Fetch full history for Git info | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Extract Git metadata | |
| id: meta | |
| run: | | |
| GIT_SHA=$(git rev-parse HEAD) | |
| GIT_DIRTY=$(git diff --no-ext-diff 2>/dev/null | wc -l) | |
| echo "git_sha=${GIT_SHA}" >> $GITHUB_OUTPUT | |
| echo "git_dirty=${GIT_DIRTY}" >> $GITHUB_OUTPUT | |
| echo "short_sha=${GIT_SHA:0:7}" >> $GITHUB_OUTPUT | |
| - name: Check Docker Hub credentials | |
| id: check_credentials | |
| run: | | |
| if [[ -n "${{ secrets.DOCKER_USERNAME }}" && -n "${{ secrets.DOCKER_PASSWORD }}" ]]; then | |
| echo "credentials_available=true" >> $GITHUB_OUTPUT | |
| echo "✅ Docker Hub credentials are configured" | |
| else | |
| echo "credentials_available=false" >> $GITHUB_OUTPUT | |
| echo "⚠️ Docker Hub credentials not configured (DOCKER_USERNAME and/or DOCKER_PASSWORD secrets missing)" | |
| echo "This is expected for forks and external PRs. Docker build validation will still work." | |
| fi | |
| - name: Build Docker image (single platform) | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| platforms: linux/amd64 | |
| push: false | |
| load: true | |
| tags: ${{ env.IMAGE_NAME }}:pr-${{ github.event.number }} | |
| build-args: | | |
| GIT_SHA=${{ steps.meta.outputs.git_sha }} | |
| GIT_DIRTY=${{ steps.meta.outputs.git_dirty }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Test Docker image | |
| run: | | |
| echo "Testing Docker image functionality..." | |
| # Verify image was built | |
| if docker images | grep -q "${{ env.IMAGE_NAME }}"; then | |
| echo "✅ Docker image built successfully" | |
| else | |
| echo "❌ Docker image not found" | |
| exit 1 | |
| fi | |
| # Test help command | |
| echo "Testing --help command..." | |
| docker run --rm ${{ env.IMAGE_NAME }}:pr-${{ github.event.number }} --help | |
| # Test version output | |
| echo "Testing --version command..." | |
| docker run --rm ${{ env.IMAGE_NAME }}:pr-${{ github.event.number }} --version | |
| echo "✅ Docker image tests passed!" | |
| - name: Build multi-platform image (validation only) | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| push: false | |
| tags: ${{ env.IMAGE_NAME }}:pr-${{ github.event.number }}-multiplatform | |
| build-args: | | |
| GIT_SHA=${{ steps.meta.outputs.git_sha }} | |
| GIT_DIRTY=${{ steps.meta.outputs.git_dirty }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Generate PR comment | |
| if: github.event_name == 'pull_request' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const credentialsStatus = '${{ steps.check_credentials.outputs.credentials_available }}' === 'true' | |
| ? '✅ Docker Hub credentials configured' | |
| : '⚠️ Docker Hub credentials not configured (expected for forks)'; | |
| const output = `## 🐳 Docker Build Validation | |
| ✅ **Docker build successful!** | |
| **Platforms tested:** | |
| - ✅ linux/amd64 (built and tested) | |
| - ✅ linux/arm64 (build validated) | |
| **Git SHA:** \`${{ steps.meta.outputs.git_sha }}\` | |
| **Docker Hub Status:** ${credentialsStatus} | |
| **Image details:** | |
| - Single platform: \`${{ env.IMAGE_NAME }}:pr-${{ github.event.number }}\` | |
| - Multi-platform: \`${{ env.IMAGE_NAME }}:pr-${{ github.event.number }}-multiplatform\` | |
| **Tests performed:** | |
| - ✅ Docker Hub credentials check | |
| - ✅ Help command execution | |
| - ✅ Version output validation | |
| - ✅ Multi-platform build validation | |
| The Docker image is ready for deployment! 🚀`; | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: output | |
| }); | |
| - name: Clean up test images | |
| if: always() | |
| run: | | |
| docker rmi ${{ env.IMAGE_NAME }}:pr-${{ github.event.number }} || true | |
| echo "Cleanup completed" |