diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml new file mode 100644 index 00000000..5993ac20 --- /dev/null +++ b/.github/workflows/build-and-release.yml @@ -0,0 +1,183 @@ +name: Build and Release + +on: + push: + branches: [ main ] + tags: [ 'v*', 'rc-*' ] + pull_request: + branches: [ main ] + workflow_dispatch: + +permissions: + id-token: write + contents: read + +jobs: + get-version: + runs-on: ubuntu-latest + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - uses: actions/checkout@v4 + - name: Get version + id: version + run: | + BASE_VERSION=$(node -p "require('./package.json').version") + echo "version=$BASE_VERSION" >> $GITHUB_OUTPUT + + build: + needs: [get-version] + timeout-minutes: 30 + strategy: + matrix: + include: + - arch: x86_64 + runner: codebuild-project-awsaws-lambda-nodejs-runtime-interface-client-${{ github.run_id }}-${{ github.run_attempt }} + - arch: aarch64 + runner: codebuild-project-awsaws-lambda-nodejs-runtime-interface-client-${{ github.run_id }}-${{ github.run_attempt }} + runs-on: ${{ matrix.runner }} + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Install build dependencies + run: | + apt-get update + apt-get install -y cmake make g++ autotools-dev automake libtool + + - name: Build natively for $(arch) + run: | + echo "Building for architecture: $(arch)" + CURRENT_ARCH=$(arch) + + # Build native dependencies and JavaScript (this creates dist/node14 and dist/node16) + BUILD=1 npm install + npm run build + + # Verify required files were created + if [ ! -f "dist/rapid-client.node" ] || [ ! -f "dist/index.mjs" ] || [ ! -f "dist/UserFunction.js" ]; then + echo "Error: Required files not found in dist directory" + exit 1 + fi + + # Copy architecture-specific package.json to dist + node -e " + const pkg = require('./package.json'); + pkg.name = 'aws-lambda-ric-' + process.env.CURRENT_ARCH; + require('fs').writeFileSync('./dist/package.json', JSON.stringify(pkg, null, 2)); + " CURRENT_ARCH=$CURRENT_ARCH + + # Create tarball with only required files + tar -czf aws-lambda-ric-$CURRENT_ARCH-${{ needs.get-version.outputs.version }}.tgz \ + -C dist package.json index.mjs UserFunction.js rapid-client.node + + - name: Generate checksums + run: | + CURRENT_ARCH=$(arch) + PACKAGE_FILE="aws-lambda-ric-$CURRENT_ARCH-${{ needs.get-version.outputs.version }}.tgz" + sha256sum $PACKAGE_FILE > checksums-$CURRENT_ARCH.sha256 + sha512sum $PACKAGE_FILE > checksums-$CURRENT_ARCH.sha512 + echo "Package: $PACKAGE_FILE ($CURRENT_ARCH) with version: ${{ needs.get-version.outputs.version }}" > checksums-$CURRENT_ARCH.txt + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: package-${{ matrix.arch }}-${{ needs.get-version.outputs.version }} + path: | + aws-lambda-ric-*-${{ needs.get-version.outputs.version }}.tgz + checksums-* + retention-days: 30 + + test: + needs: [get-version, build] + strategy: + matrix: + node-version: [18, 20, 22] + include: + - arch: x86_64 + runner: ubuntu-latest + - arch: aarch64 + runner: ubuntu-latest + runs-on: ${{ matrix.runner }} + steps: + - uses: actions/checkout@v4 + + - name: Run unit tests - Node ${{ matrix.node-version }} (native $(arch)) + run: | + docker build \ + -f test/unit/Dockerfile.nodejs${{ matrix.node-version }}.x \ + -t unit/nodejs.${{ matrix.node-version }}x \ + . + docker run --rm unit/nodejs.${{ matrix.node-version }}x + + publish: + if: startsWith(github.ref, 'refs/tags/') + runs-on: codebuild-project-awsaws-lambda-nodejs-runtime-interface-client-${{ github.run_id }}-${{ github.run_attempt }} + needs: [get-version, build, test] + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + + - name: Download x86_64 artifacts + uses: actions/download-artifact@v4 + with: + name: package-x86_64-${{ needs.get-version.outputs.version }} + path: ./artifacts/x86_64 + + - name: Download aarch64 artifacts + uses: actions/download-artifact@v4 + with: + name: package-aarch64-${{ needs.get-version.outputs.version }} + path: ./artifacts/aarch64 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Setup NPM authentication + run: | + NPM_TOKEN=$(aws secretsmanager get-secret-value --secret-id aws-lambda-runtimes/github/nodejs/npm-token --query SecretString --output text) + echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc + chmod 0600 .npmrc + + - name: Determine version and publish packages + id: version + run: | + if [[ "${{ github.ref }}" == refs/tags/rc-* ]]; then + RC_NUMBER=${GITHUB_REF#refs/tags/rc-} + PACKAGE_VERSION="${{ needs.get-version.outputs.version }}-rc.${RC_NUMBER}" + echo "package_version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT + echo "is_rc=true" >> $GITHUB_OUTPUT + TAG_FLAG="--tag rc" + else + echo "package_version=${{ needs.get-version.outputs.version }}" >> $GITHUB_OUTPUT + TAG_FLAG="" + fi + + # Publish architecture-specific packages + for arch in x86_64 aarch64; do + PACKAGE_FILE=$(ls ./artifacts/$arch/aws-lambda-ric-$arch-*.tgz) + echo "Publishing $PACKAGE_FILE for architecture $arch" + npm publish $PACKAGE_FILE $TAG_FLAG --access=public + done + + - name: Combine checksums + run: | + cat ./artifacts/*/checksums-*.txt > combined-checksums.txt + cat ./artifacts/*/checksums-*.sha256 > combined-checksums.sha256 + cat ./artifacts/*/checksums-*.sha512 > combined-checksums.sha512 + + - name: Create GitHub Release + if: startsWith(github.ref, 'refs/tags/') + uses: softprops/action-gh-release@v2 + with: + files: | + ./artifacts/*/aws-lambda-ric-*-*.tgz + combined-checksums.* + prerelease: ${{ steps.version.outputs.is_rc }} diff --git a/.npmignore b/.npmignore index af2d322b..35e35f70 100644 --- a/.npmignore +++ b/.npmignore @@ -4,6 +4,8 @@ build src/* # Rapid-client.c to be used with node-gyp !src/rapid-client.cc +# Include built native binary +!dist/rapid-client.node test # Logs diff --git a/README.md b/README.md index 789180cf..062ed08e 100644 --- a/README.md +++ b/README.md @@ -172,6 +172,39 @@ When modifying dependencies (`package.json`), make sure to: We require package-lock.json to be checked in to ensure consistent installations across development environments. +### Changelog Generation +This project maintains a changelog in `RELEASE.CHANGELOG.md`. The changelog is automatically updated when a new tag is created. + +To manually generate a changelog entry for testing or preview purposes, run: +```shell script +npm run changelog +``` + +To manually update the RELEASE.CHANGELOG.md file with a new entry: +```shell script +npm run changelog -- --update +``` + +### Copyright Headers +All source files in the bin, scripts, src, and test folders must include a copyright header containing both the words "Copyright" and "Amazon.com". The standard header format is: + +``` +/* +Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +SPDX-License-Identifier: Apache-2.0 +*/ +``` + +To check if your files have proper headers: +```shell script +npm run check-headers +``` + +To automatically add headers to files missing them: +```shell script +npm run add-headers +``` + ### Troubleshooting While running integration tests, you might encounter the Docker Hub rate limit error with the following body: diff --git a/package-lock.json b/package-lock.json index 1eb57207..83c0f0d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "aws-lambda-ric", - "version": "3.2.1", + "version": "3.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "aws-lambda-ric", - "version": "3.2.1", + "version": "3.3.0", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { @@ -21,6 +21,7 @@ "eslint": "8.42.0", "eslint-config-prettier": "8.8.0", "eslint-plugin-prettier": "4.2.1", + "glob": "^10.3.10", "husky": "^8.0.3", "lambda-runtime": "file:./src/", "mocha": "^10.8.2", @@ -896,9 +897,9 @@ } }, "node_modules/@isaacs/cliui/node_modules/ansi-regex": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", - "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", + "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", "engines": { "node": ">=12" }, @@ -1500,75 +1501,6 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, - "node_modules/cacache/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/cacache/node_modules/foreground-child": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", - "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", - "dependencies": { - "cross-spawn": "^7.0.0", - "signal-exit": "^4.0.1" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/cacache/node_modules/glob": { - "version": "10.2.7", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.2.7.tgz", - "integrity": "sha512-jTKehsravOJo8IJxUGfZILnkvVJM/MOfHRs8QcXolVef2zNI9Tqyy5+SeuOAZd3upViEZQLyFpQhYiHLrMUNmA==", - "dependencies": { - "foreground-child": "^3.1.0", - "jackspeak": "^2.0.3", - "minimatch": "^9.0.1", - "minipass": "^5.0.0 || ^6.0.2", - "path-scurry": "^1.7.0" - }, - "bin": { - "glob": "dist/cjs/src/bin.js" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/cacache/node_modules/minimatch": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.1.tgz", - "integrity": "sha512-0jWhJpD/MdhPXwPuiRkCbfYfSKp2qnn2eOc279qI7f+osl/l+prKSrvhg157zSYvx/1nmgn2NqdT6k2Z7zSH9w==", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/cacache/node_modules/signal-exit": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.0.2.tgz", - "integrity": "sha512-MY2/qGx4enyjprQnFaZsHib3Yadh3IXyV2C321GY0pjGfVBu4un0uDJkwgdxqO+Rdx8JMT8IfJIRwbYVz3Ob3Q==", - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/caching-transform": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/caching-transform/-/caching-transform-4.0.0.tgz", @@ -2618,19 +2550,19 @@ } }, "node_modules/glob": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "version": "10.4.5", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", + "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "foreground-child": "^3.1.0", + "jackspeak": "^3.1.2", + "minimatch": "^9.0.4", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^1.11.1" }, - "engines": { - "node": "*" + "bin": { + "glob": "dist/esm/bin.mjs" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -2648,6 +2580,62 @@ "node": ">=10.13.0" } }, + "node_modules/glob/node_modules/brace-expansion": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", + "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/glob/node_modules/foreground-child": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz", + "integrity": "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==", + "dependencies": { + "cross-spawn": "^7.0.6", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob/node_modules/minipass": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/glob/node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/globals": { "version": "13.20.0", "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", @@ -3159,15 +3147,12 @@ } }, "node_modules/jackspeak": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.2.1.tgz", - "integrity": "sha512-MXbxovZ/Pm42f6cDIDkl3xpwv1AGwObKwfmjs2nQePiy85tP3fatofl3FC1aBsOtP/6fq5SbtgHwWcMsLP+bDw==", + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", + "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", "dependencies": { "@isaacs/cliui": "^8.0.2" }, - "engines": { - "node": ">=14" - }, "funding": { "url": "https://github.com/sponsors/isaacs" }, @@ -3742,6 +3727,26 @@ "node": "^12.13 || ^14.13 || >=16" } }, + "node_modules/node-gyp/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/node-preload": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/node-preload/-/node-preload-0.2.1.tgz", @@ -3862,6 +3867,27 @@ "node": ">=8" } }, + "node_modules/nyc/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/nyc/node_modules/locate-path": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", @@ -4094,6 +4120,11 @@ "node": ">=8" } }, + "node_modules/package-json-from-dist": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", + "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==" + }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -4141,27 +4172,24 @@ } }, "node_modules/path-scurry": { - "version": "1.9.2", - "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.9.2.tgz", - "integrity": "sha512-qSDLy2aGFPm8i4rsbHd4MNyTcrzHFsLQykrtbuGRknZZCBBVXSv2tSCDN2Cg6Rt/GFRw8GoW9y9Ecw5rIPG1sg==", + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", + "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", "dependencies": { - "lru-cache": "^9.1.1", - "minipass": "^5.0.0 || ^6.0.2" + "lru-cache": "^10.2.0", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" }, "engines": { - "node": ">=16 || 14 >=14.17" + "node": ">=16 || 14 >=14.18" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/path-scurry/node_modules/lru-cache": { - "version": "9.1.2", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-9.1.2.tgz", - "integrity": "sha512-ERJq3FOzJTxBbFjZ7iDs+NiK4VI9Wz+RdrrAB8dio1oV+YvdPzUEE4QNiT2VD51DkIbCYRUUzCRkssXCHqSnKQ==", - "engines": { - "node": "14 || >=16.14" - } + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==" }, "node_modules/picocolors": { "version": "1.0.0", @@ -4476,6 +4504,26 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/rimraf/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", @@ -4974,6 +5022,27 @@ "node": ">=8" } }, + "node_modules/test-exclude/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", diff --git a/package.json b/package.json index dbf0360a..345b92f2 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,8 @@ "gypfile": true, "scripts": { "archive": "npx rimraf aws-lambda-ric-*.tgz && npm install && npm run build && npm pack", + "changelog": "node ./scripts/generate-changelog.js", + "changelog:update": "node ./scripts/generate-changelog.js --update", "clean": "npx rimraf build node_modules package-lock.json", "copy-files": "mkdir -p dist && cp src/types/* dist/", "update-deps": "./scripts/update_dependencies.sh", @@ -18,7 +20,10 @@ "format": "npm run format:src && npm run format:test", "format:src": "prettier --check \"src/*.*js\" --write", "format:test": "prettier --check \"test/**/*.*js\" --write", - "lint": "eslint --ext \".js\" src test", + "check-headers": "./scripts/check-headers.sh", + "add-headers": "./scripts/add-headers.sh", + "lint": "eslint --ext \".js\" src test && npm run check-headers", + "fix": "eslint --fix --ext \".js\" src test", "test": "npm run test:unit", "test:unit": "mocha --recursive ./test/unit --reporter ./test/util/StdoutReporter.test", @@ -63,6 +68,7 @@ "eslint": "8.42.0", "eslint-config-prettier": "8.8.0", "eslint-plugin-prettier": "4.2.1", + "husky": "^8.0.3", "lambda-runtime": "file:./src/", "mocha": "^10.8.2", diff --git a/scripts/add-headers.sh b/scripts/add-headers.sh new file mode 100755 index 00000000..4ffea2a9 --- /dev/null +++ b/scripts/add-headers.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 + +set -e + +script_dir="$(dirname "$0")" +files_modified=0 + +while IFS= read -r file; do + if ! grep -q 'Copyright.*Amazon\.com' "$file"; then + if [[ "$file" == *.sh ]]; then + sed "s|PLACEHOLDER|$file|" "$script_dir/patches/sh-files.patch" | git apply + else + sed "s|PLACEHOLDER|$file|" "$script_dir/patches/js-files.patch" | git apply + fi + files_modified=$((files_modified + 1)) + fi +done < <(git ls-files 'bin/**' 'scripts/**' 'src/**' 'test/**' | grep -E '\.(js|ts|mjs|mts|jsx|tsx|c|cpp|h|sh)$') + +if [ "$files_modified" -eq 0 ]; then + echo "✓ All files already have copyright headers" +else + echo "✓ Copyright headers added to $files_modified files" + echo "Run 'git diff' to review changes" +fi \ No newline at end of file diff --git a/scripts/check-headers.sh b/scripts/check-headers.sh new file mode 100755 index 00000000..6b69d8b0 --- /dev/null +++ b/scripts/check-headers.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 + +set -e + +missing_files=() + +while IFS= read -r file; do + if ! grep -q 'Copyright.*Amazon\.com' "$file"; then + missing_files+=("$file") + fi +done < <(git ls-files 'bin/**' 'scripts/**' 'src/**' 'test/**' | grep -E '\.(js|ts|mjs|mts|jsx|tsx|c|cpp|h|sh)$') + +if [ ${#missing_files[@]} -gt 0 ]; then + echo "❌ Copyright header check failed." + echo "Files missing headers:" + printf ' %s\n' "${missing_files[@]}" + echo + echo "Run 'npm run add-headers' to fix these files." + exit 1 +fi + +echo "✅ All files have proper copyright headers." \ No newline at end of file diff --git a/scripts/generate-changelog.js b/scripts/generate-changelog.js new file mode 100755 index 00000000..858914c0 --- /dev/null +++ b/scripts/generate-changelog.js @@ -0,0 +1,96 @@ +/* +Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +SPDX-License-Identifier: Apache-2.0 +*/ + +const { execSync } = require('child_process'); +const fs = require('fs'); +const path = require('path'); + +/** + * Script to generate and update changelog entries in RELEASE.CHANGELOG.md + * It automatically adds new entries when cutting a new tag + */ + +// Parse command line arguments +const args = process.argv.slice(2); +const updateFile = args.includes('--update'); +const outputFile = args.find((arg, i) => arg === '--output' && i + 1 < args.length) + ? args[args.indexOf('--output') + 1] + : null; + +// Get the last tag +let lastTag; +try { + lastTag = execSync('git describe --tags --abbrev=0').toString().trim(); + console.log(`Last tag: ${lastTag}`); +} catch (error) { + console.error('No tags found.'); + process.exit(1); +} + +// Get current version from package.json +const packageJson = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'package.json'), 'utf8')); +const version = packageJson.version; +console.log(`Current version: ${version}`); + +// Get commits since last tag +const gitLogFormat = '%h %s'; +const gitLog = execSync(`git log ${lastTag}..HEAD --pretty=format:"${gitLogFormat}"`).toString(); + +// Filter and format commits +const commits = gitLog.split('\n') + .filter(line => line.trim()) + .filter(line => { + // Filter out version commits + const message = line.substring(line.indexOf(' ') + 1); + return !/^v?\d+\.\d+\.\d+(-.*)?$/.test(message) && + !message.startsWith('working on ') && + !message.startsWith('Working on '); + }) + .map(line => { + const hash = line.substring(0, line.indexOf(' ')); + const message = line.substring(line.indexOf(' ') + 1); + + // Check for PR number in message + const prMatch = message.match(/\(#(\d+)\)|\(https:\/\/github\.com\/[^\/]+\/[^\/]+\/pull\/(\d+)\)/); + const prNumber = prMatch ? prMatch[1] || prMatch[2] : null; + + if (prNumber) { + return `- ${message} ([#${prNumber}](https://github.com/aws/aws-lambda-nodejs-runtime-interface-client/pull/${prNumber}))`; + } else { + return `- ${message}`; + } + }); + +// Generate changelog entry +const today = new Date(); +const formattedDate = `${today.toLocaleString('en-US', { month: 'short' })} ${today.getDate()}, ${today.getFullYear()}`; + +const changelogEntry = `### ${formattedDate} +\`${version}\` +${commits.join('\n')} + +`; + +// Output the changelog entry +if (outputFile) { + fs.writeFileSync(outputFile, changelogEntry); + console.log(`Changelog entry written to ${outputFile}`); +} else { + console.log('\nChangelog entry:'); + console.log(changelogEntry); +} + +// Update RELEASE.CHANGELOG.md if requested +if (updateFile) { + const changelogPath = path.join(process.cwd(), 'RELEASE.CHANGELOG.md'); + if (fs.existsSync(changelogPath)) { + const existingChangelog = fs.readFileSync(changelogPath, 'utf8'); + fs.writeFileSync(changelogPath, changelogEntry + existingChangelog); + console.log(`Updated ${changelogPath} with new entry`); + } else { + fs.writeFileSync(changelogPath, changelogEntry); + console.log(`Created ${changelogPath} with new entry`); + } +} \ No newline at end of file diff --git a/scripts/patches/js-files.patch b/scripts/patches/js-files.patch new file mode 100644 index 00000000..6f476e01 --- /dev/null +++ b/scripts/patches/js-files.patch @@ -0,0 +1,7 @@ +--- /dev/null ++++ b/PLACEHOLDER +@@ -0,0 +1,4 @@ ++/* ++Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. ++SPDX-License-Identifier: Apache-2.0 ++*/ \ No newline at end of file diff --git a/scripts/patches/sh-files.patch b/scripts/patches/sh-files.patch new file mode 100644 index 00000000..add3c434 --- /dev/null +++ b/scripts/patches/sh-files.patch @@ -0,0 +1,6 @@ +--- /dev/null ++++ b/PLACEHOLDER +@@ -0,0 +1,3 @@ ++#!/bin/bash ++# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. ++# SPDX-License-Identifier: Apache-2.0 \ No newline at end of file diff --git a/scripts/test_local.sh b/scripts/test_local.sh new file mode 100755 index 00000000..0674abd1 --- /dev/null +++ b/scripts/test_local.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 + +set -euo pipefail +trap 'echo "Error on line $LINENO"; exit 1' ERR + +echo "Running local unit tests for AWS Lambda NodeJS RIC" + +# Check if Docker is available +if ! command -v docker &> /dev/null; then + echo "Error: Docker is not installed or not in PATH" + echo "Please install Docker Desktop: https://www.docker.com/products/docker-desktop/" + exit 1 +fi + +# Check if Docker daemon is running +if ! docker info &> /dev/null; then + echo "Error: Docker daemon is not running" + echo "Please start Docker Desktop and wait for it to initialize" + exit 1 +fi + +# Function to run unit tests for specific Node version +run_unit_tests() { + local node_version=$1 + echo "Running unit tests for Node.js $node_version..." + docker build -f test/unit/Dockerfile.nodejs${node_version}.x -t unit/nodejs.${node_version}x . || { + echo "Build failed for Node.js $node_version" + exit 1 + } + docker run --rm unit/nodejs.${node_version}x || { + echo "Tests failed for Node.js $node_version" + exit 1 + } +} + +# Parse command line arguments +case "${1:-all}" in + "unit") + NODE_VERSION=${2:-"20"} + run_unit_tests $NODE_VERSION + ;; + "all") + echo "Running unit tests for all Node versions..." + for version in 18 20 22; do + run_unit_tests $version + done + ;; + *) + echo "Usage: $0 [unit|all] [node_version]" + echo "Examples:" + echo " $0 unit 20 # Run unit tests for Node 20" + echo " $0 all # Run unit tests for all Node versions" + exit 1 + ;; +esac diff --git a/src/build.js b/src/build.js index cb7baf48..f7642f5d 100644 --- a/src/build.js +++ b/src/build.js @@ -28,22 +28,29 @@ const buildOneSet = (target) => { target, }); - // Keep backward compatibility for Node14 - if (process.version.startsWith('v14')) { - build({ - ...shared, - format: 'cjs', - entryPoints: ['UserFunction.js'], - banner: { - js: '(function (){', - }, - footer: { - js: '})();', - }, - outfile: `../dist/UserFunction.js`, - target, - }); - } + // Always build UserFunction.js + build({ + ...shared, + format: 'cjs', + entryPoints: ['UserFunction.js'], + banner: { + js: '(function (){', + }, + footer: { + js: '})();', + }, + outfile: `../dist/UserFunction.js`, + target, + }); + + // Copy rapid-client + fs.mkdirSync(`../dist`, { + recursive: true, + }); + fs.copyFileSync( + '../build/Release/rapid-client.node', + `../dist/rapid-client.node`, + ); }; -buildOneSet('node14.21.3'); +buildOneSet('node16.20.2'); diff --git a/src/types/awslambda.d.ts b/src/types/awslambda.d.ts index 1c5153ed..e87e0ee9 100644 --- a/src/types/awslambda.d.ts +++ b/src/types/awslambda.d.ts @@ -1,3 +1,8 @@ +/* +Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +SPDX-License-Identifier: Apache-2.0 +*/ + export class HttpResponseStream { static from(underlyingStream: any, prelude: any): any; } diff --git a/src/types/index.d.mts b/src/types/index.d.mts index e08f6b0d..6f588ce5 100644 --- a/src/types/index.d.mts +++ b/src/types/index.d.mts @@ -1 +1,6 @@ +/* +Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +SPDX-License-Identifier: Apache-2.0 +*/ + export function run(appRootOrHandler: any, handler?: string): Promise; \ No newline at end of file diff --git a/test/integration/codebuild-local/Dockerfile.agent b/test/integration/codebuild-local/Dockerfile.agent deleted file mode 100644 index e9a9ffe5..00000000 --- a/test/integration/codebuild-local/Dockerfile.agent +++ /dev/null @@ -1,5 +0,0 @@ -FROM amazonlinux:2 - -RUN amazon-linux-extras enable docker && \ - yum clean metadata && \ - yum install -y docker tar diff --git a/test/integration/codebuild-local/codebuild_build.sh b/test/integration/codebuild-local/codebuild_build.sh deleted file mode 100755 index a858d940..00000000 --- a/test/integration/codebuild-local/codebuild_build.sh +++ /dev/null @@ -1,206 +0,0 @@ -#!/bin/bash -# This file is copied from https://github.com/aws/aws-codebuild-docker-images/blob/f0912e4b16e427da35351fc102f0f56f4ceb938a/local_builds/codebuild_build.sh - -function allOSRealPath() { - if isOSWindows - then - path="" - case $1 in - .* ) path="$PWD/${1#./}" ;; - /* ) path="$1" ;; - * ) path="/$1" ;; - esac - - echo "/$path" | sed -e 's/\\/\//g' -e 's/://' -e 's/./\U&/3' - else - case $1 in - /* ) echo "$1"; exit;; - * ) echo "$PWD/${1#./}"; exit;; - esac - fi -} - -function isOSWindows() { - if [ $OSTYPE == "msys" ] - then - return 0 - else - return 1 - fi -} - -function usage { - echo "usage: codebuild_build.sh [-i image_name] [-a artifact_output_directory] [options]" - echo "Required:" - echo " -i Used to specify the customer build container image." - echo " -a Used to specify an artifact output directory." - echo "Options:" - echo " -l IMAGE Used to override the default local agent image." - echo " -r Used to specify a report output directory." - echo " -s Used to specify source information. Defaults to the current working directory for primary source." - echo " * First (-s) is for primary source" - echo " * Use additional (-s) in : format for secondary source" - echo " * For sourceIdentifier, use a value that is fewer than 128 characters and contains only alphanumeric characters and underscores" - echo " -c Use the AWS configuration and credentials from your local host. This includes ~/.aws and any AWS_* environment variables." - echo " -p Used to specify the AWS CLI Profile." - echo " -b FILE Used to specify a buildspec override file. Defaults to buildspec.yml in the source directory." - echo " -m Used to mount the source directory to the customer build container directly." - echo " -d Used to run the build container in docker privileged mode." - echo " -e FILE Used to specify a file containing environment variables." - echo " (-e) File format expectations:" - echo " * Each line is in VAR=VAL format" - echo " * Lines beginning with # are processed as comments and ignored" - echo " * Blank lines are ignored" - echo " * File can be of type .env or .txt" - echo " * There is no special handling of quotation marks, meaning they will be part of the VAL" - exit 1 -} - -image_flag=false -artifact_flag=false -awsconfig_flag=false -mount_src_dir_flag=false -docker_privileged_mode_flag=false - -while getopts "cmdi:a:r:s:b:e:l:p:h" opt; do - case $opt in - i ) image_flag=true; image_name=$OPTARG;; - a ) artifact_flag=true; artifact_dir=$OPTARG;; - r ) report_dir=$OPTARG;; - b ) buildspec=$OPTARG;; - c ) awsconfig_flag=true;; - m ) mount_src_dir_flag=true;; - d ) docker_privileged_mode_flag=true;; - s ) source_dirs+=("$OPTARG");; - e ) environment_variable_file=$OPTARG;; - l ) local_agent_image=$OPTARG;; - p ) aws_profile=$OPTARG;; - h ) usage; exit;; - \? ) echo "Unknown option: -$OPTARG" >&2; exit 1;; - : ) echo "Missing option argument for -$OPTARG" >&2; exit 1;; - * ) echo "Invalid option: -$OPTARG" >&2; exit 1;; - esac -done - -if ! $image_flag -then - echo "The image name flag (-i) must be included for a build to run" >&2 -fi - -if ! $artifact_flag -then - echo "The artifact directory (-a) must be included for a build to run" >&2 -fi - -if ! $image_flag || ! $artifact_flag -then - exit 1 -fi - -docker_command="docker run " -if isOSWindows -then - docker_command+="-v //var/run/docker.sock:/var/run/docker.sock -e " -else - docker_command+="-v /var/run/docker.sock:/var/run/docker.sock -e " -fi - -docker_command+="\"IMAGE_NAME=$image_name\" -e \ - \"ARTIFACTS=$(allOSRealPath "$artifact_dir")\"" - -if [ -n "$report_dir" ] -then - docker_command+=" -e \"REPORTS=$(allOSRealPath "$report_dir")\"" -fi - -if [ -z "$source_dirs" ] -then - docker_command+=" -e \"SOURCE=$(allOSRealPath "$PWD")\"" -else - for index in "${!source_dirs[@]}"; do - if [ $index -eq 0 ] - then - docker_command+=" -e \"SOURCE=$(allOSRealPath "${source_dirs[$index]}")\"" - else - identifier=${source_dirs[$index]%%:*} - src_dir=$(allOSRealPath "${source_dirs[$index]#*:}") - - docker_command+=" -e \"SECONDARY_SOURCE_$index=$identifier:$src_dir\"" - fi - done -fi - -if [ -n "$buildspec" ] -then - docker_command+=" -e \"BUILDSPEC=$(allOSRealPath "$buildspec")\"" -fi - -if [ -n "$environment_variable_file" ] -then - environment_variable_file_path=$(allOSRealPath "$environment_variable_file") - environment_variable_file_dir=$(dirname "$environment_variable_file_path") - environment_variable_file_basename=$(basename "$environment_variable_file") - docker_command+=" -v \"$environment_variable_file_dir:/LocalBuild/envFile/\" -e \"ENV_VAR_FILE=$environment_variable_file_basename\"" -fi - -if [ -n "$local_agent_image" ] -then - docker_command+=" -e \"LOCAL_AGENT_IMAGE_NAME=$local_agent_image\"" -fi - -if $awsconfig_flag -then - if [ -d "$HOME/.aws" ] - then - configuration_file_path=$(allOSRealPath "$HOME/.aws") - docker_command+=" -e \"AWS_CONFIGURATION=$configuration_file_path\"" - else - docker_command+=" -e \"AWS_CONFIGURATION=NONE\"" - fi - - if [ -n "$aws_profile" ] - then - docker_command+=" -e \"AWS_PROFILE=$aws_profile\"" - fi - - docker_command+="$(env | grep ^AWS_ | while read -r line; do echo " -e \"$line\""; done )" -fi - -if $mount_src_dir_flag -then - docker_command+=" -e \"MOUNT_SOURCE_DIRECTORY=TRUE\"" -fi - -if $docker_privileged_mode_flag -then - docker_command+=" -e \"DOCKER_PRIVILEGED_MODE=TRUE\"" -fi - -if isOSWindows -then - docker_command+=" -e \"INITIATOR=$USERNAME\"" -else - docker_command+=" -e \"INITIATOR=$USER\"" -fi - -if [ -n "$local_agent_image" ] -then - docker_command+=" $local_agent_image" -else - docker_command+=" public.ecr.aws/codebuild/local-builds:latest" -fi - -# Note we do not expose the AWS_SECRET_ACCESS_KEY or the AWS_SESSION_TOKEN -exposed_command=$docker_command -secure_variables=( "AWS_SECRET_ACCESS_KEY=" "AWS_SESSION_TOKEN=") -for variable in "${secure_variables[@]}" -do - exposed_command="$(echo $exposed_command | sed "s/\($variable\)[^ ]*/\1********\"/")" -done - -echo "Build Command:" -echo "" -echo $exposed_command -echo "" - -eval $docker_command diff --git a/test/integration/codebuild-local/test_all.sh b/test/integration/codebuild-local/test_all.sh deleted file mode 100755 index a911db53..00000000 --- a/test/integration/codebuild-local/test_all.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - -set -euo pipefail - -CODEBUILD_IMAGE_TAG="${CODEBUILD_IMAGE_TAG:-al2/x86_64/standard/3.0}" -DISTRO="${DISTRO:=""}" -DRYRUN="${DRYRUN-0}" - -function usage { - echo "usage: test_all.sh buildspec_yml_dir" - echo "Runs all buildspec build-matrix combinations via test_one.sh." - echo "Required:" - echo " buildspec_yml_dir Used to specify the CodeBuild buildspec template file." -} - -do_one_yaml() { - local -r YML="$1" - - OS_DISTRIBUTION=$(grep -oE 'OS_DISTRIBUTION:\s*(\S+)' "$YML" | cut -d' ' -f2) - DISTRO_VERSIONS=$(sed '1,/DISTRO_VERSION/d;/RUNTIME_VERSION/,$d' "$YML" | tr -d '\-" ') - RUNTIME_VERSIONS=$(sed '1,/RUNTIME_VERSION/d;/phases/,$d' "$YML" | sed '/#.*$/d' | tr -d '\-" ') - - for DISTRO_VERSION in $DISTRO_VERSIONS ; do - for RUNTIME_VERSION in $RUNTIME_VERSIONS ; do - if (( DRYRUN == 1 )) ; then - echo DRYRUN test_one_combination "$YML" "$OS_DISTRIBUTION" "$DISTRO_VERSION" "$RUNTIME_VERSION" - else - test_one_combination "$YML" "$OS_DISTRIBUTION" "$DISTRO_VERSION" "$RUNTIME_VERSION" - fi - done - done -} - -test_one_combination() { - local -r YML="$1" - local -r OS_DISTRIBUTION="$2" - local -r DISTRO_VERSION="$3" - local -r RUNTIME_VERSION="$4" - - echo Testing: - echo " BUILDSPEC" "$YML" - echo " with" "$OS_DISTRIBUTION"-"$DISTRO_VERSION" "$RUNTIME_VERSION" - - "$(dirname "$0")"/test_one.sh "$YML" "$OS_DISTRIBUTION" "$DISTRO_VERSION" "$RUNTIME_VERSION" \ - > >(sed "s/^/$OS_DISTRIBUTION$DISTRO_VERSION-$RUNTIME_VERSION: /") 2> >(sed "s/^/$OS_DISTRIBUTION-$DISTRO_VERSION:$RUNTIME_VERSION: /" >&2) -} - -main() { - if (( $# != 1 && $# != 2)); then - >&2 echo "Invalid number of parameters." - usage - exit 1 - fi - - BUILDSPEC_YML_DIR="$1" - HAS_YML=0 - for f in "$BUILDSPEC_YML_DIR"/*"$DISTRO"*.yml ; do - [ -f "$f" ] || continue; - do_one_yaml "$f" - HAS_YML=1 - done - - if (( HAS_YML == 0 )); then - >&2 echo At least one buildspec is required. - exit 2 - fi -} - -main "$@" diff --git a/test/integration/codebuild-local/test_one.sh b/test/integration/codebuild-local/test_one.sh deleted file mode 100755 index 22c2f90c..00000000 --- a/test/integration/codebuild-local/test_one.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash -# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - -set -euo pipefail - -CODEBUILD_IMAGE_TAG="${CODEBUILD_IMAGE_TAG:-al2/x86_64/standard/3.0}" - -function usage { - >&2 echo "usage: test_one.sh buildspec_yml os_distribution distro_version runtime_version [env]" - >&2 echo "Runs one buildspec version combination from a build-matrix buildspec." - >&2 echo "Required:" - >&2 echo " buildspec_yml Used to specify the CodeBuild buildspec template file." - >&2 echo " os_distribution Used to specify the OS distribution to build." - >&2 echo " distro_version Used to specify the distro version of ." - >&2 echo " runtime_version Used to specify the runtime version to test on the selected ." - >&2 echo "Optional:" - >&2 echo " env Additional environment variables file." -} - -main() { - if (( $# != 3 && $# != 4)); then - >&2 echo "Invalid number of parameters." - usage - exit 1 - fi - - BUILDSPEC_YML="$1" - OS_DISTRIBUTION="$2" - DISTRO_VERSION="$3" - RUNTIME_VERSION="$4" - EXTRA_ENV="${5-}" - - CODEBUILD_TEMP_DIR=$(mktemp -d codebuild."$OS_DISTRIBUTION"-"$DISTRO_VERSION"-"$RUNTIME_VERSION".XXXXXXXXXX) - trap 'rm -rf $CODEBUILD_TEMP_DIR' EXIT - - # Create an env file for codebuild_build. - ENVFILE="$CODEBUILD_TEMP_DIR/.env" - if [ -f "$EXTRA_ENV" ]; then - cat "$EXTRA_ENV" > "$ENVFILE" - fi - { - echo "" - echo "OS_DISTRIBUTION=$OS_DISTRIBUTION" - echo "DISTRO_VERSION=$DISTRO_VERSION" - echo "RUNTIME_VERSION=$RUNTIME_VERSION" - } >> "$ENVFILE" - - ARTIFACTS_DIR="$CODEBUILD_TEMP_DIR/artifacts" - mkdir -p "$ARTIFACTS_DIR" - - # Run CodeBuild local agent. - "$(dirname "$0")"/codebuild_build.sh \ - -i "$CODEBUILD_IMAGE_TAG" \ - -a "$ARTIFACTS_DIR" \ - -e "$ENVFILE" \ - -b "$BUILDSPEC_YML" -} - -main "$@" diff --git a/test/integration/codebuild/buildspec.os.alpine.1.yml b/test/integration/codebuild/buildspec.os.alpine.1.yml deleted file mode 100644 index e4c14cd8..00000000 --- a/test/integration/codebuild/buildspec.os.alpine.1.yml +++ /dev/null @@ -1,111 +0,0 @@ -version: 0.2 - -env: - variables: - OS_DISTRIBUTION: alpine - NPX_BINARY_LOCATION: "/usr/local/bin/npx" -batch: - build-matrix: - static: - ignore-failure: false - env: - privileged-mode: true - dynamic: - env: - variables: - DISTRO_VERSION: - - "3.16" - RUNTIME_VERSION: - - "16" - - "18" -phases: - pre_build: - commands: - - export IMAGE_TAG="nodejs-${OS_DISTRIBUTION}-${DISTRO_VERSION}:${RUNTIME_VERSION}" - - echo "Extracting and including the Runtime Interface Emulator" - - SCRATCH_DIR=".scratch" - - mkdir "${SCRATCH_DIR}" - - ARCHITECTURE=$(arch) - - > - if [[ "$ARCHITECTURE" == "x86_64" ]]; then - RIE="aws-lambda-rie" - elif [[ "$ARCHITECTURE" == "aarch64" ]]; then - RIE="aws-lambda-rie-arm64" - else - echo "Architecture $ARCHITECTURE is not currently supported." - exit 1 - fi - - tar -xvf test/integration/resources/${RIE}.tar.gz --directory "${SCRATCH_DIR}" - - > - cp "test/integration/docker/Dockerfile.echo.${OS_DISTRIBUTION}" \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - echo "RUN apk add curl" >> \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - if [[ -z "${DOCKERHUB_USERNAME}" && -z "${DOCKERHUB_PASSWORD}" ]]; - then - echo "DockerHub credentials not set as CodeBuild environment variables. Continuing without docker login." - else - echo "Performing DockerHub login . . ." - docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD - fi - - echo "Building image ${IMAGE_TAG}" - - > - docker build . \ - -f "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" \ - -t "${IMAGE_TAG}" \ - --build-arg RUNTIME_VERSION="${RUNTIME_VERSION}" \ - --build-arg DISTRO_VERSION="${DISTRO_VERSION}" - build: - commands: - - set -x - - echo "Running Image ${IMAGE_TAG}" - - docker network create "${OS_DISTRIBUTION}-network" - - > - docker run \ - --detach \ - --name "${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c "/usr/bin/${RIE} ${NPX_BINARY_LOCATION} aws-lambda-ric index.handler" - - sleep 2 - - > - docker run \ - --name "${OS_DISTRIBUTION}-tester" \ - --env "TARGET=${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c 'curl -X POST "http://${TARGET}:8080/2015-03-31/functions/function/invocations" -d "{}" --max-time 10' - - actual="$(docker logs --tail 1 "${OS_DISTRIBUTION}-tester" | xargs)" - - expected='success' - - | - echo "Response: ${actual}" - if [[ "$actual" != "$expected" ]]; then - echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" - exit -1 - fi - finally: - - | - echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------" - echo - docker logs "${OS_DISTRIBUTION}-app" || true - echo - echo "---------------------------------------------------" - echo "--------Container Logs: ${OS_DISTRIBUTION}-tester--------" - echo - docker logs "${OS_DISTRIBUTION}-tester" || true - echo - echo "---------------------------------------------------" - - echo "Cleaning up..." - - docker stop "${OS_DISTRIBUTION}-app" || true - - docker rm --force "${OS_DISTRIBUTION}-app" || true - - docker stop "${OS_DISTRIBUTION}-tester" || true - - docker rm --force "${OS_DISTRIBUTION}-tester" || true - - docker network rm "${OS_DISTRIBUTION}-network" || true - - docker rmi "${IMAGE_TAG}" || true diff --git a/test/integration/codebuild/buildspec.os.alpine.2.yml b/test/integration/codebuild/buildspec.os.alpine.2.yml deleted file mode 100644 index a4528465..00000000 --- a/test/integration/codebuild/buildspec.os.alpine.2.yml +++ /dev/null @@ -1,102 +0,0 @@ -version: 0.2 - -env: - variables: - OS_DISTRIBUTION: alpine - NODE_BINARY_LOCATION: "/usr/local/bin/node" - NPX_BINARY_LOCATION: "/usr/local/bin/npx" -batch: - build-matrix: - static: - ignore-failure: false - env: - type: LINUX_CONTAINER - privileged-mode: true - dynamic: - env: - variables: - DISTRO_VERSION: - - "3.18" - RUNTIME_VERSION: - - "20" -phases: - pre_build: - commands: - - export IMAGE_TAG="nodejs-${OS_DISTRIBUTION}-${DISTRO_VERSION}:${RUNTIME_VERSION}" - - echo "Extracting and including the Runtime Interface Emulator" - - SCRATCH_DIR=".scratch" - - mkdir "${SCRATCH_DIR}" - - tar -xvf test/integration/resources/aws-lambda-rie.tar.gz --directory "${SCRATCH_DIR}" - - > - cp "test/integration/docker/Dockerfile.programmatic.${OS_DISTRIBUTION}" \ - "${SCRATCH_DIR}/Dockerfile.programmatic.${OS_DISTRIBUTION}.tmp" - - > - echo "RUN apk add curl" >> \ - "${SCRATCH_DIR}/Dockerfile.programmatic.${OS_DISTRIBUTION}.tmp" - - > - echo "COPY ${SCRATCH_DIR}/aws-lambda-rie /usr/bin/aws-lambda-rie" >> \ - "${SCRATCH_DIR}/Dockerfile.programmatic.${OS_DISTRIBUTION}.tmp" - - > - if [[ -z "${DOCKERHUB_USERNAME}" && -z "${DOCKERHUB_PASSWORD}" ]]; - then - echo "DockerHub credentials not set as CodeBuild environment variables. Continuing without docker login." - else - echo "Performing DockerHub login . . ." - docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD - fi - - echo "Building image ${IMAGE_TAG}" - - > - docker build . \ - -f "${SCRATCH_DIR}/Dockerfile.programmatic.${OS_DISTRIBUTION}.tmp" \ - -t "${IMAGE_TAG}" \ - --build-arg RUNTIME_VERSION="${RUNTIME_VERSION}" \ - --build-arg DISTRO_VERSION="${DISTRO_VERSION}" - build: - commands: - - set -x - - echo "Running Image ${IMAGE_TAG}" - - docker network create "${OS_DISTRIBUTION}-network" - - > - docker run \ - --detach \ - -e "NODE_BINARY_LOCATION=${NODE_BINARY_LOCATION}" \ - --name "${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c '/usr/bin/aws-lambda-rie ${NODE_BINARY_LOCATION} index.mjs' - - sleep 2 - - > - docker run \ - --name "${OS_DISTRIBUTION}-tester" \ - --env "TARGET=${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c 'curl -X POST "http://${TARGET}:8080/2015-03-31/functions/function/invocations" -d "{}" --max-time 10' - - actual="$(docker logs --tail 1 "${OS_DISTRIBUTION}-tester" | xargs)" - - expected='success' - - | - echo "Response: ${actual}" - if [[ "$actual" != "$expected" ]]; then - echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" - echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------" - echo - docker logs "${OS_DISTRIBUTION}-app" - echo - echo "---------------------------------------------------" - echo "--------Container Logs: ${OS_DISTRIBUTION}-tester--------" - echo - docker logs "${OS_DISTRIBUTION}-tester" - echo - echo "---------------------------------------------------" - exit -1 - fi - finally: - - echo "Cleaning up..." - - docker stop "${OS_DISTRIBUTION}-app" || true - - docker rm --force "${OS_DISTRIBUTION}-app" || true - - docker stop "${OS_DISTRIBUTION}-tester" || true - - docker rm --force "${OS_DISTRIBUTION}-tester" || true - - docker network rm "${OS_DISTRIBUTION}-network" || true - - docker rmi "${IMAGE_TAG}" || true diff --git a/test/integration/codebuild/buildspec.os.alpine.3.yml b/test/integration/codebuild/buildspec.os.alpine.3.yml deleted file mode 100644 index 3f567878..00000000 --- a/test/integration/codebuild/buildspec.os.alpine.3.yml +++ /dev/null @@ -1,113 +0,0 @@ -version: 0.2 - -env: - variables: - OS_DISTRIBUTION: alpine - NPX_BINARY_LOCATION: "/usr/local/bin/npx" -batch: - build-matrix: - static: - ignore-failure: false - env: - privileged-mode: true - dynamic: - env: - variables: - DISTRO_VERSION: - - "3.17" - - "3.18" - RUNTIME_VERSION: - - "16" - - "18" - - "20" -phases: - pre_build: - commands: - - export IMAGE_TAG="nodejs-${OS_DISTRIBUTION}-${DISTRO_VERSION}:${RUNTIME_VERSION}" - - echo "Extracting and including the Runtime Interface Emulator" - - SCRATCH_DIR=".scratch" - - mkdir "${SCRATCH_DIR}" - - ARCHITECTURE=$(arch) - - > - if [[ "$ARCHITECTURE" == "x86_64" ]]; then - RIE="aws-lambda-rie" - elif [[ "$ARCHITECTURE" == "aarch64" ]]; then - RIE="aws-lambda-rie-arm64" - else - echo "Architecture $ARCHITECTURE is not currently supported." - exit 1 - fi - - tar -xvf test/integration/resources/${RIE}.tar.gz --directory "${SCRATCH_DIR}" - - > - cp "test/integration/docker/Dockerfile.echo.${OS_DISTRIBUTION}" \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - echo "RUN apk add curl" >> \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - if [[ -z "${DOCKERHUB_USERNAME}" && -z "${DOCKERHUB_PASSWORD}" ]]; - then - echo "DockerHub credentials not set as CodeBuild environment variables. Continuing without docker login." - else - echo "Performing DockerHub login . . ." - docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD - fi - - echo "Building image ${IMAGE_TAG}" - - > - docker build . \ - -f "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" \ - -t "${IMAGE_TAG}" \ - --build-arg RUNTIME_VERSION="${RUNTIME_VERSION}" \ - --build-arg DISTRO_VERSION="${DISTRO_VERSION}" - build: - commands: - - set -x - - echo "Running Image ${IMAGE_TAG}" - - docker network create "${OS_DISTRIBUTION}-network" - - > - docker run \ - --detach \ - --name "${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c "/usr/bin/${RIE} ${NPX_BINARY_LOCATION} aws-lambda-ric index.handler" - - sleep 2 - - > - docker run \ - --name "${OS_DISTRIBUTION}-tester" \ - --env "TARGET=${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c 'curl -X POST "http://${TARGET}:8080/2015-03-31/functions/function/invocations" -d "{}" --max-time 10' - - actual="$(docker logs --tail 1 "${OS_DISTRIBUTION}-tester" | xargs)" - - expected='success' - - | - echo "Response: ${actual}" - if [[ "$actual" != "$expected" ]]; then - echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" - exit -1 - fi - finally: - - | - echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------" - echo - docker logs "${OS_DISTRIBUTION}-app" || true - echo - echo "---------------------------------------------------" - echo "--------Container Logs: ${OS_DISTRIBUTION}-tester--------" - echo - docker logs "${OS_DISTRIBUTION}-tester" || true - echo - echo "---------------------------------------------------" - - echo "Cleaning up..." - - docker stop "${OS_DISTRIBUTION}-app" || true - - docker rm --force "${OS_DISTRIBUTION}-app" || true - - docker stop "${OS_DISTRIBUTION}-tester" || true - - docker rm --force "${OS_DISTRIBUTION}-tester" || true - - docker network rm "${OS_DISTRIBUTION}-network" || true - - docker rmi "${IMAGE_TAG}" || true diff --git a/test/integration/codebuild/buildspec.os.amazonlinux.2.yml b/test/integration/codebuild/buildspec.os.amazonlinux.2.yml deleted file mode 100644 index 9426db59..00000000 --- a/test/integration/codebuild/buildspec.os.amazonlinux.2.yml +++ /dev/null @@ -1,109 +0,0 @@ -version: 0.2 - -env: - variables: - OS_DISTRIBUTION: amazonlinux - NPX_BINARY_LOCATION: "/usr/bin/npx" -batch: - build-matrix: - static: - ignore-failure: false - env: - privileged-mode: true - dynamic: - env: - variables: - DISTRO_VERSION: - - "2" - RUNTIME_VERSION: - - "14" - - "16" -phases: - pre_build: - commands: - - export IMAGE_TAG="nodejs-${OS_DISTRIBUTION}-${DISTRO_VERSION}:${RUNTIME_VERSION}" - - echo "Extracting and including the Runtime Interface Emulator" - - SCRATCH_DIR=".scratch" - - mkdir "${SCRATCH_DIR}" - - ARCHITECTURE=$(arch) - - > - if [[ "$ARCHITECTURE" == "x86_64" ]]; then - RIE="aws-lambda-rie" - elif [[ "$ARCHITECTURE" == "aarch64" ]]; then - RIE="aws-lambda-rie-arm64" - else - echo "Architecture $ARCHITECTURE is not currently supported." - exit 1 - fi - - tar -xvf test/integration/resources/${RIE}.tar.gz --directory "${SCRATCH_DIR}" - - > - cp "test/integration/docker/Dockerfile.echo.${OS_DISTRIBUTION}" \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - if [[ -z "${DOCKERHUB_USERNAME}" && -z "${DOCKERHUB_PASSWORD}" ]]; - then - echo "DockerHub credentials not set as CodeBuild environment variables. Continuing without docker login." - else - echo "Performing DockerHub login . . ." - docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD - fi - - echo "Building image ${IMAGE_TAG}" - - > - docker build . \ - -f "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" \ - -t "${IMAGE_TAG}" \ - --build-arg RUNTIME_VERSION="${RUNTIME_VERSION}" \ - --build-arg DISTRO_VERSION="${DISTRO_VERSION}" \ - --build-arg ARCHITECTURE="${ARCHITECTURE}" - build: - commands: - - set -x - - echo "Running Image ${IMAGE_TAG}" - - docker network create "${OS_DISTRIBUTION}-network" - - > - docker run \ - --detach \ - --name "${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c "/usr/bin/${RIE} ${NPX_BINARY_LOCATION} aws-lambda-ric index.handler" - - sleep 2 - - > - docker run \ - --name "${OS_DISTRIBUTION}-tester" \ - --env "TARGET=${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c 'curl -X POST "http://${TARGET}:8080/2015-03-31/functions/function/invocations" -d "{}" --max-time 10' - - actual="$(docker logs --tail 1 "${OS_DISTRIBUTION}-tester" | xargs)" - - expected='success' - - | - echo "Response: ${actual}" - if [[ "$actual" != "$expected" ]]; then - echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" - exit -1 - fi - finally: - - | - echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------" - echo - docker logs "${OS_DISTRIBUTION}-app" || true - echo - echo "---------------------------------------------------" - echo "--------Container Logs: ${OS_DISTRIBUTION}-tester--------" - echo - docker logs "${OS_DISTRIBUTION}-tester" || true - echo - echo "---------------------------------------------------" - - echo "Cleaning up..." - - docker stop "${OS_DISTRIBUTION}-app" || true - - docker rm --force "${OS_DISTRIBUTION}-app" || true - - docker stop "${OS_DISTRIBUTION}-tester" || true - - docker rm --force "${OS_DISTRIBUTION}-tester" || true - - docker network rm "${OS_DISTRIBUTION}-network" || true - - docker rmi "${IMAGE_TAG}" || true diff --git a/test/integration/codebuild/buildspec.os.amazonlinux.2023.yml b/test/integration/codebuild/buildspec.os.amazonlinux.2023.yml deleted file mode 100644 index bdda5692..00000000 --- a/test/integration/codebuild/buildspec.os.amazonlinux.2023.yml +++ /dev/null @@ -1,109 +0,0 @@ -version: 0.2 - -env: - variables: - OS_DISTRIBUTION: amazonlinux - NPX_BINARY_LOCATION: "/usr/bin/npx" -batch: - build-matrix: - static: - ignore-failure: false - env: - privileged-mode: true - dynamic: - env: - variables: - DISTRO_VERSION: - - "2023" - RUNTIME_VERSION: - - "18" - - "20" -phases: - pre_build: - commands: - - export IMAGE_TAG="nodejs-${OS_DISTRIBUTION}-${DISTRO_VERSION}:${RUNTIME_VERSION}" - - echo "Extracting and including the Runtime Interface Emulator" - - SCRATCH_DIR=".scratch" - - mkdir "${SCRATCH_DIR}" - - ARCHITECTURE=$(arch) - - > - if [[ "$ARCHITECTURE" == "x86_64" ]]; then - RIE="aws-lambda-rie" - elif [[ "$ARCHITECTURE" == "aarch64" ]]; then - RIE="aws-lambda-rie-arm64" - else - echo "Architecture $ARCHITECTURE is not currently supported." - exit 1 - fi - - tar -xvf test/integration/resources/${RIE}.tar.gz --directory "${SCRATCH_DIR}" - - > - cp "test/integration/docker/Dockerfile.echo.${OS_DISTRIBUTION}" \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - if [[ -z "${DOCKERHUB_USERNAME}" && -z "${DOCKERHUB_PASSWORD}" ]]; - then - echo "DockerHub credentials not set as CodeBuild environment variables. Continuing without docker login." - else - echo "Performing DockerHub login . . ." - docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD - fi - - echo "Building image ${IMAGE_TAG}" - - > - docker build . \ - -f "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" \ - -t "${IMAGE_TAG}" \ - --build-arg RUNTIME_VERSION="${RUNTIME_VERSION}" \ - --build-arg DISTRO_VERSION="${DISTRO_VERSION}" \ - --build-arg ARCHITECTURE="${ARCHITECTURE}" - build: - commands: - - set -x - - echo "Running Image ${IMAGE_TAG}" - - docker network create "${OS_DISTRIBUTION}-network" - - > - docker run \ - --detach \ - --name "${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c "/usr/bin/${RIE} ${NPX_BINARY_LOCATION} aws-lambda-ric index.handler" - - sleep 2 - - > - docker run \ - --name "${OS_DISTRIBUTION}-tester" \ - --env "TARGET=${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c 'curl -X POST "http://${TARGET}:8080/2015-03-31/functions/function/invocations" -d "{}" --max-time 10' - - actual="$(docker logs --tail 1 "${OS_DISTRIBUTION}-tester" | xargs)" - - expected='success' - - | - echo "Response: ${actual}" - if [[ "$actual" != "$expected" ]]; then - echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" - exit -1 - fi - finally: - - | - echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------" - echo - docker logs "${OS_DISTRIBUTION}-app" || true - echo - echo "---------------------------------------------------" - echo "--------Container Logs: ${OS_DISTRIBUTION}-tester--------" - echo - docker logs "${OS_DISTRIBUTION}-tester" || true - echo - echo "---------------------------------------------------" - - echo "Cleaning up..." - - docker stop "${OS_DISTRIBUTION}-app" || true - - docker rm --force "${OS_DISTRIBUTION}-app" || true - - docker stop "${OS_DISTRIBUTION}-tester" || true - - docker rm --force "${OS_DISTRIBUTION}-tester" || true - - docker network rm "${OS_DISTRIBUTION}-network" || true - - docker rmi "${IMAGE_TAG}" || true diff --git a/test/integration/codebuild/buildspec.os.centos.yml b/test/integration/codebuild/buildspec.os.centos.yml deleted file mode 100644 index f3be37e2..00000000 --- a/test/integration/codebuild/buildspec.os.centos.yml +++ /dev/null @@ -1,109 +0,0 @@ -version: 0.2 - -env: - variables: - OS_DISTRIBUTION: centos - NPX_BINARY_LOCATION: "/usr/bin/npx" -batch: - build-matrix: - static: - ignore-failure: false - env: - privileged-mode: true - dynamic: - env: - variables: - DISTRO_VERSION: - - "stream9" - RUNTIME_VERSION: - - "18" - - "20" -phases: - pre_build: - commands: - - export IMAGE_TAG="nodejs-${OS_DISTRIBUTION}-${DISTRO_VERSION}:${RUNTIME_VERSION}" - - echo "Extracting and including the Runtime Interface Emulator" - - SCRATCH_DIR=".scratch" - - mkdir "${SCRATCH_DIR}" - - ARCHITECTURE=$(arch) - - > - if [[ "$ARCHITECTURE" == "x86_64" ]]; then - RIE="aws-lambda-rie" - elif [[ "$ARCHITECTURE" == "aarch64" ]]; then - RIE="aws-lambda-rie-arm64" - else - echo "Architecture $ARCHITECTURE is not currently supported." - exit 1 - fi - - tar -xvf test/integration/resources/${RIE}.tar.gz --directory "${SCRATCH_DIR}" - - > - cp "test/integration/docker/Dockerfile.echo.${OS_DISTRIBUTION}" \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - if [[ -z "${DOCKERHUB_USERNAME}" && -z "${DOCKERHUB_PASSWORD}" ]]; - then - echo "DockerHub credentials not set as CodeBuild environment variables. Continuing without docker login." - else - echo "Performing DockerHub login . . ." - docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD - fi - - echo "Building image ${IMAGE_TAG}" - - > - docker build . \ - -f "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" \ - -t "${IMAGE_TAG}" \ - --build-arg RUNTIME_VERSION="${RUNTIME_VERSION}" \ - --build-arg DISTRO_VERSION="${DISTRO_VERSION}" \ - --build-arg ARCHITECTURE="${ARCHITECTURE}" - build: - commands: - - set -x - - echo "Running Image ${IMAGE_TAG}" - - docker network create "${OS_DISTRIBUTION}-network" - - > - docker run \ - --detach \ - --name "${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c "/usr/bin/${RIE} ${NPX_BINARY_LOCATION} aws-lambda-ric index.handler" - - sleep 2 - - > - docker run \ - --name "${OS_DISTRIBUTION}-tester" \ - --env "TARGET=${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c 'curl -X POST "http://${TARGET}:8080/2015-03-31/functions/function/invocations" -d "{}" --max-time 10' - - actual="$(docker logs --tail 1 "${OS_DISTRIBUTION}-tester" | xargs)" - - expected='success' - - | - echo "Response: ${actual}" - if [[ "$actual" != "$expected" ]]; then - echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" - exit -1 - fi - finally: - - | - echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------" - echo - docker logs "${OS_DISTRIBUTION}-app" || true - echo - echo "---------------------------------------------------" - echo "--------Container Logs: ${OS_DISTRIBUTION}-tester--------" - echo - docker logs "${OS_DISTRIBUTION}-tester" || true - echo - echo "---------------------------------------------------" - - echo "Cleaning up..." - - docker stop "${OS_DISTRIBUTION}-app" || true - - docker rm --force "${OS_DISTRIBUTION}-app" || true - - docker stop "${OS_DISTRIBUTION}-tester" || true - - docker rm --force "${OS_DISTRIBUTION}-tester" || true - - docker network rm "${OS_DISTRIBUTION}-network" || true - - docker rmi "${IMAGE_TAG}" || true diff --git a/test/integration/codebuild/buildspec.os.debian.1.yml b/test/integration/codebuild/buildspec.os.debian.1.yml deleted file mode 100644 index 82ea6bda..00000000 --- a/test/integration/codebuild/buildspec.os.debian.1.yml +++ /dev/null @@ -1,112 +0,0 @@ -version: 0.2 - -env: - variables: - OS_DISTRIBUTION: debian - NPX_BINARY_LOCATION: "/usr/local/bin/npx" -batch: - build-matrix: - static: - ignore-failure: false - env: - privileged-mode: true - dynamic: - env: - variables: - DISTRO_VERSION: - - "buster" - - "bullseye" - RUNTIME_VERSION: - - "18" - - "20" -phases: - pre_build: - commands: - - export IMAGE_TAG="nodejs-${OS_DISTRIBUTION}-${DISTRO_VERSION}:${RUNTIME_VERSION}" - - echo "Extracting and including the Runtime Interface Emulator" - - SCRATCH_DIR=".scratch" - - mkdir "${SCRATCH_DIR}" - - ARCHITECTURE=$(arch) - - > - if [[ "$ARCHITECTURE" == "x86_64" ]]; then - RIE="aws-lambda-rie" - elif [[ "$ARCHITECTURE" == "aarch64" ]]; then - RIE="aws-lambda-rie-arm64" - else - echo "Architecture $ARCHITECTURE is not currently supported." - exit 1 - fi - - tar -xvf test/integration/resources/${RIE}.tar.gz --directory "${SCRATCH_DIR}" - - > - cp "test/integration/docker/Dockerfile.echo.${OS_DISTRIBUTION}" \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - if [[ -z "${DOCKERHUB_USERNAME}" && -z "${DOCKERHUB_PASSWORD}" ]]; - then - echo "DockerHub credentials not set as CodeBuild environment variables. Continuing without docker login." - else - echo "Performing DockerHub login . . ." - docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD - fi - - > - echo "RUN apt-get update && apt-get install -y curl" >> \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - echo "Building image ${IMAGE_TAG}" - - > - docker build . \ - -f "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" \ - -t "${IMAGE_TAG}" \ - --build-arg RUNTIME_VERSION="${RUNTIME_VERSION}" \ - --build-arg DISTRO_VERSION="${DISTRO_VERSION}" - build: - commands: - - set -x - - echo "Running Image ${IMAGE_TAG}" - - docker network create "${OS_DISTRIBUTION}-network" - - > - docker run \ - --detach \ - --name "${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c "/usr/bin/${RIE} ${NPX_BINARY_LOCATION} aws-lambda-ric index.handler" - - sleep 2 - - > - docker run \ - --name "${OS_DISTRIBUTION}-tester" \ - --env "TARGET=${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c 'curl -X POST "http://${TARGET}:8080/2015-03-31/functions/function/invocations" -d "{}" --max-time 10' - - actual="$(docker logs --tail 1 "${OS_DISTRIBUTION}-tester" | xargs)" - - expected='success' - - | - echo "Response: ${actual}" - if [[ "$actual" != "$expected" ]]; then - echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" - exit -1 - fi - finally: - - | - echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------" - echo - docker logs "${OS_DISTRIBUTION}-app" || true - echo - echo "---------------------------------------------------" - echo "--------Container Logs: ${OS_DISTRIBUTION}-tester--------" - echo - docker logs "${OS_DISTRIBUTION}-tester" || true - echo - echo "---------------------------------------------------" - - echo "Cleaning up..." - - docker stop "${OS_DISTRIBUTION}-app" || true - - docker rm --force "${OS_DISTRIBUTION}-app" || true - - docker stop "${OS_DISTRIBUTION}-tester" || true - - docker rm --force "${OS_DISTRIBUTION}-tester" || true - - docker network rm "${OS_DISTRIBUTION}-network" || true - - docker rmi "${IMAGE_TAG}" || true diff --git a/test/integration/codebuild/buildspec.os.debian.2.yml b/test/integration/codebuild/buildspec.os.debian.2.yml deleted file mode 100644 index 0f2c0c39..00000000 --- a/test/integration/codebuild/buildspec.os.debian.2.yml +++ /dev/null @@ -1,111 +0,0 @@ -version: 0.2 - -env: - variables: - OS_DISTRIBUTION: debian - NPX_BINARY_LOCATION: "/usr/local/bin/npx" -batch: - build-matrix: - static: - ignore-failure: false - env: - privileged-mode: true - dynamic: - env: - variables: - DISTRO_VERSION: - - "bookworm" - RUNTIME_VERSION: - - "18" - - "20" -phases: - pre_build: - commands: - - export IMAGE_TAG="nodejs-${OS_DISTRIBUTION}-${DISTRO_VERSION}:${RUNTIME_VERSION}" - - echo "Extracting and including the Runtime Interface Emulator" - - SCRATCH_DIR=".scratch" - - mkdir "${SCRATCH_DIR}" - - ARCHITECTURE=$(arch) - - > - if [[ "$ARCHITECTURE" == "x86_64" ]]; then - RIE="aws-lambda-rie" - elif [[ "$ARCHITECTURE" == "aarch64" ]]; then - RIE="aws-lambda-rie-arm64" - else - echo "Architecture $ARCHITECTURE is not currently supported." - exit 1 - fi - - tar -xvf test/integration/resources/${RIE}.tar.gz --directory "${SCRATCH_DIR}" - - > - cp "test/integration/docker/Dockerfile.echo.${OS_DISTRIBUTION}" \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - if [[ -z "${DOCKERHUB_USERNAME}" && -z "${DOCKERHUB_PASSWORD}" ]]; - then - echo "DockerHub credentials not set as CodeBuild environment variables. Continuing without docker login." - else - echo "Performing DockerHub login . . ." - docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD - fi - - > - echo "RUN apt-get update && apt-get install -y curl" >> \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - echo "Building image ${IMAGE_TAG}" - - > - docker build . \ - -f "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" \ - -t "${IMAGE_TAG}" \ - --build-arg RUNTIME_VERSION="${RUNTIME_VERSION}" \ - --build-arg DISTRO_VERSION="${DISTRO_VERSION}" - build: - commands: - - set -x - - echo "Running Image ${IMAGE_TAG}" - - docker network create "${OS_DISTRIBUTION}-network" - - > - docker run \ - --detach \ - --name "${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c "/usr/bin/${RIE} ${NPX_BINARY_LOCATION} aws-lambda-ric index.handler" - - sleep 2 - - > - docker run \ - --name "${OS_DISTRIBUTION}-tester" \ - --env "TARGET=${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c 'curl -X POST "http://${TARGET}:8080/2015-03-31/functions/function/invocations" -d "{}" --max-time 10' - - actual="$(docker logs --tail 1 "${OS_DISTRIBUTION}-tester" | xargs)" - - expected='success' - - | - echo "Response: ${actual}" - if [[ "$actual" != "$expected" ]]; then - echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" - exit -1 - fi - finally: - - | - echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------" - echo - docker logs "${OS_DISTRIBUTION}-app" || true - echo - echo "---------------------------------------------------" - echo "--------Container Logs: ${OS_DISTRIBUTION}-tester--------" - echo - docker logs "${OS_DISTRIBUTION}-tester" || true - echo - echo "---------------------------------------------------" - - echo "Cleaning up..." - - docker stop "${OS_DISTRIBUTION}-app" || true - - docker rm --force "${OS_DISTRIBUTION}-app" || true - - docker stop "${OS_DISTRIBUTION}-tester" || true - - docker rm --force "${OS_DISTRIBUTION}-tester" || true - - docker network rm "${OS_DISTRIBUTION}-network" || true - - docker rmi "${IMAGE_TAG}" || true diff --git a/test/integration/codebuild/buildspec.os.ubuntu.1.yml b/test/integration/codebuild/buildspec.os.ubuntu.1.yml deleted file mode 100644 index 3875078a..00000000 --- a/test/integration/codebuild/buildspec.os.ubuntu.1.yml +++ /dev/null @@ -1,109 +0,0 @@ -version: 0.2 - -env: - variables: - OS_DISTRIBUTION: ubuntu - NPX_BINARY_LOCATION: "/usr/bin/npx" -batch: - build-matrix: - static: - ignore-failure: false - env: - privileged-mode: true - dynamic: - env: - variables: - DISTRO_VERSION: - - "20.04" - - "22.04" - RUNTIME_VERSION: - - "18" -phases: - pre_build: - commands: - - export IMAGE_TAG="nodejs-${OS_DISTRIBUTION}-${DISTRO_VERSION}:${RUNTIME_VERSION}" - - echo "Extracting and including the Runtime Interface Emulator" - - SCRATCH_DIR=".scratch" - - mkdir "${SCRATCH_DIR}" - - ARCHITECTURE=$(arch) - - > - if [[ "$ARCHITECTURE" == "x86_64" ]]; then - RIE="aws-lambda-rie" - elif [[ "$ARCHITECTURE" == "aarch64" ]]; then - RIE="aws-lambda-rie-arm64" - else - echo "Architecture $ARCHITECTURE is not currently supported." - exit 1 - fi - - tar -xvf test/integration/resources/${RIE}.tar.gz --directory "${SCRATCH_DIR}" - - > - cp "test/integration/docker/Dockerfile.echo.${OS_DISTRIBUTION}" \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - if [[ -z "${DOCKERHUB_USERNAME}" && -z "${DOCKERHUB_PASSWORD}" ]]; - then - echo "DockerHub credentials not set as CodeBuild environment variables. Continuing without docker login." - else - echo "Performing DockerHub login . . ." - docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD - fi - - echo "Building image ${IMAGE_TAG}" - - > - docker build . \ - -f "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" \ - -t "${IMAGE_TAG}" \ - --build-arg RUNTIME_VERSION="${RUNTIME_VERSION}" \ - --build-arg DISTRO_VERSION="${DISTRO_VERSION}" \ - --build-arg ARCHITECTURE="${ARCHITECTURE}" - build: - commands: - - set -x - - echo "Running Image ${IMAGE_TAG}" - - docker network create "${OS_DISTRIBUTION}-network" - - > - docker run \ - --detach \ - --name "${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c "/usr/bin/${RIE} ${NPX_BINARY_LOCATION} aws-lambda-ric index.handler" - - sleep 2 - - > - docker run \ - --name "${OS_DISTRIBUTION}-tester" \ - --env "TARGET=${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c 'curl -X POST "http://${TARGET}:8080/2015-03-31/functions/function/invocations" -d "{}" --max-time 10' - - actual="$(docker logs --tail 1 "${OS_DISTRIBUTION}-tester" | xargs)" - - expected='success' - - | - echo "Response: ${actual}" - if [[ "$actual" != "$expected" ]]; then - echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" - exit -1 - fi - finally: - - | - echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------" - echo - docker logs "${OS_DISTRIBUTION}-app" || true - echo - echo "---------------------------------------------------" - echo "--------Container Logs: ${OS_DISTRIBUTION}-tester--------" - echo - docker logs "${OS_DISTRIBUTION}-tester" || true - echo - echo "---------------------------------------------------" - - echo "Cleaning up..." - - docker stop "${OS_DISTRIBUTION}-app" || true - - docker rm --force "${OS_DISTRIBUTION}-app" || true - - docker stop "${OS_DISTRIBUTION}-tester" || true - - docker rm --force "${OS_DISTRIBUTION}-tester" || true - - docker network rm "${OS_DISTRIBUTION}-network" || true - - docker rmi "${IMAGE_TAG}" || true diff --git a/test/integration/codebuild/buildspec.os.ubuntu.2.yml b/test/integration/codebuild/buildspec.os.ubuntu.2.yml deleted file mode 100644 index 95f6b226..00000000 --- a/test/integration/codebuild/buildspec.os.ubuntu.2.yml +++ /dev/null @@ -1,110 +0,0 @@ -version: 0.2 - -env: - variables: - OS_DISTRIBUTION: ubuntu - NPX_BINARY_LOCATION: "/usr/bin/npx" -batch: - build-matrix: - static: - ignore-failure: false - env: - privileged-mode: true - dynamic: - env: - variables: - DISTRO_VERSION: - - "20.04" - - "22.04" - RUNTIME_VERSION: - - "18" - - "20" -phases: - pre_build: - commands: - - export IMAGE_TAG="nodejs-${OS_DISTRIBUTION}-${DISTRO_VERSION}:${RUNTIME_VERSION}" - - echo "Extracting and including the Runtime Interface Emulator" - - SCRATCH_DIR=".scratch" - - mkdir "${SCRATCH_DIR}" - - ARCHITECTURE=$(arch) - - > - if [[ "$ARCHITECTURE" == "x86_64" ]]; then - RIE="aws-lambda-rie" - elif [[ "$ARCHITECTURE" == "aarch64" ]]; then - RIE="aws-lambda-rie-arm64" - else - echo "Architecture $ARCHITECTURE is not currently supported." - exit 1 - fi - - tar -xvf test/integration/resources/${RIE}.tar.gz --directory "${SCRATCH_DIR}" - - > - cp "test/integration/docker/Dockerfile.echo.${OS_DISTRIBUTION}" \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - if [[ -z "${DOCKERHUB_USERNAME}" && -z "${DOCKERHUB_PASSWORD}" ]]; - then - echo "DockerHub credentials not set as CodeBuild environment variables. Continuing without docker login." - else - echo "Performing DockerHub login . . ." - docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD - fi - - echo "Building image ${IMAGE_TAG}" - - > - docker build . \ - -f "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" \ - -t "${IMAGE_TAG}" \ - --build-arg RUNTIME_VERSION="${RUNTIME_VERSION}" \ - --build-arg DISTRO_VERSION="${DISTRO_VERSION}" \ - --build-arg ARCHITECTURE="${ARCHITECTURE}" - build: - commands: - - set -x - - echo "Running Image ${IMAGE_TAG}" - - docker network create "${OS_DISTRIBUTION}-network" - - > - docker run \ - --detach \ - --name "${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c "/usr/bin/${RIE} ${NPX_BINARY_LOCATION} aws-lambda-ric index.handler" - - sleep 2 - - > - docker run \ - --name "${OS_DISTRIBUTION}-tester" \ - --env "TARGET=${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c 'curl -X POST "http://${TARGET}:8080/2015-03-31/functions/function/invocations" -d "{}" --max-time 10' - - actual="$(docker logs --tail 1 "${OS_DISTRIBUTION}-tester" | xargs)" - - expected='success' - - | - echo "Response: ${actual}" - if [[ "$actual" != "$expected" ]]; then - echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" - exit -1 - fi - finally: - - | - echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------" - echo - docker logs "${OS_DISTRIBUTION}-app" || true - echo - echo "---------------------------------------------------" - echo "--------Container Logs: ${OS_DISTRIBUTION}-tester--------" - echo - docker logs "${OS_DISTRIBUTION}-tester" || true - echo - echo "---------------------------------------------------" - - echo "Cleaning up..." - - docker stop "${OS_DISTRIBUTION}-app" || true - - docker rm --force "${OS_DISTRIBUTION}-app" || true - - docker stop "${OS_DISTRIBUTION}-tester" || true - - docker rm --force "${OS_DISTRIBUTION}-tester" || true - - docker network rm "${OS_DISTRIBUTION}-network" || true - - docker rmi "${IMAGE_TAG}" || true diff --git a/test/integration/docker/Dockerfile.echo.alpine b/test/integration/docker/Dockerfile.echo.alpine deleted file mode 100644 index 10f1aab4..00000000 --- a/test/integration/docker/Dockerfile.echo.alpine +++ /dev/null @@ -1,68 +0,0 @@ -# Define global args -ARG FUNCTION_DIR="/home/app/" -ARG RUNTIME_VERSION -ARG DISTRO_VERSION - -# Stage 1 - build function and dependencies -FROM node:${RUNTIME_VERSION}-alpine${DISTRO_VERSION} AS build-image -# Include global arg in this stage of the build -ARG DISTRO_VERSION -# Install aws-lambda-cpp build dependencies -RUN apk add --update-cache \ - build-base \ - libtool \ - musl-dev \ - libressl-dev \ - libffi-dev \ - autoconf \ - automake \ - make \ - cmake \ - python3 \ - libcurl - -# AWS Lambda CPP and libcurl rely on backtrace which requires libexecinfo from Alpine. -# Since starting from Alpine3.17 libexecinfo is no longer available, temporarily source it from Alpine3.16 -# while awaiting an upstream resolution in AWS Lambda CPP. -RUN if [[ "${DISTRO_VERSION}" == "3.17" ]] || [[ "${DISTRO_VERSION}" == "3.18" ]] ; \ -then \ - apk add --update-cache --repository=https://dl-cdn.alpinelinux.org/alpine/v3.16/main/ libexecinfo-dev ; \ -else \ - apk add --update-cache libexecinfo-dev ; \ -fi - -# Include global arg in this stage of the build -ARG FUNCTION_DIR -# Create function directory -RUN mkdir -p ${FUNCTION_DIR} - -# Copy & build Runtime Interface Client package (as we're installing it from a local filesystem source) -WORKDIR ${FUNCTION_DIR}/deps/aws-lambda-ric -COPY . . - -RUN make build && \ - npm run test:unit - -# Copy function code -COPY test/integration/test-handlers/echo/* ${FUNCTION_DIR} -# Install the function's dependencies -WORKDIR ${FUNCTION_DIR} -RUN npm install - - -# Stage 2 - final runtime image -# Grab a fresh copy of the Node image -FROM node:${RUNTIME_VERSION}-alpine${DISTRO_VERSION} - -# Required for Node runtimes which use npm@8.6.0+ because -# by default npm writes logs under /home/.npm and Lambda fs is read-only -ENV NPM_CONFIG_CACHE=/tmp/.npm -# Include global arg in this stage of the build -ARG FUNCTION_DIR -# Set working directory to function root directory -WORKDIR ${FUNCTION_DIR} -# Copy in the built dependencies -COPY --from=build-image ${FUNCTION_DIR} ${FUNCTION_DIR} - -ENTRYPOINT [ "/usr/local/bin/npx", "aws-lambda-ric" ] -CMD [ "index.handler" ] diff --git a/test/integration/docker/Dockerfile.echo.amazonlinux b/test/integration/docker/Dockerfile.echo.amazonlinux deleted file mode 100644 index b54956df..00000000 --- a/test/integration/docker/Dockerfile.echo.amazonlinux +++ /dev/null @@ -1,83 +0,0 @@ -# Define global args -ARG FUNCTION_DIR="/home/app/" -ARG RUNTIME_VERSION -ARG DISTRO_VERSION - -# Stage 1 - bundle base image + runtime -# Grab a fresh copy of the image and install Node -FROM amazonlinux:${DISTRO_VERSION} AS node-amazonlinux -# Include global arg in this stage of the build -ARG RUNTIME_VERSION -ARG DISTRO_VERSION -# Install Py3 required to build Node16+ -RUN if [[ "${DISTRO_VERSION}" == "2" ]] ; then amazon-linux-extras install python3.8 && update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1 ; fi -# Install NodeJS -RUN if [[ "${RUNTIME_VERSION}" == "14" ]]; then \ - yum install -y tar gzip xz && \ - AARCH="$([[ "$(arch)" == "x86_64" ]] && echo "x64" || echo "arm64")" && \ - NODE_URL="https://nodejs.org/download/release/v14.21.3/node-v14.21.3-linux-$AARCH.tar.xz" && \ - curl -fL "$NODE_URL" | tar -C /usr --strip-components 1 -xJf - && \ - yum clean all -q && rm -rf /var/cache/yum ; \ -else \ - yum install https://rpm.nodesource.com/pub_${RUNTIME_VERSION}.x/nodistro/repo/nodesource-release-nodistro-1.noarch.rpm -y && \ - yum install nodejs -y --setopt=nodesource-nodejs.module_hotfixes=1s ; \ -fi - -# Stage 2 - build function and dependencies -FROM node-amazonlinux AS build-image -ARG ARCHITECTURE -# Install aws-lambda-cpp build dependencies -RUN yum install -y \ - tar \ - gzip \ - make \ - wget \ - autoconf \ - automake \ - libtool \ - libcurl-devel \ - gcc-c++ -# Install a modern CMake -RUN wget --quiet -O cmake-install https://github.com/Kitware/CMake/releases/download/v3.20.0/cmake-3.20.0-linux-${ARCHITECTURE}.sh && \ - sh cmake-install --skip-license --prefix=/usr --exclude-subdirectory; - -# Include global arg in this stage of the build -ARG FUNCTION_DIR -# Create function directory -RUN mkdir -p ${FUNCTION_DIR} - -# Copy & build Runtime Interface Client package (as we're installing it from a local filesystem source) -WORKDIR ${FUNCTION_DIR}/deps/aws-lambda-ric -COPY . . - -# Node14 uses npm@6.14.18 by default which will downgrade permissions, if it's root, -# before running any build scripts: https://github.com/npm/npm/issues/3497 -# Starting from npm@7.0.0, when npm is run as root, -# scripts are always run with the effective uid and gid of the working directory owner. -RUN if [[ $(node -v | cut -c 1-3) == "v14" ]] ; then npm install -g npm@7 ; fi -RUN make build && \ - npm run test:unit - -# Copy function code -COPY test/integration/test-handlers/echo/* ${FUNCTION_DIR} -# Install the function's dependencies -WORKDIR ${FUNCTION_DIR} -RUN npm install - - -# Stage 3 - final runtime image -# Grab a fresh copy of the Node image -FROM node-amazonlinux - -# Required for Node runtimes which use npm@8.6.0+ because -# by default npm writes logs under /home/.npm and Lambda fs is read-only -ENV NPM_CONFIG_CACHE=/tmp/.npm -# Include global arg in this stage of the build -ARG FUNCTION_DIR -# Set working directory to function root directory -WORKDIR ${FUNCTION_DIR} -# Copy in the built dependencies -COPY --from=build-image ${FUNCTION_DIR} ${FUNCTION_DIR} - -ENTRYPOINT [ "/usr/bin/npx", "aws-lambda-ric" ] -CMD [ "index.handler" ] diff --git a/test/integration/docker/Dockerfile.echo.centos b/test/integration/docker/Dockerfile.echo.centos deleted file mode 100644 index 778b5560..00000000 --- a/test/integration/docker/Dockerfile.echo.centos +++ /dev/null @@ -1,68 +0,0 @@ -# Define global args -ARG FUNCTION_DIR="/home/app/" -ARG RUNTIME_VERSION -ARG DISTRO_VERSION - -# Stage 1 - bundle base image + runtime -# Grab a fresh copy of the image and install Node -FROM quay.io/centos/centos:${DISTRO_VERSION} AS node-centos -# Include global arg in this stage of the build -ARG RUNTIME_VERSION -# Install NodeJS -RUN yum module enable -y nodejs:${RUNTIME_VERSION} && \ - yum install -y nodejs - - -# Stage 2 - build function and dependencies -FROM node-centos AS build-image -ARG ARCHITECTURE -# Install aws-lambda-cpp build dependencies -RUN yum install -y \ - tar \ - gzip \ - make \ - wget \ - autoconf \ - automake \ - libtool \ - libcurl-devel \ - gcc-c++ -# Install a modern CMake -RUN wget --quiet -O cmake-install https://github.com/Kitware/CMake/releases/download/v3.20.0/cmake-3.20.0-linux-${ARCHITECTURE}.sh && \ - sh cmake-install --skip-license --prefix=/usr --exclude-subdirectory; - -# Include global arg in this stage of the build -ARG FUNCTION_DIR -# Create function directory -RUN mkdir -p ${FUNCTION_DIR} - -# Copy & build Runtime Interface Client package (as we're installing it from a local filesystem source) -WORKDIR ${FUNCTION_DIR}/deps/aws-lambda-ric -COPY . . - -RUN make build && \ - npm run test:unit - -# Copy function code -COPY test/integration/test-handlers/echo/* ${FUNCTION_DIR} -# Install the function's dependencies -WORKDIR ${FUNCTION_DIR} -RUN npm install - - -# Stage 3 - final runtime image -# Grab a fresh copy of the Node image -FROM node-centos - -# Required for Node runtimes which use npm@8.6.0+ because -# by default npm writes logs under /home/.npm and Lambda fs is read-only -ENV NPM_CONFIG_CACHE=/tmp/.npm -# Include global arg in this stage of the build -ARG FUNCTION_DIR -# Set working directory to function root directory -WORKDIR ${FUNCTION_DIR} -# Copy in the built dependencies -COPY --from=build-image ${FUNCTION_DIR} ${FUNCTION_DIR} - -ENTRYPOINT [ "/usr/bin/npx", "aws-lambda-ric" ] -CMD [ "index.handler" ] diff --git a/test/integration/docker/Dockerfile.echo.debian b/test/integration/docker/Dockerfile.echo.debian deleted file mode 100644 index a611d8f3..00000000 --- a/test/integration/docker/Dockerfile.echo.debian +++ /dev/null @@ -1,50 +0,0 @@ -# Define global args -ARG FUNCTION_DIR="/home/app/" -ARG RUNTIME_VERSION -ARG DISTRO_VERSION - -# Stage 1 - build function and dependencies -FROM node:${RUNTIME_VERSION}-${DISTRO_VERSION} AS build-image -# Install aws-lambda-cpp build dependencies -RUN apt-get update && \ - apt-get install -y \ - g++ \ - make \ - cmake \ - libcurl4-openssl-dev - -# Include global arg in this stage of the build -ARG FUNCTION_DIR -# Create function directory -RUN mkdir -p ${FUNCTION_DIR} - -# Copy & build Runtime Interface Client package (as we're installing it from a local filesystem source) -WORKDIR ${FUNCTION_DIR}/deps/aws-lambda-ric -COPY . . - -RUN make build && \ - npm run test:unit - -# Copy function code -COPY test/integration/test-handlers/echo/* ${FUNCTION_DIR} -# Install the function's dependencies -WORKDIR ${FUNCTION_DIR} -RUN npm install - - -# Stage 2 - final runtime image -# Grab a fresh slim copy of the Node image -FROM node:${RUNTIME_VERSION}-${DISTRO_VERSION}-slim - -# Required for Node runtimes which use npm@8.6.0+ because -# by default npm writes logs under /home/.npm and Lambda fs is read-only -ENV NPM_CONFIG_CACHE=/tmp/.npm -# Include global arg in this stage of the build -ARG FUNCTION_DIR -# Set working directory to function root directory -WORKDIR ${FUNCTION_DIR} -# Copy in the built dependencies -COPY --from=build-image ${FUNCTION_DIR} ${FUNCTION_DIR} - -ENTRYPOINT [ "/usr/local/bin/npx", "aws-lambda-ric" ] -CMD [ "index.handler" ] diff --git a/test/integration/docker/Dockerfile.echo.ubuntu b/test/integration/docker/Dockerfile.echo.ubuntu deleted file mode 100644 index 567768bf..00000000 --- a/test/integration/docker/Dockerfile.echo.ubuntu +++ /dev/null @@ -1,77 +0,0 @@ -# Define global args -ARG FUNCTION_DIR="/home/app/" -ARG RUNTIME_VERSION -ARG DISTRO_VERSION - -# Stage 1 - bundle base image + runtime -# Grab a fresh copy of the image and install Node -FROM ubuntu:${DISTRO_VERSION} AS node-ubuntu -# Non-interactive mode -ENV DEBIAN_FRONTEND=noninteractive -# Install NodeJS -ARG RUNTIME_VERSION -RUN apt-get update && \ - apt-get install -y \ - curl && \ - curl -sL https://deb.nodesource.com/setup_${RUNTIME_VERSION}.x | bash - && \ - apt-get install -y nodejs - - -# Stage 2 - build function and dependencies -FROM node-ubuntu AS build-image -ARG ARCHITECTURE -# Install aws-lambda-cpp build dependencies -RUN apt-get update && \ - apt-get install -y \ - g++ \ - gcc \ - tar \ - curl \ - gzip \ - make \ - cmake \ - autoconf \ - automake \ - libtool \ - wget \ - libcurl4-openssl-dev \ - python3 -# Install a modern CMake -RUN wget --quiet -O cmake-install https://github.com/Kitware/CMake/releases/download/v3.20.0/cmake-3.20.0-linux-${ARCHITECTURE}.sh && \ - sh cmake-install --skip-license --prefix=/usr --exclude-subdirectory; - -# Include global arg in this stage of the build -ARG FUNCTION_DIR -# Create function directory -RUN mkdir -p ${FUNCTION_DIR} - -# Copy & build Runtime Interface Client package (as we're installing it from a local filesystem source) -WORKDIR ${FUNCTION_DIR}/deps/aws-lambda-ric -COPY . . - -RUN make build && \ - npm run test:unit - -# Copy function code -COPY test/integration/test-handlers/echo/* ${FUNCTION_DIR} -# Install the function's dependencies -WORKDIR ${FUNCTION_DIR} -RUN npm install - - -# Stage 3 - final runtime image -# Grab a fresh copy of the Node image -FROM node-ubuntu - -# Required for Node runtimes which use npm@8.6.0+ because -# by default npm writes logs under /home/.npm and Lambda fs is read-only -ENV NPM_CONFIG_CACHE=/tmp/.npm -# Include global arg in this stage of the build -ARG FUNCTION_DIR -# Set working directory to function root directory -WORKDIR ${FUNCTION_DIR} -# Copy in the built dependencies -COPY --from=build-image ${FUNCTION_DIR} ${FUNCTION_DIR} - -ENTRYPOINT [ "/usr/bin/npx", "aws-lambda-ric" ] -CMD [ "index.handler" ] diff --git a/test/integration/docker/Dockerfile.programmatic.alpine b/test/integration/docker/Dockerfile.programmatic.alpine deleted file mode 100644 index 5bcb4b7b..00000000 --- a/test/integration/docker/Dockerfile.programmatic.alpine +++ /dev/null @@ -1,67 +0,0 @@ -# Define global args -ARG FUNCTION_DIR="/home/app/" -ARG RUNTIME_VERSION -ARG DISTRO_VERSION - -# Stage 1 - build function and dependencies -FROM node:${RUNTIME_VERSION}-alpine${DISTRO_VERSION} AS build-image -# Include global arg in this stage of the build -ARG DISTRO_VERSION -# Install aws-lambda-cpp build dependencies -RUN apk add --update-cache \ - build-base \ - libtool \ - musl-dev \ - libressl-dev \ - libffi-dev \ - autoconf \ - automake \ - make \ - cmake \ - python3 \ - libcurl - -# AWS Lambda CPP and libcurl rely on backtrace which requires libexecinfo from Alpine. -# Since starting from Alpine3.17 libexecinfo is no longer available, temporarily source it from Alpine3.16 -# while awaiting an upstream resolution in AWS Lambda CPP. -RUN if [[ "${DISTRO_VERSION}" == "3.17" ]] || [[ "${DISTRO_VERSION}" == "3.18" ]] ; \ -then \ - apk add --update-cache --repository=https://dl-cdn.alpinelinux.org/alpine/v3.16/main/ libexecinfo-dev ; \ -else \ - apk add --update-cache libexecinfo-dev ; \ -fi - -# Include global arg in this stage of the build -ARG FUNCTION_DIR -# Create function directory -RUN mkdir -p ${FUNCTION_DIR} - -# Copy & build Runtime Interface Client package (as we're installing it from a local filesystem source) -WORKDIR ${FUNCTION_DIR}/deps/aws-lambda-ric -COPY . . - -RUN make build && \ - npm run test:unit - -# Copy function code -COPY test/integration/test-handlers/programmatic/* ${FUNCTION_DIR} -# Install the function's dependencies -WORKDIR ${FUNCTION_DIR} -RUN npm install - - -# Stage 2 - final runtime image -# Grab a fresh copy of the Node image -FROM node:${RUNTIME_VERSION}-alpine${DISTRO_VERSION} - -# Required for Node runtimes which use npm@8.6.0+ because -# by default npm writes logs under /home/.npm and Lambda fs is read-only -ENV NPM_CONFIG_CACHE=/tmp/.npm -# Include global arg in this stage of the build -ARG FUNCTION_DIR -# Set working directory to function root directory -WORKDIR ${FUNCTION_DIR} -# Copy in the built dependencies -COPY --from=build-image ${FUNCTION_DIR} ${FUNCTION_DIR} - -CMD [ "/usr/local/bin/node", "index.mjs" ] diff --git a/test/integration/resources/aws-lambda-rie-arm64.tar.gz b/test/integration/resources/aws-lambda-rie-arm64.tar.gz deleted file mode 100644 index 57878e2b..00000000 Binary files a/test/integration/resources/aws-lambda-rie-arm64.tar.gz and /dev/null differ diff --git a/test/integration/resources/aws-lambda-rie.tar.gz b/test/integration/resources/aws-lambda-rie.tar.gz deleted file mode 100644 index 2553eaa3..00000000 Binary files a/test/integration/resources/aws-lambda-rie.tar.gz and /dev/null differ diff --git a/test/integration/test-handlers/echo/index.js b/test/integration/test-handlers/echo/index.js deleted file mode 100644 index ff988d38..00000000 --- a/test/integration/test-handlers/echo/index.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -exports.handler = async (event, context) => { - console.log('hello world'); - return 'success'; -}; diff --git a/test/integration/test-handlers/echo/package.json b/test/integration/test-handlers/echo/package.json deleted file mode 100644 index 7d320212..00000000 --- a/test/integration/test-handlers/echo/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "echo-hanlder", - "version": "1.0.0", - "description": "Sample Lambda echo handler for NodeJS", - "author": "AWS Lambda", - "license": "Apache-2.0", - "dependencies": { - "aws-lambda-ric": "file:deps/aws-lambda-ric" - } -} diff --git a/test/integration/test-handlers/programmatic/index.mjs b/test/integration/test-handlers/programmatic/index.mjs deleted file mode 100644 index 8d3d85a5..00000000 --- a/test/integration/test-handlers/programmatic/index.mjs +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -import { run } from 'aws-lambda-ric'; - -const echo = async (event, context) => { - console.log('hello world'); - return 'success'; -}; - -await run(echo); diff --git a/test/integration/test-handlers/programmatic/package.json b/test/integration/test-handlers/programmatic/package.json deleted file mode 100644 index 95b0c3f3..00000000 --- a/test/integration/test-handlers/programmatic/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "programmatic-hanlder", - "version": "1.0.0", - "description": "Sample Lambda echo handler for NodeJS", - "author": "AWS Lambda", - "license": "Apache-2.0", - "dependencies": { - "aws-lambda-ric": "file:deps/aws-lambda-ric" - } -}