Skip to content

Commit 813603a

Browse files
authored
chore: node e2e config -> gha secret (#400)
1 parent 9f82857 commit 813603a

File tree

8 files changed

+68
-247
lines changed

8 files changed

+68
-247
lines changed

.changeset/five-donkeys-join.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

.github/workflows/callable-local-e2e-tests.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,20 @@ jobs:
66
unit_test:
77
name: Local E2E Tests
88
runs-on: ubuntu-latest
9+
910
steps:
1011
- name: Checkout repository
1112
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 https://github.com/actions/checkout/commit/24cb9080177205b6e8c946b17badbe402adc938f
1213
with:
1314
path: amplify-api-next
1415
- name: Setup node and build the repository
1516
uses: ./amplify-api-next/.github/actions/node-and-build
17+
- name: Write Amplify outputs
18+
working-directory: ./amplify-api-next
19+
env:
20+
AMPLIFY_OUTPUTS_BASE64: ${{ secrets.E2E_NODE_AMPLIFY_OUTPUTS_BASE64 }}
21+
run: |
22+
echo $AMPLIFY_OUTPUTS_BASE64 | base64 --decode > ./packages/e2e-tests/node/amplify_outputs.json
1623
- name: Install Node Sample Dependencies
1724
working-directory: ./amplify-api-next
1825
run: npm run e2e-node:install

.github/workflows/callable-release-verification.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
local-e2e:
1818
needs:
1919
- prebuild-ubuntu
20+
secrets: inherit
2021
uses: ./.github/workflows/callable-local-e2e-tests.yml
2122
e2e:
2223
needs:
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Push - run release verifications
2+
3+
concurrency:
4+
# group name unique for push to push-integ-test
5+
group: push-e2e-${{ github.ref }}
6+
cancel-in-progress: true
7+
8+
on:
9+
push:
10+
branches:
11+
- replace-with-your-branch
12+
13+
jobs:
14+
e2e:
15+
secrets: inherit
16+
uses: ./.github/workflows/callable-release-verification.yml

packages/e2e-tests/node/.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@ dist-ssr
2424
*.sw?
2525

2626
# amplify
27-
.amplify
27+
.amplify
28+
amplify_outputs.json
29+
amplify_outputs.base64

packages/e2e-tests/node/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Node E2E Test
2+
3+
This e2e test relies on a long-lived cloud backend provisioned in the team's internal AWS account.
4+
5+
The `amplify_outputs.json` file is not persisted to the repo. The contents of the `amplify_outputs.json` file are base64-encoded and stored in a GitHub Actions secret. The GHA job creates a temporary `amplify_outputs.json` from the secret during execution.
6+
7+
The decoded config is stored in SSM in the team's internal AWS account.
8+
9+
## Running the test locally
10+
11+
1. Run `npx ampx sandbox`
12+
1. `npm run install:no-lock`
13+
1. `npm run e2e-node` to run test
14+
15+
Note: `amplify_outputs.json` and `.amplify/*` files are ignored by Git in this directory, so you do not have to delete them manually.
16+
17+
## Updating backend
18+
19+
Prereqs:
20+
21+
- `gh` CLI installed and configured with your GitHub credentials (`brew install gh && gh auth login`)
22+
- amplify-backend profile configured with the team's internal AWS test account
23+
24+
See GitHub Actions [docs](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions#storing-base64-binary-blobs-as-secrets) for similar configuration.
25+
26+
Steps:
27+
28+
1. Create a new amplify-backend sandbox in this directory using an AWS profile configured with our internal AWS test account credentials
29+
1. After sandbox deploys, ensure the generated `amplify_outputs.json` contains the expected configuration
30+
1. Run `base64 -i amplify_outputs.json -o amplify_outputs.base64` to output a base64-encoded config
31+
1. Run `gh secret set E2E_NODE_AMPLIFY_OUTPUTS_BASE64 < amplify_outputs.base64` to set the secret to the base64-encoded value
32+
1. Trigger e2e workflow to confirm the test script works as expected with your new backend.
33+
- **If you're seeing errors and would like to revert to the last known working config: retrieve `amplify_outputs.json` from team's SSM, base64-encode it, and set as secret value. Trigger test run to confirm.**
34+
- If new config works as expected, update SSM with the new config you created. Use the un-encoded JSON contents (direct copy-paste from your `amplify_outputs.json` file)
35+
36+
Note: `amplify_outputs.json` and `amplify_outputs.base64` files are ignored by Git in this directory, so you do not have to delete them manually.

packages/e2e-tests/node/amplify_outputs.json

Lines changed: 0 additions & 245 deletions
This file was deleted.

packages/e2e-tests/node/utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ import {
66
} from 'aws-amplify/data';
77
import { Hub, ConsoleLogger } from 'aws-amplify/utils';
88
import type { Schema } from './amplify/data/resource';
9-
import outputs from './amplify_outputs.json';
109
import { WebSocket } from 'ws';
10+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
11+
// @ts-ignore - outputs is loaded dynamically in GHA; expected undefined locally
12+
import outputs from './amplify_outputs.json';
1113

1214
// TODO: use imported type from `aws-amplify/data` once it's fixed
1315
export type Client = ReturnType<typeof generateClient<Schema>>;

0 commit comments

Comments
 (0)