chore: limit serverless e2e #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Serverless E2E | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened, edited] | |
| push: | |
| branches: [master] | |
| permissions: | |
| contents: read | |
| jobs: | |
| eligibility: | |
| if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository | |
| name: Check serverless E2E eligibility | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| outputs: | |
| should_run: ${{ steps.event.outputs.eligible == 'true' && steps.version.outputs.result != 'true' && (steps.filter.outputs.container-app == 'true' || steps.filter.outputs.aas == 'true' || steps.filter.outputs.cloud-run == 'true' || steps.filter.outputs.lambda == 'true') }} | |
| container_app: ${{ steps.filter.outputs.container-app }} | |
| aas: ${{ steps.filter.outputs.aas }} | |
| cloud_run: ${{ steps.filter.outputs.cloud-run }} | |
| lambda: ${{ steps.filter.outputs.lambda }} | |
| steps: | |
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.event.pull_request.head.sha || github.sha }} | |
| - name: Check event eligibility | |
| id: event | |
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 | |
| with: | |
| script: | | |
| const eligible = context.eventName === 'push' || ( | |
| context.payload.pull_request.base.ref === 'master' && | |
| (context.payload.action !== 'edited' || context.payload.changes?.base !== undefined) | |
| ) | |
| core.setOutput('eligible', eligible ? 'true' : 'false') | |
| - name: Detect version-bump-only changes | |
| id: version | |
| env: | |
| BASE_SHA: ${{ github.event.pull_request.base.sha || 'HEAD^' }} | |
| run: | | |
| non_json=$(git diff --name-only "$BASE_SHA" HEAD | grep -v 'package\.json' || true) | |
| if [ -n "$non_json" ]; then | |
| echo "result=false" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| leftover=$(git diff "$BASE_SHA" HEAD \ | |
| | grep '^[+-]' \ | |
| | grep -v '^+++\|^---' \ | |
| | grep -vE '^[+-]\s*"version":\s*"[0-9]+\.[0-9]+\.[0-9]+"' \ | |
| | grep -v '^$' || true) | |
| [ -z "$leftover" ] \ | |
| && echo "result=true" >> "$GITHUB_OUTPUT" \ | |
| || echo "result=false" >> "$GITHUB_OUTPUT" | |
| - uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4 | |
| id: filter | |
| with: | |
| filters: | | |
| container-app: | |
| - 'packages/plugin-container-app/**' | |
| - 'packages/base/package.json' | |
| - 'packages/base/src/helpers/serverless/azure.ts' | |
| - 'packages/base/src/helpers/serverless/common.ts' | |
| - 'packages/base/src/helpers/serverless/constants.ts' | |
| - 'packages/base/src/helpers/serverless/source-code-integration.ts' | |
| - 'e2e/serverless/container-app/**' | |
| - 'e2e/serverless/helpers/**' | |
| - '.github/workflows/serverless-e2e.yml' | |
| aas: | |
| - 'packages/plugin-aas/**' | |
| - 'packages/base/package.json' | |
| - 'packages/base/src/helpers/serverless/azure.ts' | |
| - 'packages/base/src/helpers/serverless/common.ts' | |
| - 'packages/base/src/helpers/serverless/constants.ts' | |
| - 'packages/base/src/helpers/serverless/source-code-integration.ts' | |
| - 'packages/base/src/commands/aas/**' | |
| - 'e2e/serverless/aas/**' | |
| - 'e2e/serverless/helpers/**' | |
| - '.github/workflows/serverless-e2e.yml' | |
| cloud-run: | |
| - 'packages/plugin-cloud-run/**' | |
| - 'packages/base/package.json' | |
| - 'packages/base/src/commands/cloud-run/**' | |
| - 'packages/base/src/helpers/serverless/common.ts' | |
| - 'packages/base/src/helpers/serverless/constants.ts' | |
| - 'packages/base/src/helpers/serverless/source-code-integration.ts' | |
| - 'e2e/serverless/cloud-run/**' | |
| - 'e2e/serverless/helpers/**' | |
| - '.github/workflows/serverless-e2e.yml' | |
| lambda: | |
| - 'packages/plugin-lambda/**' | |
| - 'packages/base/package.json' | |
| - 'packages/base/src/commands/lambda/**' | |
| - 'packages/base/src/helpers/serverless/**' | |
| - 'packages/base/src/helpers/tags.ts' | |
| - 'e2e/serverless/lambda/**' | |
| - 'e2e/serverless/helpers/**' | |
| - 'jest.config-e2e.js' | |
| - '.github/workflows/serverless-e2e.yml' | |
| serverless-e2e: | |
| if: needs.eligibility.outputs.should_run == 'true' | |
| name: Serverless E2E (Node 24) | |
| needs: eligibility | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| concurrency: | |
| group: serverless-e2e-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| FORCE_COLOR: 1 | |
| steps: | |
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha || github.sha }} | |
| - name: Install Node | |
| uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 | |
| with: | |
| node-version: 24 | |
| - run: yarn install --immutable | |
| - run: yarn build | |
| - run: | | |
| mkdir artifacts | |
| yarn loop-packages pack --out ../../artifacts/%s-24.tgz | |
| - name: Create E2E project | |
| run: | | |
| echo '{ | |
| "name": "datadog-ci-e2e-tests", | |
| "resolutions": { | |
| "@datadog/datadog-ci-plugin-coverage": "file:./artifacts/@datadog-datadog-ci-plugin-coverage-24.tgz", | |
| "@datadog/datadog-ci-plugin-deployment": "file:./artifacts/@datadog-datadog-ci-plugin-deployment-24.tgz", | |
| "@datadog/datadog-ci-plugin-dora": "file:./artifacts/@datadog-datadog-ci-plugin-dora-24.tgz", | |
| "@datadog/datadog-ci-plugin-gate": "file:./artifacts/@datadog-datadog-ci-plugin-gate-24.tgz", | |
| "@datadog/datadog-ci-plugin-junit": "file:./artifacts/@datadog-datadog-ci-plugin-junit-24.tgz", | |
| "@datadog/datadog-ci-plugin-sarif": "file:./artifacts/@datadog-datadog-ci-plugin-sarif-24.tgz", | |
| "@datadog/datadog-ci-plugin-sbom": "file:./artifacts/@datadog-datadog-ci-plugin-sbom-24.tgz" | |
| }, | |
| "dependencies": { | |
| "@datadog/datadog-ci": "./artifacts/@datadog-datadog-ci-24.tgz", | |
| "@datadog/datadog-ci-plugin-aas": "./artifacts/@datadog-datadog-ci-plugin-aas-24.tgz", | |
| "@datadog/datadog-ci-plugin-cloud-run": "./artifacts/@datadog-datadog-ci-plugin-cloud-run-24.tgz", | |
| "@datadog/datadog-ci-plugin-container-app": "./artifacts/@datadog-datadog-ci-plugin-container-app-24.tgz", | |
| "@datadog/datadog-ci-plugin-lambda": "./artifacts/@datadog-datadog-ci-plugin-lambda-24.tgz", | |
| "@types/jest": "29.5.14", | |
| "jest": "29.6.2", | |
| "ts-jest": "29.1.1", | |
| "typescript": "5.1.6", | |
| "@datadog/datadog-api-client": "^1.0.0" | |
| } | |
| }' > package.json | |
| yarn set version stable | |
| yarn config set nodeLinker node-modules | |
| yarn install --no-immutable | |
| - name: Azure login (OIDC) | |
| if: needs.eligibility.outputs.container_app == 'true' || needs.eligibility.outputs.aas == 'true' | |
| uses: azure/login@532459ea530d8321f2fb9bb10d1e0bcf23869a43 # v3 | |
| with: | |
| client-id: ${{ vars.AZURE_CLIENT_ID_E2E }} | |
| tenant-id: ${{ vars.AZURE_TENANT_ID_E2E }} | |
| subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID_E2E }} | |
| - name: Google Cloud auth (OIDC) | |
| if: needs.eligibility.outputs.cloud_run == 'true' | |
| uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0 | |
| with: | |
| workload_identity_provider: ${{ vars.GCP_WORKLOAD_IDENTITY_PROVIDER_E2E }} | |
| service_account: ${{ vars.GCP_SERVICE_ACCOUNT_E2E }} | |
| - name: Set up Google Cloud CLI | |
| if: needs.eligibility.outputs.cloud_run == 'true' | |
| uses: google-github-actions/setup-gcloud@aa5489c8933f4cc7a4f7d45035b3b1440c9c10db # v3.0.1 | |
| - name: Configure AWS credentials (OIDC) | |
| if: needs.eligibility.outputs.lambda == 'true' | |
| uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4.3.1 | |
| with: | |
| role-to-assume: ${{ vars.AWS_ROLE_ARN_E2E }} | |
| aws-region: eu-central-1 | |
| - name: Run serverless E2E tests | |
| run: yarn jest --config jest.config-e2e.js --colors e2e/serverless | |
| env: | |
| DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY_E2E }} | |
| DATADOG_APP_KEY: ${{ secrets.DATADOG_APP_KEY_E2E }} | |
| DD_API_KEY: ${{ secrets.DD_API_KEY_CI_VISIBILITY }} | |
| DD_APP_KEY: ${{ secrets.DD_APP_KEY_CI_VISIBILITY }} | |
| GITHUB_SHA: ${{ github.event.pull_request.head.sha || github.sha }} | |
| SKIP_CONTAINER_APP_TESTS: ${{ needs.eligibility.outputs.container_app != 'true' }} | |
| SKIP_AAS_TESTS: ${{ needs.eligibility.outputs.aas != 'true' }} | |
| SKIP_CLOUD_RUN_TESTS: ${{ needs.eligibility.outputs.cloud_run != 'true' }} | |
| SKIP_LAMBDA_TESTS: ${{ needs.eligibility.outputs.lambda != 'true' }} | |
| GCP_PROJECT_ID: ${{ vars.GCP_PROJECT_ID_E2E }} | |
| GCP_REGION: ${{ vars.GCP_REGION_E2E }} | |
| GCP_CLOUD_RUN_APP_IMAGE_E2E: ${{ vars.GCP_CLOUD_RUN_APP_IMAGE_E2E }} | |
| AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID_E2E }} | |
| AZURE_RESOURCE_GROUP: ${{ vars.AZURE_RESOURCE_GROUP_E2E }} | |
| AZURE_CONTAINER_APP_ENV: ${{ vars.AZURE_CONTAINER_APP_ENV_E2E }} | |
| AZURE_CONTAINER_APP_IMAGE_E2E: ${{ vars.AZURE_CONTAINER_APP_IMAGE_E2E }} | |
| AZURE_AAS_LINUX_PLAN: ${{ vars.AZURE_AAS_LINUX_PLAN_E2E }} | |
| AZURE_AAS_WINDOWS_PLAN: ${{ vars.AZURE_AAS_WINDOWS_PLAN_E2E }} | |
| AWS_REGION: eu-central-1 | |
| AWS_LAMBDA_EXECUTION_ROLE_ARN: ${{ vars.AWS_LAMBDA_EXECUTION_ROLE_ARN_E2E }} |