CI: support workflow dispatch #1
Workflow file for this run
This file contains 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 AppSync utils | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
env: | |
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} | |
TEST_IMAGE_NAME: public.ecr.aws/lambda/nodejs:16 | |
jobs: | |
unit-test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 16 | |
- run: npm ci | |
- run: npm test | |
integration-test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 16 | |
- name: Pull test docker image | |
run: docker pull $TEST_IMAGE_NAME | |
- name: Install dependencies | |
run: npm ci | |
- name: Integration test with LocalStack invoke method | |
run: bash ./test_in_docker.sh | |
localstack-test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Start LocalStack | |
uses: LocalStack/[email protected] | |
with: | |
image-tag: 'latest' | |
use-pro: 'true' | |
env: | |
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} | |
APPSYNC_JS_LIBS_VERSION: ${{ github.sha }} | |
DEBUG: "1" | |
DISABLE_EVENTS: "1" | |
- name: Ensure pro image is used | |
run: curl -s http://localhost:4566/_localstack/health | grep appsync | |
- uses: actions/setup-node@v4 | |
- name: Install cdk project | |
working-directory: cdk | |
run: npm install | |
- name: CDK bootstrap | |
working-directory: cdk | |
run: npm run cdklocal -- bootstrap | |
- name: CDK deploy | |
working-directory: cdk | |
run: npm run cdklocal -- deploy --require-approval never --outputs-file outputs.json | |
- name: Fetch output variables for test step | |
working-directory: cdk | |
run: | | |
jq -r '"TEST_URL=\(.CdkStack.GraphQLURL)"' outputs.json >> $GITHUB_ENV | |
jq -r '"TEST_API_KEY=\(.CdkStack.ApiKey)"' outputs.json >> $GITHUB_ENV | |
- name: Invoke the URL | |
run: | | |
set -x | |
curl --connect-timeout 30 --retry 10 --retry-delay 6 -X POST -H "x-api-key:$TEST_API_KEY" -H "Accept:application/json" -H "Content-Type:application/json" $TEST_URL -d '{"query": "query { foo }"}' | |
- name: Get the LocalStack logs | |
if: success() || failure() | |
run: | | |
localstack logs | gzip > logs.txt.gz | |
- name: Upload the logs as an artifact | |
if: success() || failure() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ls-logs-${{ github.run_number }} | |
path: | | |
logs.txt.gz | |
retention-days: 7 | |
- name: Print the LocalStack logs | |
if: success() || failure() | |
run: | | |
gunzip -c logs.txt.gz |