Skip to content

Commit cf37ff6

Browse files
authored
Add more Nodejs runtime test workflow (#1028)
1 parent 4872c8c commit cf37ff6

File tree

2 files changed

+135
-17
lines changed

2 files changed

+135
-17
lines changed

Diff for: .github/workflows/main-build-nodejs.yml

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: NodeJS Layer Integration Test
2+
on:
3+
workflow_call:
4+
inputs:
5+
caller-workflow-name:
6+
required: true
7+
type: string
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: main-build-nodejs-${{ github.ref_name }}
12+
cancel-in-progress: true
13+
14+
permissions:
15+
id-token: write
16+
contents: read
17+
18+
jobs:
19+
integration-test:
20+
runs-on: ubuntu-22.04
21+
name: nodejs-wrapper-${{ matrix.architecture }}
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
architecture: [ amd64, arm64 ]
26+
runtime: [nodejs16.x, nodejs18.x]
27+
steps:
28+
- uses: actions/checkout@v4
29+
with:
30+
submodules: recursive
31+
- uses: actions/setup-go@v5
32+
with:
33+
go-version: '~1.21.10'
34+
check-latest: true
35+
- uses: actions/setup-node@v4
36+
with:
37+
node-version: '16'
38+
- name: Cache (NodeJS)
39+
uses: actions/cache@v4
40+
with:
41+
path: |
42+
~/go/pkg/mod
43+
~/.npm
44+
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}-go-${{ hashFiles('**/go.sum') }}
45+
restore-keys: |
46+
${{ runner.os }}-node-
47+
- uses: aws-actions/[email protected]
48+
with:
49+
role-to-assume: ${{ secrets.INTEG_TEST_LAMBDA_ROLE_ARN }}
50+
role-duration-seconds: 7200
51+
aws-region: us-east-1
52+
- name: Generate UUID
53+
id: generate-uuid
54+
run: |
55+
UUID=$(uuidgen | cut -c1-4)
56+
echo "uuid=$UUID" >> $GITHUB_OUTPUT
57+
- name: Patch ADOT
58+
run: ./patch-upstream.sh
59+
- name: Login to Public ECR
60+
uses: docker/login-action@v3
61+
with:
62+
registry: public.ecr.aws
63+
- name: Build layers / functions
64+
run: GOARCH=${{ matrix.architecture }} ./build.sh ${{ matrix.architecture }}
65+
working-directory: nodejs
66+
- name: Get Lambda Layer amd64 architecture value
67+
if: ${{ matrix.architecture == 'amd64' }}
68+
run: echo LAMBDA_FUNCTION_ARCH=x86_64 | tee --append $GITHUB_ENV
69+
- name: Get Lambda Layer arm64 architecture value
70+
if: ${{ matrix.architecture == 'arm64' }}
71+
run: echo LAMBDA_FUNCTION_ARCH=arm64 | tee --append $GITHUB_ENV
72+
- name: Get terraform directory
73+
run: |
74+
echo TERRAFORM_DIRECTORY=nodejs/integration-tests/aws-sdk/wrapper |
75+
tee --append $GITHUB_ENV
76+
- uses: hashicorp/setup-terraform@v2
77+
- name: Initialize terraform
78+
run: terraform init
79+
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
80+
- name: Get terraform Lambda function name
81+
run: |
82+
echo TERRAFORM_LAMBDA_FUNCTION_NAME=lambda-nodejs-${{ matrix.architecture }}-${{ steps.generate-uuid.outputs.uuid }} |
83+
tee --append $GITHUB_ENV
84+
- name: Apply terraform
85+
run: terraform apply -auto-approve
86+
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
87+
env:
88+
TF_VAR_sdk_layer_name: otel-nodejs-aws-sdk-wrapper-${{ matrix.architecture }}
89+
TF_VAR_function_name: ${{ env.TERRAFORM_LAMBDA_FUNCTION_NAME }}
90+
TF_VAR_architecture: ${{ env.LAMBDA_FUNCTION_ARCH }}
91+
TF_VAR_runtime: ${{ matrix.runtime }}
92+
- name: Extract endpoint
93+
id: extract-endpoint
94+
run: terraform output -raw api-gateway-url
95+
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
96+
- name: Extract SDK layer arn
97+
id: extract-sdk-layer-arn
98+
run: terraform output -raw sdk_layer_arn
99+
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
100+
- name: Output annotations
101+
run: |
102+
echo "::warning::Function: ${{ env.TERRAFORM_LAMBDA_FUNCTION_NAME }}"
103+
echo "::warning::SDK Layer ARN: ${{ steps.extract-sdk-layer-arn.outputs.stdout }}"
104+
- name: Send request to endpoint
105+
run: curl -sS ${{ steps.extract-endpoint.outputs.stdout }}
106+
- name: Checkout test framework
107+
uses: actions/checkout@v4
108+
with:
109+
repository: aws-observability/aws-otel-test-framework
110+
path: test-framework
111+
- name: validate trace sample
112+
run: |
113+
cp adot/utils/expected-templates/nodejs-aws-sdk-wrapper.json \
114+
test-framework/validator/src/main/resources/expected-data-template/lambdaExpectedTrace.mustache
115+
cd test-framework
116+
./gradlew :validator:run --args="-c default-lambda-validation.yml --endpoint ${{ steps.extract-endpoint.outputs.stdout }} --region $AWS_REGION"
117+
- name: Destroy terraform
118+
if: always()
119+
run: terraform destroy -auto-approve
120+
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
121+
env:
122+
TF_VAR_architecture: ${{ env.LAMBDA_FUNCTION_ARCH }}

