Publish construct #57
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/CD | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| jobs: | |
| install-deps: | |
| name: Install Dependencies (Cache Lookup Only) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ./.github/actions/configure-nodejs | |
| with: | |
| lookup-only: 'true' | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| needs: install-deps | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ./.github/actions/configure-nodejs | |
| - name: Build | |
| run: | | |
| npm run build | |
| npm run build -w packages/lambda | |
| - name: Cache cdk-construct build outputs | |
| id: cdk_construct_cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| packages/cdk-construct/coverage | |
| packages/cdk-construct/lib | |
| packages/cdk-construct/dist | |
| packages/cdk-construct/test-reports | |
| packages/cdk-construct/.jsii | |
| packages/cdk-construct/tsconfig.json | |
| key: cdk-construct-${{ hashFiles('packages/lambda/docker/**', 'packages/lambda/src/**', 'packages/lambda/tsconfig.json', 'packages/lambda/package.json', 'packages/cdk-construct/src/**', 'packages/cdk-construct/package.json', 'packages/cdk-construct/tsconfig.json', 'packages/cdk-construct/.projenrc.ts', 'package-lock.json', 'package.json') }} | |
| - name: Package the Construct | |
| if: steps.cdk_construct_cache.outputs.cache-hit != 'true' | |
| run: | | |
| npm run compile -w packages/cdk-construct | |
| npm run post-compile -w packages/cdk-construct | |
| npm run test -w packages/cdk-construct | |
| npm run package -w packages/cdk-construct | |
| - name: Upload cdk-construct-package artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: cdk-construct-package | |
| path: packages/cdk-construct/dist/js/*.tgz | |
| deploy: | |
| name: Deploy | |
| runs-on: ubuntu-latest | |
| needs: build | |
| permissions: | |
| contents: read | |
| id-token: write | |
| concurrency: | |
| group: deploy-${{ github.workflow }}-${{ github.event.pull_request.number || 'main' }} | |
| cancel-in-progress: false | |
| if: github.ref == 'refs/heads/main' || github.event_name == 'pull_request' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ./.github/actions/configure-nodejs | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/builder-writeRole | |
| aws-region: us-east-2 | |
| - name: Build | |
| run: | | |
| npm run build | |
| - name: Deploy CDK Stack (Main) | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| npx cdk deploy crush-test --require-approval never --outputs-file cdk-outputs.json | |
| - name: Deploy CDK Stack (PR) | |
| if: github.event_name == 'pull_request' | |
| env: | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| run: | | |
| npx cdk deploy crush-test-pr-${PR_NUMBER} --require-approval never --outputs-file cdk-outputs.json | |
| - name: Determine Lambda Name | |
| id: lambda-name | |
| run: | | |
| if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then | |
| echo "lambda_name=crush-test-lambda" >> $GITHUB_OUTPUT | |
| else | |
| echo "lambda_name=crush-test-lambda-pr-${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Lambda Smoke Check | |
| uses: ./.github/actions/lambda-smoke-check | |
| with: | |
| lambda_name: ${{ steps.lambda-name.outputs.lambda_name }} | |
| artifact_id: smoke-check-response-deploy | |
| deploy-packaged: | |
| name: Deploy Packaged | |
| runs-on: ubuntu-latest | |
| needs: build | |
| permissions: | |
| contents: read | |
| id-token: write | |
| concurrency: | |
| group: deploy-packaged-${{ github.workflow }}-${{ github.event.pull_request.number || 'main' }} | |
| cancel-in-progress: false | |
| if: github.ref == 'refs/heads/main' || github.event_name == 'pull_request' | |
| steps: | |
| - name: Checkout CDK only (sparse) | |
| uses: actions/checkout@v4 | |
| with: | |
| sparse-checkout: | | |
| .github | |
| cdk-consumer-test | |
| sparse-checkout-cone-mode: false | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| - name: Download cdk-construct-package artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: cdk-construct-package | |
| path: cdk-consumer-test | |
| - name: Install packaged construct | |
| working-directory: cdk-consumer-test | |
| run: | | |
| npm install ./crush-test-cdk*.tgz | |
| - name: Build | |
| working-directory: cdk-consumer-test | |
| run: | | |
| npm run build | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/builder-writeRole | |
| aws-region: us-east-2 | |
| - name: Deploy CDK Stack (Main) | |
| if: github.ref == 'refs/heads/main' | |
| working-directory: cdk-consumer-test | |
| run: | | |
| npx cdk deploy crush-test-construct-test --require-approval never --outputs-file cdk-outputs.json | |
| - name: Deploy CDK Stack (PR) | |
| if: github.event_name == 'pull_request' | |
| working-directory: cdk-consumer-test | |
| env: | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| run: | | |
| npx cdk deploy crush-test-construct-test-pr-${PR_NUMBER} --require-approval never --outputs-file cdk-outputs.json | |
| - name: Determine Lambda Name | |
| id: lambda-name | |
| working-directory: cdk-consumer-test | |
| run: | | |
| if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then | |
| echo "lambda_name=crush-test-construct-test-lambda" >> $GITHUB_OUTPUT | |
| else | |
| echo "lambda_name=crush-test-construct-test-lambda-pr-${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Lambda Smoke Check | |
| uses: ./.github/actions/lambda-smoke-check | |
| with: | |
| lambda_name: ${{ steps.lambda-name.outputs.lambda_name }} | |
| artifact_id: smoke-check-response-deploy-packaged | |
| summarize-performance: | |
| name: Summarize Performance Results | |
| runs-on: ubuntu-latest | |
| needs: | |
| - deploy | |
| - deploy-packaged | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout CDK only (sparse) | |
| uses: actions/checkout@v4 | |
| with: | |
| sparse-checkout: | | |
| scripts | |
| README.md | |
| sparse-checkout-cone-mode: false | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| - name: Download deploy smoke check artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: smoke-check-response-deploy | |
| path: smoke-check-deploy | |
| - name: Download deploy-packaged smoke check artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: smoke-check-response-deploy-packaged | |
| path: smoke-check-deploy-packaged | |
| - name: Summarize Performance Results | |
| id: perf-test | |
| run: | | |
| set -e | |
| # Extract and de-stringify "body" field for each artifact | |
| node scripts/extract-body.js smoke-check-deploy/response-oha.json smoke-check-deploy/response-oha.body.json | |
| node scripts/extract-body.js smoke-check-deploy/response-k6.json smoke-check-deploy/response-k6.body.json | |
| node scripts/extract-body.js smoke-check-deploy-packaged/response-oha.json smoke-check-deploy-packaged/response-oha.body.json | |
| node scripts/extract-body.js smoke-check-deploy-packaged/response-k6.json smoke-check-deploy-packaged/response-k6.body.json | |
| # Generate Markdown performance table | |
| node scripts/create-perf-table.js \ | |
| --oha-deploy smoke-check-deploy/response-oha.body.json \ | |
| --k6-deploy smoke-check-deploy/response-k6.body.json \ | |
| --oha-packaged smoke-check-deploy-packaged/response-oha.body.json \ | |
| --k6-packaged smoke-check-deploy-packaged/response-k6.body.json \ | |
| --output perf.md | |
| shell: bash | |
| - name: Update README with perf table | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| git fetch origin main | |
| git pull --rebase origin main | |
| node scripts/update-readme-perf-table.js perf-short.md README.md | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add README.md | |
| git commit -m "chore: update perf table in README.md [skip ci]" || echo "No changes to commit" | |
| git push | |
| - name: Find Performance Results Comment | |
| uses: peter-evans/find-comment@v3 | |
| id: find-comment | |
| if: github.event_name == 'pull_request' | |
| with: | |
| issue-number: ${{ github.event.pull_request.number }} | |
| comment-author: 'github-actions[bot]' | |
| body-includes: '### 🚀 Performance Test Results' | |
| - name: Post Performance Results Comment | |
| uses: peter-evans/create-or-update-comment@v4 | |
| if: github.event_name == 'pull_request' | |
| with: | |
| comment-id: ${{ steps.find-comment.outputs.comment-id }} | |
| edit-mode: replace | |
| issue-number: ${{ github.event.pull_request.number }} | |
| body-file: perf.md |