Repository navigation
ci: exercise DDTest with action-installed tracer on Express #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e220d78
ci: reproduce DDTest action preload with Express Mocha
anmarchenko 888b134
ci: explain missing Datadog secret in the fork
anmarchenko 17b9d50
ci: verify ddtest platform refactor with action preloads
anmarchenko a6f9f30
ci: verify corrected discovery prerequisites
anmarchenko 3f1b2cc
ci: isolate Express test tracing from router wrapping
anmarchenko c3f5964
ci: define preload options in the matrix
anmarchenko 67891fc
ci: use latest ddtest prerelease with automatic tracer discovery
anmarchenko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| name: DDTest action preload | ||
|
|
||
| on: | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| mocha: | ||
| if: github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == 'anmarchenko/express' | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| # Express asserts middleware next-function identity. dd-trace's router | ||
| # wrapping breaks those assertions; retain Mocha tracing for this test. | ||
| DD_TRACE_ROUTER_ENABLED: 'false' | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| persist-credentials: false | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '22' | ||
| - name: Install Express dependencies | ||
| run: npm install --include=dev | ||
| - name: Install latest DDTest prerelease | ||
| shell: bash | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | | ||
| download_url=$(gh api --paginate --slurp 'repos/DataDog/ddtest/releases?per_page=100' | \ | ||
| jq -er 'add | map(select(.prerelease and (.draft | not))) | max_by(.published_at) | .assets[] | select(.name == "ddtest-linux-amd64") | .browser_download_url') | ||
| test -n "$download_url" | ||
| echo "Installing $download_url" | ||
| curl --fail --location --retry 3 "$download_url" --output ddtest | ||
| chmod +x ddtest | ||
| ./ddtest --version | ||
| - name: Require the Datadog API key | ||
| env: | ||
| DD_API_KEY: ${{ secrets.DD_API_KEY }} | ||
| run: | | ||
| if [ -z "$DD_API_KEY" ]; then | ||
| echo 'Add DD_API_KEY as an Actions repository secret in anmarchenko/express' | ||
| exit 1 | ||
| fi | ||
| - name: Configure Datadog Test Optimization | ||
| uses: datadog/test-visibility-github-action@v3 | ||
| with: | ||
| languages: js | ||
| api_key: ${{ secrets.DD_API_KEY }} | ||
| service: express-ddtest-action | ||
| - name: Check the action preload is outside the project | ||
| shell: bash | ||
| run: | | ||
| test -n "$DD_TRACE_PACKAGE" | ||
| NODE_OPTIONS= node -e "require.resolve(process.env.DD_TRACE_PACKAGE)" | ||
| if NODE_OPTIONS= node -e "require.resolve('dd-trace/ci/init')" 2>/dev/null; then | ||
| echo 'dd-trace unexpectedly resolves from the Express project' | ||
| exit 1 | ||
| fi | ||
| - name: Run Mocha directly with the action preload | ||
| env: | ||
| NODE_OPTIONS: -r ${{ env.DD_TRACE_PACKAGE }} | ||
| run: ./node_modules/.bin/mocha --require test/support/env --reporter dot --check-leaks test/ test/acceptance/ | ||
| - name: Plan Mocha tests with DDTest | ||
| run: | | ||
| ./ddtest plan --platform javascript --framework mocha \ | ||
| --min-parallelism 1 --max-parallelism 1 \ | ||
| --command "./node_modules/.bin/mocha --require test/support/env --reporter spec --check-leaks test/ test/acceptance/" | ||
| - name: Run planned Mocha tests with DDTest | ||
| run: | | ||
| ./ddtest run --platform javascript --framework mocha --ci-node 0 \ | ||
| --command "./node_modules/.bin/mocha --require test/support/env --reporter spec --check-leaks test/ test/acceptance/" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.