Skip to content

Commit 3d20703

Browse files
committed
Harden e2e workflows: fail-loud CDK sourcing, robust npm pack, fix concurrency/region/comments
1 parent decccca commit 3d20703

2 files changed

Lines changed: 42 additions & 14 deletions

File tree

.github/workflows/e2e-tests-full.yml

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ on:
66
description: 'AWS region for deployment'
77
default: 'us-east-1'
88
schedule:
9-
- cron: '0 14 * * 1' # Every Monday at 9 AM EST (14:00 UTC)
9+
- cron: '0 14 * * 1' # Mondays 14:00 UTC (09:00 EST / 10:00 EDT — cron does not observe DST)
1010

1111
concurrency:
12-
group: e2e-${{ github.event.pull_request.number || github.ref }}
12+
group: e2e-full-${{ github.ref }}
1313
cancel-in-progress: false
1414

1515
permissions:
@@ -21,6 +21,10 @@ jobs:
2121
runs-on: ubuntu-latest
2222
environment: e2e-testing
2323
timeout-minutes: 60
24+
env:
25+
# Single source for the AWS region default. On `workflow_dispatch` the
26+
# input applies; on `schedule` `inputs` is empty so the fallback applies.
27+
AWS_REGION: ${{ inputs.aws_region || 'us-east-1' }}
2428
strategy:
2529
fail-fast: false
2630
matrix:
@@ -43,7 +47,7 @@ jobs:
4347
uses: aws-actions/configure-aws-credentials@d979d5b3a71173a29b74b5b88418bfda9437d885 # v6.1.1
4448
with:
4549
role-to-assume: ${{ secrets.E2E_AWS_ROLE_ARN }}
46-
aws-region: ${{ inputs.aws_region || 'us-east-1' }}
50+
aws-region: ${{ env.AWS_REGION }}
4751
- name: Get AWS Account ID
4852
id: aws
4953
run: echo "account_id=$(aws sts get-caller-identity --query Account --output text)" >> "$GITHUB_OUTPUT"
@@ -58,21 +62,30 @@ jobs:
5862
- name: Build CDK package from main
5963
if: matrix.cdk-source == 'main'
6064
run: |
65+
set -euo pipefail
66+
[ -n "${CDK_REPO_TOKEN}" ] && [ -n "${CDK_REPO}" ] || { echo "::error::CDK_REPO and CDK_REPO_TOKEN must be set"; exit 1; }
6167
git clone --depth 1 "https://x-access-token:${CDK_REPO_TOKEN}@github.com/${CDK_REPO}.git" /tmp/cdk-repo
6268
cd /tmp/cdk-repo
6369
npm ci
6470
npm run build
65-
TARBALL=$(npm pack --pack-destination "$RUNNER_TEMP" | tail -1)
66-
echo "CDK_TARBALL=$RUNNER_TEMP/$TARBALL" >> "$GITHUB_ENV"
71+
TARBALL="$(npm pack --json --pack-destination "$RUNNER_TEMP" | jq -r '.[0].filename')"
72+
CDK_TARBALL="$RUNNER_TEMP/$TARBALL"
73+
# Fail loud: a missing tarball would silently fall back to the published
74+
# CDK in installCdkTarball(), defeating the `main` matrix leg.
75+
[ -f "$CDK_TARBALL" ] || { echo "::error::CDK tarball not found at '$CDK_TARBALL'"; exit 1; }
76+
echo "CDK_TARBALL=$CDK_TARBALL" >> "$GITHUB_ENV"
6777
env:
6878
CDK_REPO_TOKEN: ${{ secrets.CDK_REPO_TOKEN }}
6979
CDK_REPO: ${{ secrets.CDK_REPO_NAME }}
7080
- name: Install CLI globally
71-
run: npm install -g "$(npm pack | tail -1)"
81+
run: |
82+
set -euo pipefail
83+
TARBALL="$(npm pack --json | jq -r '.[0].filename')"
84+
npm install -g "./$TARBALL"
7285
- name: Run E2E tests (${{ matrix.cdk-source }})
7386
env:
7487
AWS_ACCOUNT_ID: ${{ steps.aws.outputs.account_id }}
75-
AWS_REGION: ${{ inputs.aws_region || 'us-east-1' }}
88+
AWS_REGION: ${{ env.AWS_REGION }}
7689
ANTHROPIC_API_KEY: ${{ env.E2E_ANTHROPIC_API_KEY }}
7790
OPENAI_API_KEY: ${{ env.E2E_OPENAI_API_KEY }}
7891
GEMINI_API_KEY: ${{ env.E2E_GEMINI_API_KEY }}

