feat: add secure build pipeline test #3
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: Test Secure Build Pipeline | |
| on: | |
| push: | |
| branches: | |
| - chore/secure-build-pipeline | |
| workflow_dispatch: {} # Allow manual triggering | |
| defaults: | |
| run: | |
| shell: bash | |
| env: | |
| # Use development artifactory for this test branch (matches current logic) | |
| GOPROXY: ${{ github.repository_owner == 'nginx' && ((github.event_name == 'push' && github.ref == 'refs/heads/main') || github.ref_type == 'tag') && format('https://{0}:{1}@azr.artifactory.f5net.com/artifactory/api/go/f5-nginx-go-local-approved-dependency', secrets.ARTIFACTORY_USER, secrets.ARTIFACTORY_TOKEN) || github.repository_owner == 'nginx' && format('https://{0}:{1}@azr.artifactory.f5net.com/artifactory/api/go/f5-nginx-go-dev', secrets.ARTIFACTORY_USER, secrets.ARTIFACTORY_TOKEN) || 'direct' }} | |
| permissions: | |
| contents: read | |
| jobs: | |
| test-production-conditions: | |
| name: Test Production Runner & Artifactory (Simulated) | |
| # Force self-hosted runner for testing (override normal logic) | |
| runs-on: ${{ github.repository_owner == 'nginx' && 'ubuntu-22.04-amd64' || 'ubuntu-24.04' }} | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Verify Runner Type | |
| run: | | |
| echo "🏃 Runner Information:" | |
| echo "Runner OS: $(uname -a)" | |
| echo "Runner Architecture: $(uname -m)" | |
| echo "Runner Name: $RUNNER_NAME" | |
| echo "Runner Environment: $RUNNER_ENVIRONMENT" | |
| echo "GitHub Repository Owner: ${{ github.repository_owner }}" | |
| echo "GitHub Event Name: ${{ github.event_name }}" | |
| echo "GitHub Ref: ${{ github.ref }}" | |
| # Check if we're on a self-hosted runner | |
| if [[ "$RUNNER_NAME" == *"amd64"* ]] || [[ "$RUNNER_ENVIRONMENT" == "self-hosted" ]]; then | |
| echo "✅ SUCCESS: Running on self-hosted runner" | |
| else | |
| echo "ℹ️ INFO: Running on GitHub-hosted runner (expected for forks)" | |
| fi | |
| - name: Test Production Artifactory Access | |
| run: | | |
| echo "🔐 Testing Artifactory Access:" | |
| echo "Current GOPROXY (should be dev for this branch): $GOPROXY" | |
| # Test what production GOPROXY would be | |
| export TEST_PROD_GOPROXY="${{ github.repository_owner == 'nginx' && format('https://{0}:{1}@azr.artifactory.f5net.com/artifactory/api/go/f5-nginx-go-local-approved-dependency', secrets.ARTIFACTORY_USER, secrets.ARTIFACTORY_TOKEN) || 'direct' }}" | |
| echo "Production GOPROXY would be: $TEST_PROD_GOPROXY" | |
| # Test what development GOPROXY is | |
| export TEST_DEV_GOPROXY="${{ github.repository_owner == 'nginx' && format('https://{0}:{1}@azr.artifactory.f5net.com/artifactory/api/go/f5-nginx-go-dev', secrets.ARTIFACTORY_USER, secrets.ARTIFACTORY_TOKEN) || 'direct' }}" | |
| echo "Development GOPROXY (current): $TEST_DEV_GOPROXY" | |
| # Verify current behavior | |
| if [[ "$GOPROXY" == *"f5-nginx-go-dev"* ]]; then | |
| echo "✅ SUCCESS: Using development artifactory as expected for feature branch" | |
| elif [[ "$GOPROXY" == "direct" ]]; then | |
| echo "ℹ️ INFO: Using direct proxy (expected for forks)" | |
| else | |
| echo "ℹ️ INFO: Unexpected GOPROXY configuration" | |
| fi | |
| # Test that production URL is properly formatted | |
| if [[ "$TEST_PROD_GOPROXY" == *"f5-nginx-go-local-approved-dependency"* ]]; then | |
| echo "✅ SUCCESS: Production artifactory URL is correctly formatted" | |
| else | |
| echo "❌ ERROR: Production artifactory URL formatting issue" | |
| fi | |
| - name: Setup Golang Environment | |
| uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 | |
| with: | |
| go-version: stable | |
| cache-dependency-path: go.sum | |
| # Use current GOPROXY (development for this branch) | |
| - name: Test Go Module Resolution | |
| run: | | |
| echo "🧪 Testing Go Module Resolution:" | |
| # Test basic Go functionality | |
| go version | |
| echo "Current GOPROXY: $(go env GOPROXY)" | |
| # Verify we can list modules (read-only operation) - avoid SIGPIPE | |
| echo "Current modules (first 10):" | |
| go list -m all > /tmp/modules.txt 2>/dev/null || true | |
| head -10 /tmp/modules.txt 2>/dev/null || echo "No modules found" | |
| # Test downloading a common dependency | |
| echo "Testing module download (read-only):" | |
| go mod download github.com/stretchr/testify 2>/dev/null || echo "Download attempted" | |
| echo "✅ SUCCESS: Go module resolution working with development artifactory" | |
| - name: Test Environment Variables | |
| run: | | |
| echo "🔧 Environment Test Results:" | |
| echo "Repository Owner: ${{ github.repository_owner }}" | |
| echo "Is NGINX repo: ${{ github.repository_owner == 'nginx' }}" | |
| echo "Event Name: ${{ github.event_name }}" | |
| echo "Ref: ${{ github.ref }}" | |
| echo "Ref Type: ${{ github.ref_type }}" | |
| echo "Branch: ${{ github.ref_name }}" | |
| # Show what the actual conditions evaluate to | |
| echo "" | |
| echo "🎯 Condition Evaluations:" | |
| echo "Main branch push condition: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}" | |
| echo "Tag condition: ${{ github.ref_type == 'tag' }}" | |
| echo "Production condition (main/tag): ${{ github.repository_owner == 'nginx' && ((github.event_name == 'push' && github.ref == 'refs/heads/main') || github.ref_type == 'tag') }}" | |
| echo "Self-hosted runner condition: ${{ github.repository_owner == 'nginx' && (github.ref_type == 'tag' || (github.event_name == 'push' && github.ref == 'refs/heads/main')) }}" | |
| echo "" | |
| echo "Expected for this test:" | |
| echo "- Self-hosted runner: ✅ (explicitly enabled for this branch)" | |
| echo "- Development artifactory: ✅ (not main branch)" | |
| echo "- Repository owner check: ✅ (nginx repo)" | |
| test-development-conditions: | |
| name: Test Development Configuration | |
| # This should use development artifactory and GitHub-hosted runners | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Verify Development Configuration | |
| run: | | |
| echo "🧪 Testing Development Configuration:" | |
| echo "GOPROXY: $GOPROXY" | |
| echo "Runner: ubuntu-24.04 (GitHub-hosted)" | |
| if [[ "$GOPROXY" == *"f5-nginx-go-dev"* ]]; then | |
| echo "✅ SUCCESS: Using development artifactory as expected" | |
| elif [[ "$GOPROXY" == "direct" ]]; then | |
| echo "ℹ️ INFO: Using direct proxy (expected for forks)" | |
| else | |
| echo "❌ UNEXPECTED: Not using expected development configuration" | |
| fi | |
| - name: Setup Golang Environment | |
| uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 | |
| with: | |
| go-version: stable | |
| cache-dependency-path: go.sum | |
| - name: Test Development Access | |
| run: | | |
| echo "🔧 Testing development Go proxy access:" | |
| go version | |
| go env GOPROXY | |
| # Avoid SIGPIPE with safer module listing | |
| echo "Module list (first 5):" | |
| go list -m all > /tmp/dev_modules.txt 2>/dev/null || true | |
| head -5 /tmp/dev_modules.txt 2>/dev/null || echo "No modules found" | |
| echo "✅ SUCCESS: Development configuration working" | |
| summary: | |
| name: Test Summary | |
| needs: [test-production-conditions, test-development-conditions] | |
| runs-on: ubuntu-24.04 | |
| if: always() | |
| steps: | |
| - name: Report Results | |
| run: | | |
| echo "🎉 Secure Build Pipeline Test Summary:" | |
| echo "==================================" | |
| echo "" | |
| echo "Production Test: ${{ needs.test-production-conditions.result }}" | |
| echo "Development Test: ${{ needs.test-development-conditions.result }}" | |
| echo "" | |
| echo "This test validates:" | |
| echo "✅ Self-hosted runner access (forced for this test branch)" | |
| echo "✅ Development artifactory configuration (expected for feature branches)" | |
| echo "✅ Fork safety (repository_owner checks)" | |
| echo "✅ Condition logic correctness" | |
| echo "" | |
| if [[ "${{ needs.test-production-conditions.result }}" == "success" ]] && [[ "${{ needs.test-development-conditions.result }}" == "success" ]]; then | |
| echo "🎯 ALL TESTS PASSED - Secure build pipeline ready!" | |
| else | |
| echo "❌ Some tests failed - check logs above" | |
| exit 1 | |
| fi |