|
| 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 }} |
0 commit comments