Diff for: .github/workflows/main-build.yml

+13-17
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
- '!.github/workflows/main-build.yml'
1111
- '!.github/workflows/main-build-python.yml'
1212
- '!.github/workflows/main-build-java.yml'
13+
- '!.github/workflows/main-build-nodejs.yml'
1314
- '**.md'
1415
workflow_dispatch:
1516

@@ -29,7 +30,7 @@ jobs:
2930
fail-fast: false
3031
matrix:
3132
architecture: [ amd64, arm64 ]
32-
language: [ dotnet, go, nodejs ]
33+
language: [ dotnet, go ]
3334
sample-app: [ aws-sdk ]
3435
instrumentation-type: [ wrapper ]
3536

@@ -41,20 +42,6 @@ jobs:
4142
with:
4243
go-version: '~1.21.10'
4344
check-latest: true
44-
- uses: actions/setup-node@v4
45-
if: ${{ matrix.language == 'nodejs' }}
46-
with:
47-
node-version: '16'
48-
- name: Cache (NodeJS)
49-
uses: actions/cache@v4
50-
if: ${{ matrix.language == 'nodejs' }}
51-
with:
52-
path: |
53-
~/go/pkg/mod
54-
~/.npm
55-
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}-go-${{ hashFiles('**/go.sum') }}
56-
restore-keys: |
57-
${{ runner.os }}-node-
5845
- uses: actions/setup-dotnet@v4
5946
if: ${{ matrix.language == 'dotnet' }}
6047
with:
@@ -146,16 +133,25 @@ jobs:
146133
with:
147134
caller-workflow-name: 'main-build'
148135

136+
nodejs-runtime-test:
137+
concurrency:
138+
group: nodejs-runtime-test
139+
cancel-in-progress: false
140+
uses: ./.github/workflows/main-build-nodejs.yml
141+
secrets: inherit
142+
with:
143+
caller-workflow-name: 'main-build'
144+
149145
publish-build-status:
150-
needs: [integration-test, python-runtime-test, java-runtime-test]
146+
needs: [integration-test, python-runtime-test, java-runtime-test, nodejs-runtime-test]
151147
if: ${{ always() }}
152148
uses: ./.github/workflows/publish-status.yml
153149
with:
154150
namespace: 'ADOT/GitHubActions'
155151
repository: ${{ github.repository }}
156152
branch: ${{ github.ref_name }}
157153
workflow: main-build
158-
success: ${{ needs.integration-test.result == 'success' && needs.python-runtime-test.result == 'success' && needs.java-runtime-test.result == 'success' }}
154+
success: ${{ needs.integration-test.result == 'success' && needs.python-runtime-test.result == 'success' && needs.java-runtime-test.result == 'success' && needs.nodejs-runtime-test == 'success' }}
159155
region: us-west-2
160156
secrets:
161157
roleArn: ${{ secrets.METRICS_ROLE_ARN }}

0 commit comments

Comments
 (0)