.github/workflows/e2e-tests.yml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ jobs:
2323
runs-on: ubuntu-latest
2424
environment: e2e-testing
2525
timeout-minutes: 30
26+
env:
27+
# Single source for the AWS region default. On `workflow_dispatch` the
28+
# input applies; on other events `inputs` is empty so the fallback applies.
29+
AWS_REGION: ${{ inputs.aws_region || 'us-east-1' }}
2630
strategy:
2731
fail-fast: false
2832
matrix:
@@ -58,7 +62,7 @@ jobs:
5862
uses: aws-actions/configure-aws-credentials@d979d5b3a71173a29b74b5b88418bfda9437d885 # v6.1.1
5963
with:
6064
role-to-assume: ${{ secrets.E2E_AWS_ROLE_ARN }}
61-
aws-region: ${{ inputs.aws_region || 'us-east-1' }}
65+
aws-region: ${{ env.AWS_REGION }}
6266
- name: Get AWS Account ID
6367
id: aws
6468
run: echo "account_id=$(aws sts get-caller-identity --query Account --output text)" >> "$GITHUB_OUTPUT"
@@ -74,28 +78,39 @@ jobs:
7478
- name: Build CDK package from main
7579
if: matrix.cdk-source == 'main'
7680
run: |
81+
set -euo pipefail
82+
[ -n "${CDK_REPO_TOKEN}" ] && [ -n "${CDK_REPO}" ] || { echo "::error::CDK_REPO and CDK_REPO_TOKEN must be set"; exit 1; }
7783
git clone --depth 1 "https://x-access-token:${CDK_REPO_TOKEN}@github.com/${CDK_REPO}.git" /tmp/cdk-repo
7884
cd /tmp/cdk-repo
7985
npm ci
8086
npm run build
81-
TARBALL=$(npm pack --pack-destination "$RUNNER_TEMP" | tail -1)
82-
echo "CDK_TARBALL=$RUNNER_TEMP/$TARBALL" >> "$GITHUB_ENV"
87+
TARBALL="$(npm pack --json --pack-destination "$RUNNER_TEMP" | jq -r '.[0].filename')"
88+
CDK_TARBALL="$RUNNER_TEMP/$TARBALL"
89+
# Fail loud: a missing tarball would silently fall back to the published
90+
# CDK in installCdkTarball(), defeating the `main` matrix leg.
91+
[ -f "$CDK_TARBALL" ] || { echo "::error::CDK tarball not found at '$CDK_TARBALL'"; exit 1; }
92+
echo "CDK_TARBALL=$CDK_TARBALL" >> "$GITHUB_ENV"
8393
env:
8494
CDK_REPO_TOKEN: ${{ secrets.CDK_REPO_TOKEN }}
8595
CDK_REPO: ${{ secrets.CDK_REPO_NAME }}
8696

8797
- run: npm ci
8898
- run: npm run build
8999
- name: Install CLI globally
90-
run: npm install -g "$(npm pack | tail -1)"
100+
run: |
101+
set -euo pipefail
102+
TARBALL="$(npm pack --json | jq -r '.[0].filename')"
103+
npm install -g "./$TARBALL"
91104
- name: Run E2E tests (${{ matrix.cdk-source }})
92105
env:
93106
AWS_ACCOUNT_ID: ${{ steps.aws.outputs.account_id }}
94-
AWS_REGION: ${{ inputs.aws_region || 'us-east-1' }}
107+
AWS_REGION: ${{ env.AWS_REGION }}
95108
ANTHROPIC_API_KEY: ${{ env.E2E_ANTHROPIC_API_KEY }}
96109
OPENAI_API_KEY: ${{ env.E2E_OPENAI_API_KEY }}
97110
GEMINI_API_KEY: ${{ env.E2E_GEMINI_API_KEY }}
98111
CDK_TARBALL: ${{ env.CDK_TARBALL }}
99-
# Only run Bedrock tests on PRs to avoid creating ApiKeyCredentialProviders,
100-
# which have a 50-resource account limit and accumulate from interrupted runs.
112+
# This manual/dispatch workflow runs only the Bedrock subset (strands-bedrock,
113+
# langgraph-bedrock) to limit creation of ApiKeyCredentialProviders, which have a
114+
# 50-resource account limit and accumulate from interrupted runs. The full suite
115+
# runs in e2e-tests-full.yml.
101116
run: npx vitest run --project e2e strands-bedrock langgraph-bedrock

0 commit comments

Comments
 (0)