diff --git a/.github/workflows/build-artifacts.yml b/.github/workflows/build-artifacts.yml index 7809c59..f68bbb4 100644 --- a/.github/workflows/build-artifacts.yml +++ b/.github/workflows/build-artifacts.yml @@ -90,6 +90,7 @@ jobs: name: ${{ env.ARTIFACT_NAME }}-${{ env.LANGUAGE }}-${{ matrix.architecture }}-artifacts path: ${{ env.LANGUAGE }}/${{ env.ARTIFACT_ARCHIVE_BASE_NAME }}-${{ matrix.architecture }}.zip if-no-files-found: error + overwrite: true - name: Rename sample-app java artifact if: env.LANGUAGE == 'java' && success() run: | @@ -102,6 +103,7 @@ jobs: name: sample-app-${{ env.LANGUAGE }}-${{ matrix.architecture }}-artifacts path: opentelemetry-lambda/${{ env.LANGUAGE }}/sample-apps/aws-sdk/build/libs/java-sample-app.jar if-no-files-found: error + overwrite: true - name: Upload artifacts - nodejs if: env.LANGUAGE == 'nodejs' && success() uses: actions/upload-artifact@v4 @@ -109,6 +111,7 @@ jobs: name: ${{ env.ARTIFACT_NAME }}-${{ env.LANGUAGE }}-${{ matrix.architecture }}-artifacts path: ${{ env.LANGUAGE }}/${{ env.ARTIFACT_ARCHIVE_BASE_NAME }}-${{ matrix.architecture }}.zip if-no-files-found: error + overwrite: true - name: Rename sample-app nodejs artifact if: env.LANGUAGE == 'nodejs' && success() run: | @@ -121,6 +124,7 @@ jobs: name: sample-app-${{ env.LANGUAGE }}-${{ matrix.architecture }}-artifacts path: opentelemetry-lambda/${{ env.LANGUAGE }}/sample-apps/aws-sdk/build/nodejs-sample-app.zip if-no-files-found: error + overwrite: true - name: Upload artifacts - python layer if: env.LANGUAGE == 'python' && success() uses: actions/upload-artifact@v4 @@ -128,6 +132,7 @@ jobs: name: ${{ env.ARTIFACT_NAME }}-${{ env.LANGUAGE }}-${{ matrix.architecture }}-artifacts path: ${{ env.LANGUAGE }}/${{ env.ARTIFACT_ARCHIVE_BASE_NAME }}-${{ matrix.architecture }}.zip if-no-files-found: error + overwrite: true - name: Rename sample-app python artifact if: env.LANGUAGE == 'python' && success() run: | @@ -140,3 +145,4 @@ jobs: name: sample-app-${{ env.LANGUAGE }}-${{ matrix.architecture }}-artifacts path: opentelemetry-lambda/${{ env.LANGUAGE }}/sample-apps/build/python-sample-app.zip if-no-files-found: error + overwrite: true diff --git a/.github/workflows/pr-build-java.yml b/.github/workflows/pr-build-java.yml index 5e16396..9aa24e3 100644 --- a/.github/workflows/pr-build-java.yml +++ b/.github/workflows/pr-build-java.yml @@ -17,14 +17,14 @@ jobs: BUILD_COMMAND: make build-java LANGUAGE: java ARTIFACT_ARCHIVE_BASE_NAME: opentelemetry-java-wrapper - ARTIFACT_NAME: ${{ github.head_ref }} + ARTIFACT_NAME: ${{ github.run_id }} create-dev-lambda-layer: needs: build-artifacts uses: ./.github/workflows/publish-dev-layer.yml with: ARTIFACT_ARCHIVE_BASE_NAME: opentelemetry-java-wrapper - ARTIFACT_NAME: ${{ github.head_ref }} + ARTIFACT_NAME: ${{ github.run_id }} LANGUAGE: java run-tests: diff --git a/.github/workflows/pr-build-nodejs.yml b/.github/workflows/pr-build-nodejs.yml index 5d39a4d..3b164f9 100644 --- a/.github/workflows/pr-build-nodejs.yml +++ b/.github/workflows/pr-build-nodejs.yml @@ -17,14 +17,14 @@ jobs: BUILD_COMMAND: make build-nodejs LANGUAGE: nodejs ARTIFACT_ARCHIVE_BASE_NAME: opentelemetry-nodejs - ARTIFACT_NAME: ${{ github.head_ref }} + ARTIFACT_NAME: ${{ github.run_id }} create-dev-lambda-layer: needs: build-artifacts uses: ./.github/workflows/publish-dev-layer.yml with: ARTIFACT_ARCHIVE_BASE_NAME: opentelemetry-nodejs - ARTIFACT_NAME: ${{ github.head_ref }} + ARTIFACT_NAME: ${{ github.run_id }} LANGUAGE: nodejs run-tests: diff --git a/.github/workflows/pr-build-python.yml b/.github/workflows/pr-build-python.yml index cc939e3..65507ca 100644 --- a/.github/workflows/pr-build-python.yml +++ b/.github/workflows/pr-build-python.yml @@ -17,14 +17,14 @@ jobs: BUILD_COMMAND: make build-python LANGUAGE: python ARTIFACT_ARCHIVE_BASE_NAME: opentelemetry-python - ARTIFACT_NAME: ${{ github.head_ref }} + ARTIFACT_NAME: ${{ github.run_id }} create-dev-lambda-layer: needs: build-artifacts uses: ./.github/workflows/publish-dev-layer.yml with: ARTIFACT_ARCHIVE_BASE_NAME: opentelemetry-python - ARTIFACT_NAME: ${{ github.head_ref }} + ARTIFACT_NAME: ${{ github.run_id }} LANGUAGE: python run-tests: diff --git a/.github/workflows/publish-dev-layer.yml b/.github/workflows/publish-dev-layer.yml index 46f2249..1fa43c7 100644 --- a/.github/workflows/publish-dev-layer.yml +++ b/.github/workflows/publish-dev-layer.yml @@ -33,11 +33,11 @@ jobs: aws_region: [ eu-central-1 ] env: LANGUAGE: ${{ inputs.LANGUAGE }} - LAYER_NAME: sumologic-otel-lambda-dev-${{ inputs.LANGUAGE }}-${{ matrix.architecture }}-${{ github.run_id }} + LAYER_NAME: sumologic-otel-lambda-dev-${{ inputs.LANGUAGE }}-${{ matrix.architecture }}-${{ github.run_id }}-${{ github.run_attempt }} ARCHITECTURE: ${{ matrix.architecture }} ARTIFACT_ARCHIVE_BASE_NAME: ${{ inputs.ARTIFACT_ARCHIVE_BASE_NAME }} ARTIFACT_NAME: ${{ inputs.ARTIFACT_NAME }} - BUCKET_NAME: sumologic-otel-lambda-dev-${{ github.run_id }}-${{ matrix.architecture }} + BUCKET_NAME: sumologic-otel-lambda-dev-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.architecture }} BUCKET_KEY: layer-${{ matrix.architecture }}-${{ matrix.aws_region }}-.zip DIRECTORY: ${{ inputs.LANGUAGE }} REGION: ${{ matrix.aws_region }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index cd44774..a619823 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -27,11 +27,16 @@ jobs: receivermockendpoint: ${{ steps.get-receiver-mock-endpoint.outputs.endpoint }} env: BUCKET_NAME: lambda-tests-terraform-state-bucket - BUCKET_KEY: receivermock.${{ matrix.architecture}}.${{ inputs.LANGUAGE }}/terraform_state.tfstate + BUCKET_KEY: receivermock.${{ github.run_id }}.${{ inputs.LANGUAGE }}/terraform_state.tfstate LANGUAGE: ${{ inputs.LANGUAGE }} TERRAFORM_DIRECTORY: utils/receiver-mock/deploy steps: - uses: actions/checkout@v4 + - name: Set receiver-mock resource name + run: | + # Load balancer and target group names cap at 32 characters, so hash the run id instead of embedding it. + run_hash="$(printf '%s' '${{ github.run_id }}' | sha256sum | cut -c1-8)" + echo "TF_VAR_app_name=ll-${{ inputs.LANGUAGE }}-${run_hash}" >> "$GITHUB_ENV" - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v4.0.1 env: @@ -40,11 +45,6 @@ jobs: role-to-assume: ${{ env.AWS_OPENID_ROLE_ARN }} aws-region: ${{ matrix.aws_region }} mask-aws-account-id: false - - name: Cache terraform working directory - uses: actions/cache@v3 - with: - path: ${{ env.TERRAFORM_DIRECTORY }} - key: ${{ inputs.LANGUAGE }}-${{ github.run_id }} - uses: hashicorp/setup-terraform@v3 with: terraform_wrapper: false @@ -55,21 +55,17 @@ jobs: --backend-config "key=${{ env.BUCKET_KEY }}" \ --backend-config "region=${{ matrix.aws_region }}" \ --backend-config "encrypt=true" \ - --backend-config "dynamodb_table=SumoOtelLambdaTfStateLock" + --backend-config "use_lockfile=true" working-directory: ${{ env.TERRAFORM_DIRECTORY }} - name: Apply terraform run: terraform apply -auto-approve working-directory: ${{ env.TERRAFORM_DIRECTORY }} - env: - TF_VAR_app_name: lambda-layers-${{ inputs.LANGUAGE }} - name: Wait for task container to be ready run: sleep 30 - name: Get receiver-mock endpoint id: get-receiver-mock-endpoint run: echo "endpoint=$(terraform output -raw loadbalancer_ip)" >> $GITHUB_OUTPUT working-directory: ${{ env.TERRAFORM_DIRECTORY }} - env: - TF_VAR_app_name: lambda-layers-${{ inputs.LANGUAGE }} run-tests: name: Run tests runs-on: ubuntu-22.04 @@ -78,12 +74,13 @@ jobs: id-token: write contents: read strategy: + fail-fast: false matrix: architecture: [ amd64, arm64 ] aws_region: [ eu-central-1 ] env: BUCKET_NAME: lambda-tests-terraform-state-bucket - BUCKET_KEY: ${{ matrix.architecture}}.${{ inputs.LANGUAGE }}/terraform_state.tfstate + BUCKET_KEY: ${{ matrix.architecture}}.${{ inputs.LANGUAGE }}.${{ github.run_id }}/terraform_state.tfstate LANGUAGE: ${{ inputs.LANGUAGE }} TERRAFORM_DIRECTORY: ${{ inputs.LANGUAGE }}/tests/deploy steps: @@ -138,7 +135,7 @@ jobs: --backend-config "key=${{ env.BUCKET_KEY }}" \ --backend-config "region=${{ matrix.aws_region }}" \ --backend-config "encrypt=true" \ - --backend-config "dynamodb_table=SumoOtelLambdaTfStateLock" + --backend-config "use_lockfile=true" working-directory: ${{ env.TERRAFORM_DIRECTORY }} - name: Deploy lambda sample function run: terraform apply -auto-approve @@ -170,7 +167,7 @@ jobs: cd tests/lambdalayer go test -v -run TestSpans${{ env.LANGUAGE }} - name: Cleanup AWS environment - if: success() + if: always() run: terraform destroy -auto-approve working-directory: ${{ env.TERRAFORM_DIRECTORY }} env: @@ -190,9 +187,16 @@ jobs: matrix: aws_region: [ eu-central-1 ] env: + BUCKET_NAME: lambda-tests-terraform-state-bucket + BUCKET_KEY: receivermock.${{ github.run_id }}.${{ inputs.LANGUAGE }}/terraform_state.tfstate TERRAFORM_DIRECTORY: utils/receiver-mock/deploy steps: - uses: actions/checkout@v4 + - name: Set receiver-mock resource name + run: | + # Must match the name computed in deploy-receiver-mock. + run_hash="$(printf '%s' '${{ github.run_id }}' | sha256sum | cut -c1-8)" + echo "TF_VAR_app_name=ll-${{ inputs.LANGUAGE }}-${run_hash}" >> "$GITHUB_ENV" - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v4.0.1 env: @@ -204,13 +208,15 @@ jobs: - uses: hashicorp/setup-terraform@v3 with: terraform_wrapper: false - - name: Cache terraform working directory - uses: actions/cache@v3 - with: - path: ${{ env.TERRAFORM_DIRECTORY }} - key: ${{ inputs.LANGUAGE }}-${{ github.run_id }} + - name: Initialize terraform + run: | + terraform init \ + --backend-config "bucket=${{ env.BUCKET_NAME }}" \ + --backend-config "key=${{ env.BUCKET_KEY }}" \ + --backend-config "region=${{ matrix.aws_region }}" \ + --backend-config "encrypt=true" \ + --backend-config "use_lockfile=true" + working-directory: ${{ env.TERRAFORM_DIRECTORY }} - name: Destroy terraform run: terraform destroy -auto-approve working-directory: ${{ env.TERRAFORM_DIRECTORY }} - env: - TF_VAR_app_name: lambda-layers-${{ inputs.LANGUAGE }}