diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 92c4360..dc74266 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -28,7 +28,7 @@ jobs: run: curl https://curl.se/ca/cacert.pem -o build/public-certs.pem - name: Zip Lambda - run: zip -r -qq proxy-lambda.zip build node_modules + run: bun run package - name: Upload Release Assets uses: softprops/action-gh-release@v3 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 20e5099..f893afc 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -29,6 +29,23 @@ jobs: - name: Build run: bun run build + - name: Setup Node + uses: actions/setup-node@v7 + with: + # Keep in sync with the Lambda runtime in lambda.tf + node-version: 20 + + - name: Smoke Test Lambda Bundle + # Load the handler from the packaged zip the way Lambda does: as CommonJS, with + # require(esm) and module syntax detection off, so an ESM bundle fails here too. + run: | + bun run package + unzip -q proxy-lambda.zip -d "$RUNNER_TEMP/lambda" + cd "$RUNNER_TEMP/lambda" + node --no-experimental-require-module --no-experimental-detect-module -e " + if (typeof require('./build/proxy.js').handler !== 'function') throw new Error('build/proxy.js does not export handler'); + " + - name: Test run: bun run test diff --git a/package.json b/package.json index 516f27f..40dedf2 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "main": "lambdas/proxy/index.js", "type": "module", "scripts": { - "build": "bun build lambda/proxy.ts --outdir build/ --target node", + "build": "bun build lambda/proxy.ts --outdir build/ --target node --format cjs", + "package": "zip -r -qq proxy-lambda.zip build node_modules", "format": "prettier --write .", "format-check": "prettier --check .", "test": "bun test"