Skip to content

chore: bump serverless from 3.40.0 to 4.10.1 in /examples/basic #702

chore: bump serverless from 3.40.0 to 4.10.1 in /examples/basic

chore: bump serverless from 3.40.0 to 4.10.1 in /examples/basic #702

Workflow file for this run

name: build
# We want pushes to main, beta, and next to trigger a publish to npm for the corresponding npm dist-tag.
# NOTE: semantic-release detects pull requests and won't deploy on them so we don't have to deal with that complexity here.
# Any pull request should run all tests.
# NOTE: e2e tests use shared resource (AWS) and if they run concurrently they step on one another and cause errors.
# This can happen for beta & next branches if a PR targeting main also exists for them. There is some logic in e2e_tests job to mitigate this.
on:
push:
branches: [main, beta, next]
pull_request:
branches: [main]
# Allow one concurrent build for the same branch
concurrency:
group: current-branch-${{ github.ref }}
cancel-in-progress: true
jobs:
unit_tests:
runs-on: ubuntu-20.04
strategy:
matrix:
node: [20, 22]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
cache: "npm"
- name: install dependencies
run: |
npm i
- name: test
env:
CI_NODE_VERSION: ${{ matrix.node }}
run: |
npm run test
- name: publish coverage
uses: coverallsapp/github-action@master
continue-on-error: true
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: nodejs-${{ matrix.node }}
parallel: true
update_code_coverage:
needs: unit_tests
runs-on: ubuntu-20.04
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
continue-on-error: true
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
e2e_tests:
# Allow only one concurrent deployment for the target branch:
## no reason to run the long-running AWS e2e tests until we are sure this one will be viable
## NOTE: we could separate e2e_tests job into a e2e_tests_local and e2e_tests_remote since the local ones are quite a lot faster
concurrency:
group: target-branch-${{ github.base_ref }}
permissions:
# NOTE: If you specify the access for any of these scopes, all of those that are not specified are set to none.
# for AWS OIDC Token access per https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services#updating-your-github-actions-workflow
id-token: write
contents: read
deployments: read
needs: unit_tests
runs-on: ubuntu-20.04
environment: aws
env:
# e2e tests use a shared resource in AWS. Since we trigger on both a push to beta/next and a PR with destination branch of main, a PR against beta/next will cause them to run concurrently and causes errors. To prevent this contention we use a serverless stage.
# For more information on serverless stages:
# - https://www.serverless.com/framework/docs/providers/aws/cli-reference/deploy/
# - https://www.serverless.com/framework/docs/providers/aws/guide/deploying#tips
# github.run_id: A unique number for each run within a repository. This number does not change if you re-run the workflow run. https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context
# github format: https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#format
SERVERLESS_STAGE: ${{ github.event_name == 'pull_request' && format('pr{0}', github.run_id) || format('push{0}', github.run_id) }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v1
with:
# NOTE: in v13.0, serverless-offline removed support for node v14: https://github.com/dherault/serverless-offline/releases/tag/v13.0.0
node-version: 20
- name: build plugin locally
run: |
cd "$GITHUB_WORKSPACE"
npm i
npm pack
- name: run local end-to-end test in serverless-offline
run: |
"$GITHUB_WORKSPACE/test-files/scripts/test-local-e2e.sh"
- name: configure aws credentials
# Configures AWS credential and region environment variables for use in other GitHub Actions.
# The environment variables will be detected by both the AWS SDKs and the AWS CLI to determine the credentials and region to use for AWS API calls.
# More on this action at https://github.com/aws-actions/configure-aws-credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: arn:aws:iam::166901232151:role/serverless-aws-static-file-handler-at-github
aws-region: us-west-2
- name: prepare to run remote end-to-end test
run: |
cd "$GITHUB_WORKSPACE/examples/basic"
npm i
# update to use the local plugin built above
npm install --save file://../../serverless-aws-static-file-handler-0.0.0.tgz
- name: run remote end-to-end test
run: |
cd "$GITHUB_WORKSPACE/examples/basic"
echo "Deploying serverless stage $SERVERLESS_STAGE"
./node_modules/.bin/serverless deploy --stage $SERVERLESS_STAGE
# get the APIG endpoint URL:
APIG_URL=$(./node_modules/.bin/serverless info --stage $SERVERLESS_STAGE | sed -nr "s#^.*(https://.+/$SERVERLESS_STAGE)\$#\1#p")
echo "Discovered APIG_URL: $APIG_URL"
# CURL to some known good endpoints expecting 200:
TEST_HTTP_EXEC=$GITHUB_WORKSPACE/test-files/scripts/test-http.sh
ROOT_URL=$APIG_URL
# 200; these all should succeed
$TEST_HTTP_EXEC $ROOT_URL/binary/png.png
$TEST_HTTP_EXEC $ROOT_URL/binary/jpg.jpg
$TEST_HTTP_EXEC $ROOT_URL/binary/glyphicons-halflings-regular.woff2
$TEST_HTTP_EXEC $ROOT_URL/binary/subdir/png.png
# 403
$TEST_HTTP_EXEC "$ROOT_URL/ff404.png" 403
$TEST_HTTP_EXEC "$ROOT_URL/jpeg404.jpg" 403
$TEST_HTTP_EXEC "$ROOT_URL/subdir404/ff.png" 403
$TEST_HTTP_EXEC "$ROOT_URL/subdir/ff404.png" 403
# 404
$TEST_HTTP_EXEC "$ROOT_URL/binary/404-glyphicons-halflings-regular.woff2" 404
$TEST_HTTP_EXEC "$ROOT_URL/binary/subdir/404-png.png" 404
- name: cleanup remote end-to-end test (destroy serverless stack)
# Run this step even if the prior one failed (to clean up)
if: ${{ always() }}
run: |
cd "$GITHUB_WORKSPACE/examples/basic"
echo "Destroying serverless stage $SERVERLESS_STAGE"
./node_modules/.bin/serverless remove --stage $SERVERLESS_STAGE
publish_package:
if: ${{ github.event_name != 'pull_request' }}
needs: [e2e_tests, unit_tests]
runs-on: ubuntu-20.04
environment: npm
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 20
#- name: debug publish_package
# uses: actions/bin/debug@master
- name: publish to npm
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm install
npx semantic-release@17