Add workload detection for PostgreSQL #5716
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
| # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | |
| # SPDX-License-Identifier: MIT | |
| name: PR Build | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| branches: | |
| - main* | |
| - feature* | |
| - feature/** | |
| types: | |
| - opened | |
| - synchronize | |
| - reopened | |
| - ready_for_review | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref_name }} | |
| cancel-in-progress: true | |
| jobs: | |
| changes: | |
| name: Check changes | |
| runs-on: ubuntu-latest | |
| outputs: | |
| build: ${{ steps.filter.outputs.build }} | |
| lint: ${{ steps.filter.outputs.lint }} | |
| steps: | |
| - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | |
| - uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1 | |
| id: filter | |
| with: | |
| list-files: shell | |
| filters: .github/config/file-filters.yml | |
| - name: List all updated files | |
| env: | |
| BUILD_FILES: ${{ steps.filter.outputs.build_files }} | |
| run: | | |
| for file in $BUILD_FILES; do | |
| echo "$file" | |
| done | |
| lint: | |
| needs: [changes] | |
| name: Check lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Set up Go 1.x | |
| if: needs.changes.outputs.lint == 'true' | |
| uses: actions/setup-go@7b8cf10d4e4a01d4992d18a89f4d7dc5a3e6d6f4 # v4.3.0 | |
| with: | |
| go-version: ~1.26.4 | |
| cache: false | |
| - name: Check out code | |
| if: needs.changes.outputs.lint == 'true' | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check format | |
| if: needs.changes.outputs.lint == 'true' | |
| run: | | |
| make fmt fmt-sh | |
| if [ ! -z "`git status --porcelain`" ]; then | |
| echo "make fmt changed files" | |
| git status | |
| exit 1 | |
| fi | |
| - name: Check license and imports | |
| if: needs.changes.outputs.lint == 'true' | |
| run: make lint | |
| build: | |
| needs: [lint, changes] | |
| name: Build ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-2022, windows-latest, macos-15] | |
| include: | |
| - os: ubuntu-latest | |
| family: linux | |
| cache-path: | | |
| ~/.cache/go-build | |
| ~/go/pkg/mod | |
| - os: macos-15 | |
| family: darwin | |
| cache-path: | | |
| ~/Library/Caches/go-build | |
| ~/go/pkg/mod | |
| - os: windows-2022 | |
| family: windows | |
| cache-path: | | |
| ~\AppData\Local\go-build | |
| ~\go\pkg\mod | |
| - os: windows-latest | |
| family: windows | |
| cache-path: | | |
| ~\AppData\Local\go-build | |
| ~\go\pkg\mod | |
| steps: | |
| - name: Set up Go 1.x | |
| if: needs.changes.outputs.build == 'true' | |
| uses: actions/setup-go@7b8cf10d4e4a01d4992d18a89f4d7dc5a3e6d6f4 # v4.3.0 | |
| with: | |
| go-version: ~1.26.4 | |
| cache: false | |
| - name: Check out code | |
| if: needs.changes.outputs.build == 'true' | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | |
| - name: Free up disk space | |
| if: needs.changes.outputs.build == 'true' && matrix.family == 'linux' | |
| run: .github/scripts/free-disk-space.sh | |
| - name: Cache binaries | |
| id: cached_binaries | |
| if: needs.changes.outputs.build == 'true' | |
| uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c # v3.5.0 | |
| with: | |
| key: "cached-binaries-${{ matrix.os }}-${{ github.sha }}" | |
| path: go.mod | |
| - name: Cache build output | |
| if: steps.cached_binaries.outputs.cache-hit != 'true' && needs.changes.outputs.build == 'true' | |
| uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c # v3.5.0 | |
| with: | |
| path: ${{ matrix.cache-path }} | |
| key: v1-go-pkg-mod-${{ matrix.os }}-${{ hashFiles('**/go.sum') }} | |
| - name: Install make | |
| if: matrix.family == 'windows' && steps.cached_binaries.outputs.cache-hit != 'true' && needs.changes.outputs.build == 'true' | |
| run: choco install make | |
| - name: Unit Test | |
| if: steps.cached_binaries.outputs.cache-hit != 'true' && needs.changes.outputs.build == 'true' | |
| run: make test | |
| - name: Build | |
| if: steps.cached_binaries.outputs.cache-hit != 'true' && needs.changes.outputs.build == 'true' | |
| env: | |
| MATRIX_FAMILY: ${{ matrix.family }} | |
| shell: bash | |
| run: make "amazon-cloudwatch-agent-$MATRIX_FAMILY" | |
| - name: Collect binary sizes | |
| if: steps.cached_binaries.outputs.cache-hit != 'true' && needs.changes.outputs.build == 'true' && matrix.family != 'darwin' && matrix.os != 'windows-latest' && github.event_name == 'pull_request' | |
| shell: bash | |
| env: | |
| RUNNER_OS: ${{ matrix.os }} | |
| run: .github/scripts/collect-binary-sizes.sh | |
| - name: Upload size report | |
| if: steps.cached_binaries.outputs.cache-hit != 'true' && needs.changes.outputs.build == 'true' && matrix.family != 'darwin' && matrix.os != 'windows-latest' && github.event_name == 'pull_request' | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: size-report-${{ matrix.os }} | |
| path: size-report-*.json | |
| if-no-files-found: ignore | |
| retention-days: 1 | |
| binary-size-report: | |
| name: Binary Size Report | |
| needs: [build, changes] | |
| if: needs.changes.outputs.build == 'true' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork != true | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | |
| - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | |
| id: download | |
| continue-on-error: true | |
| with: | |
| pattern: size-report-* | |
| merge-multiple: true | |
| path: ./size-reports | |
| - name: Configure AWS Credentials | |
| if: steps.download.outcome == 'success' | |
| uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4.3.1 | |
| with: | |
| role-to-assume: ${{ vars.TERRAFORM_AWS_ASSUME_ROLE }} | |
| aws-region: us-west-2 | |
| - name: Generate and post report | |
| if: steps.download.outcome == 'success' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| run: .github/scripts/report-binary-sizes.sh ./size-reports | |
| test-data-race: | |
| needs: [lint, changes] | |
| name: Test data race | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Set up Go 1.x | |
| if: needs.changes.outputs.build == 'true' | |
| uses: actions/setup-go@7b8cf10d4e4a01d4992d18a89f4d7dc5a3e6d6f4 # v4.3.0 | |
| with: | |
| go-version: ~1.26.4 | |
| cache: false | |
| - name: Check out code | |
| if: needs.changes.outputs.build == 'true' | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | |
| - name: Test data race | |
| if: needs.changes.outputs.build == 'true' | |
| run: make test-data-race | |
| verify-all: | |
| name: Verify All PR Build Jobs | |
| needs: [ changes, lint, build, test-data-race ] | |
| runs-on: ubuntu-latest | |
| if: ${{ !cancelled() }} | |
| steps: | |
| - name: Check Job Status | |
| env: | |
| NEEDS_JSON: ${{ toJSON(needs) }} | |
| run: | | |
| failed_jobs=() | |
| successful_jobs=() | |
| # Loop through all jobs in needs context | |
| for job in $(echo "$NEEDS_JSON" | jq -r 'keys[]'); do | |
| result=$(echo "$NEEDS_JSON" | jq -r ".[\"$job\"].result") | |
| if [[ "$result" == "failure" ]]; then | |
| failed_jobs+=("$job") | |
| elif [[ "$result" == "success" ]]; then | |
| successful_jobs+=("$job") | |
| fi | |
| done | |
| echo "Successfully validated jobs:" | |
| printf '%s\n' "${successful_jobs[@]}" | |
| if [ ${#failed_jobs[@]} -ne 0 ]; then | |
| echo -e "\nFailed jobs:" | |
| printf '%s\n' "${failed_jobs[@]}" | |
| exit 1 | |
| fi | |
| echo -e "\nAll required jobs completed without failures!" |