Skip to content

[SVLS-7763] simplify #8281

[SVLS-7763] simplify

[SVLS-7763] simplify #8281

Workflow file for this run

# This workflow will do a clean install of node dependencies, build the source code and run tests
name: Continuous Integration
on: push
jobs:
build-and-test:
strategy:
fail-fast: false
matrix:
version: [18, 20, 22]
name: Build and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
- name: Install node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: ${{ matrix.version }}
- run: yarn install --immutable
- run: yarn lint:packages
- run: yarn build
- name: Run yarn lint:ci
run: |
if ! yarn lint:ci ; then
echo "ESLint failed with the following errors:"
jq '.runs[].results' sarif-datadog-ci.sarif
echo ""
echo "Find the full SARIF report in the Artifacts section here: https://github.com/DataDog/datadog-ci/actions/runs/${{ github.run_id }}"
echo "You can fix this by running ==> yarn format <=="
echo ""
exit 1
fi
- run: yarn test
env:
CI: true
DD_SERVICE: datadog-ci-tests
DD_CIVISIBILITY_AGENTLESS_ENABLED: 1
DD_API_KEY: ${{ secrets.DATADOG_API_KEY_MAIN_ACCOUNT }}
DD_APP_KEY: ${{ secrets.DATADOG_APP_KEY_MAIN_ACCOUNT }}
DD_ENV: ci
NODE_OPTIONS: -r dd-trace/ci/init
- run: |
mkdir artifacts
yarn loop-packages pack --out ../../artifacts/%s-${{ matrix.version }}.tgz
cp -r .github/workflows/e2e artifacts/
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: artifacts-${{ matrix.version }}
path: artifacts/
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
if: always()
with:
name: sarif-datadog-ci-${{ matrix.version }}.sarif
path: sarif-datadog-ci.sarif
if-no-files-found: error
unit-tests-windows:
strategy:
fail-fast: false
matrix:
version: [18, 20, 22]
name: Unit tests (Windows)
runs-on: windows-latest
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
- name: Install node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: ${{ matrix.version }}
- run: yarn install --immutable
- run: yarn build
- run: yarn test:windows
env:
CI: true
DD_SERVICE: datadog-ci-tests
DD_CIVISIBILITY_AGENTLESS_ENABLED: 1
DD_API_KEY: ${{ secrets.DATADOG_API_KEY_MAIN_ACCOUNT }}
DD_APP_KEY: ${{ secrets.DATADOG_APP_KEY_MAIN_ACCOUNT }}
DD_ENV: ci
NODE_OPTIONS: -r dd-trace/ci/init
e2e-test:
strategy:
matrix:
version: [18, 20, 22]
name: End-to-end test the package
runs-on: ubuntu-latest
needs: build-and-test
env:
FORCE_COLOR: 1
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
# Only checkout the files we need from the `DataDog/datadog-ci` repo.
# See https://github.com/actions/checkout#fetch-only-a-single-file
sparse-checkout: bin/check-junit-upload.js
sparse-checkout-cone-mode: false
- name: Install node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: ${{ matrix.version }}
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: artifacts-${{ matrix.version }}
path: artifacts/
# Force all dependencies to be installed from the artifacts
- name: Create e2e project
run: |
echo '{
"name": "datadog-ci-e2e-tests",
"resolutions": {
"@datadog/datadog-ci-base": "file:./artifacts/@datadog-datadog-ci-base-${{ matrix.version }}.tgz",
"@datadog/datadog-ci-plugin-aas": "file:./artifacts/@datadog-datadog-ci-plugin-aas-${{ matrix.version }}.tgz",
"@datadog/datadog-ci-plugin-cloud-run": "file:./artifacts/@datadog-datadog-ci-plugin-cloud-run-${{ matrix.version }}.tgz",
"@datadog/datadog-ci-plugin-deployment": "file:./artifacts/@datadog-datadog-ci-plugin-deployment-${{ matrix.version }}.tgz",
"@datadog/datadog-ci-plugin-dora": "file:./artifacts/@datadog-datadog-ci-plugin-dora-${{ matrix.version }}.tgz",
"@datadog/datadog-ci-plugin-gate": "file:./artifacts/@datadog-datadog-ci-plugin-gate-${{ matrix.version }}.tgz",
"@datadog/datadog-ci-plugin-lambda": "file:./artifacts/@datadog-datadog-ci-plugin-lambda-${{ matrix.version }}.tgz",
"@datadog/datadog-ci-plugin-sarif": "file:./artifacts/@datadog-datadog-ci-plugin-sarif-${{ matrix.version }}.tgz",
"@datadog/datadog-ci-plugin-sbom": "file:./artifacts/@datadog-datadog-ci-plugin-sbom-${{ matrix.version }}.tgz",
"@datadog/datadog-ci-plugin-stepfunctions": "file:./artifacts/@datadog-datadog-ci-plugin-stepfunctions-${{ matrix.version }}.tgz",
"@datadog/datadog-ci-plugin-synthetics": "file:./artifacts/@datadog-datadog-ci-plugin-synthetics-${{ matrix.version }}.tgz"
},
"dependencies": {
"@datadog/datadog-ci": "./artifacts/@datadog-datadog-ci-${{ matrix.version }}.tgz"
}
}' > package.json
yarn set version stable
yarn install --no-immutable
- name: Run synthetics test
run: yarn datadog-ci synthetics run-tests --config artifacts/e2e/global.config.json
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY_E2E }}
DATADOG_APP_KEY: ${{ secrets.DATADOG_APP_KEY_E2E }}
- name: Run sourcemaps upload test
run: yarn datadog-ci sourcemaps upload artifacts/e2e/sourcemaps/ --release-version=e2e --service=e2e-tests --minified-path-prefix=https://e2e-tests.datadoghq.com/static/
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY_E2E }}
DATADOG_APP_KEY: ${{ secrets.DATADOG_APP_KEY_E2E }}
- name: Run junit upload test (measures)
run: yarn datadog-ci junit upload --service=datadog-ci-e2e-tests-junit **/junit-reports/**/*.xml --measures testmeasure1:20 --report-measures sessionmeasure1:40
env:
DD_API_KEY: ${{ secrets.DD_API_KEY_CI_VISIBILITY }}
- name: Check that test data can be queried (measures)
run: |
yarn add @datadog/datadog-api-client
yarn node bin/check-junit-upload.js
env:
EXTRA_TEST_QUERY_FILTER: "@testmeasure1:20"
EXTRA_SESSION_QUERY_FILTER: "@sessionmeasure1:40"
DD_API_KEY: ${{ secrets.DD_API_KEY_CI_VISIBILITY }}
DD_APP_KEY: ${{ secrets.DD_APP_KEY_CI_VISIBILITY }}
DD_SERVICE: datadog-ci-e2e-tests-junit
- name: Run junit upload test (measures), passing glob as literal string
run: yarn datadog-ci junit upload --service=datadog-ci-e2e-tests-junit '**/junit-reports/**' --measures testmeasure2:60 --report-measures sessionmeasure2:80
env:
DD_API_KEY: ${{ secrets.DD_API_KEY_CI_VISIBILITY }}
- name: Check that test data can be queried (measures)
run: |
yarn add @datadog/datadog-api-client
yarn node bin/check-junit-upload.js
env:
EXTRA_TEST_QUERY_FILTER: "@testmeasure2:60"
EXTRA_SESSION_QUERY_FILTER: "@sessionmeasure2:80"
DD_API_KEY: ${{ secrets.DD_API_KEY_CI_VISIBILITY }}
DD_APP_KEY: ${{ secrets.DD_APP_KEY_CI_VISIBILITY }}
DD_SERVICE: datadog-ci-e2e-tests-junit
- name: Run sarif upload test
run: yarn datadog-ci sarif upload --service=datadog-ci-e2e-tests-sarif artifacts/e2e/sarif-reports
env:
DD_API_KEY: ${{ secrets.DD_API_KEY_CI_VISIBILITY }}
- name: Run sbom upload test
run: yarn datadog-ci sbom upload --service=datadog-ci-e2e-tests-sbom --env test artifacts/e2e/sbom-reports/sbom.json
env:
DD_API_KEY: ${{ secrets.DD_API_KEY_CI_VISIBILITY }}
DD_APP_KEY: ${{ secrets.DD_APP_KEY_CI_VISIBILITY }}
- name: Check that version can be run without git repository
run: |
rm -rf .git
yarn datadog-ci version
standalone-binary-test-ubuntu:
name: Test standalone binary in ubuntu
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
- name: Install node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 22.19.0
- run: yarn install --immutable
- run: yarn build
- name: Create standalone binary
run: yarn dist-standalone -t node22-linux-x64 -o datadog-ci_linux-x64
- name: Remove src and dist folders to check that binary can stand alone
run: yarn rimraf --glob 'packages/*/{src,dist}'
- name: Test generated standalone binary
run: yarn dist-standalone:test
- name: Compare binary sizes
run: yarn compare-binary-size datadog-ci_linux-x64
standalone-binary-test-ubuntu-arm:
name: Test standalone binary in ARM ubuntu
runs-on:
group: ARM LINUX SHARED
labels: arm-4core-linux
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
- name: Install node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 22.19.0
- run: npm install -g yarn
name: Install Yarn # Yarn is not installed by default in this runner
- run: yarn install --immutable
- run: yarn build
- name: Create standalone binary
run: yarn dist-standalone -t node22-linux-arm64 -o datadog-ci_linux-arm64
- name: Remove src and dist folders to check that binary can stand alone
run: yarn rimraf --glob 'packages/*/{src,dist}'
- name: Test generated standalone binary
run: yarn dist-standalone:test
- name: Compare binary sizes
run: yarn compare-binary-size datadog-ci_linux-arm64
standalone-binary-test-windows:
name: Test standalone binary in windows
runs-on: windows-latest
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
- name: Install node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 22.19.0
- run: yarn install --immutable
- run: yarn build
- name: Create standalone binary
run: yarn dist-standalone -t node22-win-x64 -o datadog-ci_win-x64
- name: Remove src and dist folders to check that binary can stand alone
run: yarn rimraf --glob 'packages/*/{src,dist}'
- name: Test generated standalone binary
run: yarn dist-standalone:test
- name: Compare binary sizes
run: yarn compare-binary-size datadog-ci_win-x64.exe
standalone-binary-test-macos:
name: Test standalone binary in macOS
# `macos-latest-large` is an x64 image, and we need it to run the standalone tests
# https://github.com/actions/runner-images#available-images
runs-on: macos-latest-large
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
- name: Install node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 22.19.0
- run: yarn install --immutable
- run: yarn build
- name: Create standalone binary
run: yarn dist-standalone -t node22-macos-x64 -o datadog-ci_darwin-x64
- name: Remove src and dist folders to check that binary can stand alone
run: yarn rimraf --glob 'packages/*/{src,dist}'
- name: Test generated standalone binary
run: yarn dist-standalone:test
- name: Compare binary sizes
run: yarn compare-binary-size datadog-ci_darwin-x64
standalone-binary-test-macos-arm:
name: Test standalone binary in ARM macOS
runs-on: macos-latest
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
- name: Install node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 22.19.0
- run: yarn install --immutable
- run: yarn build
- name: Create standalone binary
run: yarn dist-standalone -t node22-macos-arm64 -o datadog-ci_darwin-arm64
- name: Remove src and dist folders to check that binary can stand alone
run: yarn rimraf --glob 'packages/*/{src,dist}'
- name: Test generated standalone binary
run: yarn dist-standalone:test
- name: Compare binary sizes
run: yarn compare-binary-size datadog-ci_darwin-arm64
datadog-static-analyzer:
runs-on: ubuntu-latest
name: Static Analyzer - Diff Aware
steps:
- name: Checkout
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
- name: Run Datadog static analyzer
id: datadog-static-analysis
uses: DataDog/datadog-static-analyzer-github-action@2707598b1182dce1d1792186477b5b4132338e1c # v1.2.3
with:
dd_app_key: ${{ secrets.DATADOG_APP_KEY_MAIN_ACCOUNT }}
dd_api_key: ${{ secrets.DATADOG_API_KEY_MAIN_ACCOUNT }}
cpu_count: 2
diff_aware: true
datadog-static-analyzer-non-diff-aware:
runs-on: ubuntu-latest
name: Static Analyzer - Non Diff Aware
steps:
- name: Checkout
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
- name: Run Datadog static analyzer
id: datadog-static-analysis
uses: DataDog/datadog-static-analyzer-github-action@2707598b1182dce1d1792186477b5b4132338e1c # v1.2.3
with:
dd_app_key: ${{ secrets.DATADOG_APP_KEY_MAIN_ACCOUNT }}
dd_api_key: ${{ secrets.DATADOG_API_KEY_MAIN_ACCOUNT }}
cpu_count: 2
diff_aware: false
check-licenses:
name: Check licenses
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
- name: Install node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 22.19.0
# The install step has been added here such that the `.yarn/install-state.gz` file is generated. This file is used
# by the script `check-licenses` below.
- run: yarn install --immutable
- run: yarn check-licenses