1+ name : Build
2+
3+ on :
4+ push :
5+ branches : [ main ]
6+ pull_request :
7+ branches : [ main ]
8+
9+ permissions : {}
10+
11+ jobs :
12+ get-version :
13+ runs-on : ubuntu-latest
14+ permissions :
15+ contents : read
16+ outputs :
17+ version : ${{ steps.version.outputs.version }}
18+ steps :
19+ - uses : actions/checkout@v4
20+ - name : Get version
21+ id : version
22+ run : |
23+ BASE_VERSION=$(node -p "require('./package.json').version")
24+ echo "version=$BASE_VERSION" >> $GITHUB_OUTPUT
25+
26+ build :
27+ needs : [get-version]
28+ timeout-minutes : 30
29+ permissions :
30+ id-token : write
31+ contents : read
32+ strategy :
33+ matrix :
34+ include :
35+ - arch : x86_64
36+ runner : codebuild-project-awsaws-lambda-nodejs-runtime-interface-client-${{ github.run_id }}-${{ github.run_attempt }}
37+ - arch : aarch64
38+ runner : codebuild-project-awsaws-lambda-nodejs-runtime-interface-client-${{ github.run_id }}-${{ github.run_attempt }}
39+ runs-on : ${{ matrix.runner }}
40+ steps :
41+ - uses : actions/checkout@v4
42+
43+ - name : Setup Node.js
44+ uses : actions/setup-node@v4
45+ with :
46+ node-version : ' lts/*'
47+
48+ - name : Check copyright headers
49+ run : npm run check-headers
50+
51+ - name : Install build dependencies
52+ run : |
53+ apt-get update
54+ apt-get install -y cmake make g++ autotools-dev automake libtool
55+
56+ - name : Build natively for ${{ matrix.arch }}
57+ run : |
58+ echo "Building for architecture: ${{ matrix.arch }}"
59+
60+ # Build native dependencies and JavaScript
61+ BUILD=1 npm install
62+ npm run build
63+
64+ # Verify required files were created
65+ if [ ! -f "dist/rapid-client.node" ] || [ ! -f "dist/index.mjs" ] || [ ! -f "dist/UserFunction.js" ]; then
66+ echo "Error: Required files not found in dist directory"
67+ exit 1
68+ fi
69+
70+ # Copy architecture-specific package.json to dist
71+ node -e "
72+ const pkg = require('./package.json');
73+ pkg.name = 'aws-lambda-ric-${{ matrix.arch }}';
74+ require('fs').writeFileSync('./dist/package.json', JSON.stringify(pkg, null, 2));
75+ "
76+
77+ # Create tarball with only required files
78+ tar -czf aws-lambda-ric-${{ matrix.arch }}-${{ needs.get-version.outputs.version }}.tgz \
79+ -C dist package.json index.mjs UserFunction.js rapid-client.node
80+
81+ - name : Generate checksums
82+ run : |
83+ PACKAGE_FILE="aws-lambda-ric-${{ matrix.arch }}-${{ needs.get-version.outputs.version }}.tgz"
84+ sha256sum $PACKAGE_FILE > checksums-${{ matrix.arch }}.sha256
85+ sha512sum $PACKAGE_FILE > checksums-${{ matrix.arch }}.sha512
86+ echo "Package: $PACKAGE_FILE (${{ matrix.arch }}) with version: ${{ needs.get-version.outputs.version }}" > checksums-${{ matrix.arch }}.txt
87+
88+ - name : Upload artifacts
89+ uses : actions/upload-artifact@v4
90+ with :
91+ name : package-${{ matrix.arch }}-${{ needs.get-version.outputs.version }}
92+ path : |
93+ aws-lambda-ric-*-${{ needs.get-version.outputs.version }}.tgz
94+ checksums-*
95+ retention-days : 30
96+
97+ test :
98+ needs : [get-version, build]
99+ permissions :
100+ contents : read
101+ strategy :
102+ matrix :
103+ node-version : [18, 20, 22]
104+ include :
105+ - arch : x86_64
106+ runner : ubuntu-latest
107+ - arch : aarch64
108+ runner : ubuntu-latest
109+ runs-on : ${{ matrix.runner }}
110+ steps :
111+ - uses : actions/checkout@v4
112+
113+ - name : Run unit tests - Node ${{ matrix.node-version }} (native $(arch))
114+ run : |
115+ docker build \
116+ -f test/unit/Dockerfile.nodejs${{ matrix.node-version }}.x \
117+ -t unit/nodejs.${{ matrix.node-version }}x \
118+ .
119+ docker run --rm unit/nodejs.${{ matrix.node-version }}x
0 commit comments