diff --git a/.github/workflows/main.yml b/.github/workflows/ci.yml similarity index 57% rename from .github/workflows/main.yml rename to .github/workflows/ci.yml index af2ee829..17028fbf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/ci.yml @@ -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/test-visibility-github-action@v1.0.5 + 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 diff --git a/package.json b/package.json index 9af574be..4554f92e 100644 --- a/package.json +++ b/package.json @@ -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"