Skip to content
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

feat: add Github Action for test coverage to Datadog #307

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions .github/workflows/main.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,39 @@ jobs:
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-

- name: Configure Datadog Test Visibility
env:
DD_SERVICE_NAME: ${{ secrets.DD_SERVICE_NAME }}
DD_API_KEY: ${{ secrets.DD_API_KEY }}
if: env.DD_SERVICE_NAME != '' && env.DD_API_KEY != ''
uses: datadog/[email protected]
with:
languages: js
service-name: ${{ secrets.DD_SERVICE_NAME }}
api-key: ${{ secrets.DD_API_KEY }}

- name: Start test containers
run: npm run setup:test

- name: Build and test
run: npm run build && npm run test-start
- name: Build
run: npm run build

- name: Run unit tests
shell: bash
run: npm run test:unit
env:
# env.DD_TRACE_PACKAGE is provided by the Datadog GitHub Action,
# but might not be available if repository does not have the required env vars set.
# --import dd-trace/register.js is required for vitest
NODE_OPTIONS: ${{ env.DD_TRACE_PACKAGE && format('--import {0}/.datadog/lib/node_modules/dd-trace/register.js -r {1}', github.workspace, env.DD_TRACE_PACKAGE) || '' }}

- name: Run e2e tests
shell: bash
run: npm run test-e2e-start
env:
# env.DD_TRACE_PACKAGE is provided by the Datadog GitHub Action,
# but might not be available if repository does not have the required env vars set.
NODE_OPTIONS: ${{ env.DD_TRACE_PACKAGE && format('-r {0}', env.DD_TRACE_PACKAGE) || '' }}

- name: Stop test containers
run: npm run teardown
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"test:e2e": "dotenv -e .env.test playwright test",
"test-dev": "start-server-and-test dev http://127.0.0.1:3000 test",
"test-dev:unit": "dotenv -e .env.test vitest",
"test-start": "start-server-and-test start http://127.0.0.1:3000 test",
"test-e2e-start": "start-server-and-test start http://127.0.0.1:3000 test:e2e",
"postinstall": "npm run generate && npm run build:theme",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
Expand Down
Loading