Skip to content

Commit 51be34d

Browse files
author
Fabiana Severin
committed
Creating github actions workflow with publishing pipeline
1 parent a5ae1c2 commit 51be34d

File tree

2 files changed

+163
-0
lines changed

2 files changed

+163
-0
lines changed
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
branches: [ fabisev/artifact-publishing ]
6+
tags: [ 'v*' ]
7+
pull_request:
8+
branches: [ main ]
9+
10+
jobs:
11+
# lint:
12+
# runs-on: ubuntu-latest
13+
# steps:
14+
# - uses: actions/checkout@v4
15+
# - name: Setup Node.js
16+
# uses: actions/setup-node@v4
17+
# with:
18+
# node-version: '20'
19+
# cache: 'npm'
20+
# - name: Install and lint
21+
# run: |
22+
# npm ci
23+
# npm run lint
24+
# npm run format
25+
26+
build:
27+
runs-on: ubuntu-latest
28+
outputs:
29+
version: ${{ steps.version.outputs.version }}
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- name: Setup Node.js
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: '20'
37+
cache: 'npm'
38+
39+
- name: Get version
40+
id: version
41+
run: |
42+
BASE_VERSION=$(node -p "require('./package.json').version")
43+
VERSION="${BASE_VERSION}"
44+
echo "version=$VERSION" >> $GITHUB_OUTPUT
45+
46+
- name: Cache native dependencies
47+
uses: actions/cache@v4
48+
with:
49+
path: |
50+
deps/
51+
build/
52+
key: native-deps-${{ runner.os }}-${{ hashFiles('deps/versions', 'binding.gyp') }}
53+
54+
- name: Install and build
55+
run: |
56+
npm ci
57+
npm run build
58+
npm pack
59+
60+
- name: Generate checksums and signatures
61+
run: |
62+
PACKAGE_FILE=$(ls aws-lambda-ric-*.tgz)
63+
sha256sum $PACKAGE_FILE > checksums.sha256
64+
sha512sum $PACKAGE_FILE > checksums.sha512
65+
cat checksums.sha256 checksums.sha512 > checksums.txt
66+
echo "Package: $PACKAGE_FILE with version prefix: ${{ steps.version.outputs.version }}" >> checksums.txt
67+
68+
- name: Upload artifacts
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: package-${{ steps.version.outputs.version }}
72+
path: |
73+
aws-lambda-ric-*.tgz
74+
checksums.*
75+
retention-days: 30
76+
77+
test:
78+
runs-on: ubuntu-latest
79+
needs: [build] #don't forget to add lint later
80+
strategy:
81+
matrix:
82+
node-version: [18, 20, 22]
83+
steps:
84+
- uses: actions/checkout@v4
85+
86+
- name: Run unit tests - Node ${{ matrix.node-version }}
87+
run: |
88+
docker build -f test/unit/Dockerfile.nodejs${{ matrix.node-version }}.x -t unit/nodejs.${{ matrix.node-version }}x .
89+
docker run --rm unit/nodejs.${{ matrix.node-version }}x
90+
91+
92+
93+
publish:
94+
if: startsWith(github.ref, 'refs/tags/v')
95+
runs-on: ubuntu-latest
96+
needs: [build, test]
97+
permissions:
98+
contents: write
99+
steps:
100+
- uses: actions/checkout@v4
101+
102+
- name: Download artifacts
103+
uses: actions/download-artifact@v4
104+
with:
105+
name: package-${{ needs.build.outputs.version }}
106+
107+
- name: Verify checksums
108+
run: |
109+
sha256sum -c checksums.sha256
110+
sha512sum -c checksums.sha512
111+
112+
- name: Setup Node.js
113+
uses: actions/setup-node@v4
114+
with:
115+
node-version: '20'
116+
registry-url: 'https://registry.npmjs.org'
117+
118+
# - name: Publish to npm
119+
# run: npm publish aws-lambda-ric-*.tgz
120+
# env:
121+
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
122+
123+
- name: Create GitHub Release
124+
uses: softprops/action-gh-release@v2
125+
with:
126+
files: |
127+
aws-lambda-ric-*.tgz
128+
checksums.sha256
129+
checksums.sha512
130+
checksums.txt
131+
generate_release_notes: true

scripts/test_local.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
set -e
2+
3+
echo "Running local unit tests for AWS Lambda NodeJS RIC"
4+
5+
# Function to run unit tests for specific Node version
6+
run_unit_tests() {
7+
local node_version=$1
8+
echo "Running unit tests for Node.js $node_version..."
9+
docker build -f test/unit/Dockerfile.nodejs${node_version}.x -t unit/nodejs.${node_version}x .
10+
docker run --rm unit/nodejs.${node_version}x
11+
}
12+
13+
# Parse command line arguments
14+
case "${1:-all}" in
15+
"unit")
16+
NODE_VERSION=${2:-"20"}
17+
run_unit_tests $NODE_VERSION
18+
;;
19+
"all")
20+
echo "Running unit tests for all Node versions..."
21+
for version in 18 20 22; do
22+
run_unit_tests $version
23+
done
24+
;;
25+
*)
26+
echo "Usage: $0 [unit|all] [node_version]"
27+
echo "Examples:"
28+
echo " $0 unit 20 # Run unit tests for Node 20"
29+
echo " $0 all # Run unit tests for all Node versions"
30+
exit 1
31+
;;
32+
esac

0 commit comments

Comments
 (0)