diff --git a/.github/workflows/cli-ci.yaml b/.github/workflows/cli-ci.yaml index 94e84f9f18..dc3ede95bc 100644 --- a/.github/workflows/cli-ci.yaml +++ b/.github/workflows/cli-ci.yaml @@ -61,7 +61,7 @@ jobs: coverage-path: | cli/coverage/clover.xml cli/coverage/coverage-final.json - retention-days: 7 + retention-days: 14 codecov-token: ${{ secrets.CODECOV_TOKEN }} build_test_node_matrix: diff --git a/.github/workflows/codecov-post-merge.yaml b/.github/workflows/codecov-post-merge.yaml index 6496de799f..8eafcdf747 100644 --- a/.github/workflows/codecov-post-merge.yaml +++ b/.github/workflows/codecov-post-merge.yaml @@ -34,7 +34,7 @@ jobs: uses: ./.github/actions/codecov-merge-upload with: coverage-path: coverage - workflow-paths: .github/workflows/cli-ci.yaml,.github/workflows/router-ci.yaml + workflow-paths: .github/workflows/cli-ci.yaml,.github/workflows/router-ci.yaml,.github/workflows/composition-ci.yaml,.github/workflows/controlplane-ci.yaml,.github/workflows/graphqlmetrics-ci.yaml,.github/workflows/protographic.yaml,.github/workflows/studio-ci.yaml override-commit: ${{ github.sha }} merge-commit-sha: ${{ steps.find-pr-commit.outputs.merge_commit_sha }} codecov-token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/composition-ci.yaml b/.github/workflows/composition-ci.yaml index ac44fd5ca7..cdc8ae4fea 100644 --- a/.github/workflows/composition-ci.yaml +++ b/.github/workflows/composition-ci.yaml @@ -45,20 +45,40 @@ jobs: run: pnpm run --filter ./composition --filter ./connect --filter ./shared build - name: Test - run: pnpm run --filter composition test + run: pnpm run --filter composition test:coverage - name: Lint run: pnpm run --filter composition lint + - name: Upload integration results to Codecov + uses: ./.github/actions/codecov-upload-pr + with: + artifact-name: composition-tests-coverage + coverage-path: | + composition/coverage/clover.xml + composition/coverage/coverage-final.json + retention-days: 14 + codecov-token: ${{ secrets.CODECOV_TOKEN }} + - name: Run linter on composition-go uses: ./.github/actions/go-linter with: working-directory: ./composition-go - name: Test Go library - run: go test + run: go test -coverprofile=coverage_normal.out -coverpkg=github.com/wundergraph/cosmo/composition-go/... working-directory: composition-go - name: Test Go library with V8 - run: go test -tags wg_composition_v8 + run: go test -tags wg_composition_v8 -coverprofile=coverage_v8.out -coverpkg=github.com/wundergraph/cosmo/composition-go/... working-directory: composition-go + + - name: Upload integration results to Codecov + uses: ./.github/actions/codecov-upload-pr + with: + artifact-name: composition-go-tests-coverage + coverage-path: | + composition-go/coverage_normal.out + composition-go/coverage_v8.out + retention-days: 14 + codecov-token: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/controlplane-ci.yaml b/.github/workflows/controlplane-ci.yaml index 408744925e..4a30855a49 100644 --- a/.github/workflows/controlplane-ci.yaml +++ b/.github/workflows/controlplane-ci.yaml @@ -20,7 +20,7 @@ env: jobs: build_test: - timeout-minutes: 10 + timeout-minutes: 15 runs-on: ubuntu-latest services: redis: @@ -81,10 +81,20 @@ jobs: run: nohup .github/scripts/setup-keycloak.sh & - name: Test - run: pnpm run --filter controlplane test + run: pnpm run --filter controlplane test:coverage env: DB_URL: "postgresql://postgres:changeme@localhost:5432/controlplane" + - name: Upload Coverage to Codecov + uses: ./.github/actions/codecov-upload-pr + with: + artifact-name: controlplane-tests-coverage + coverage-path: | + controlplane/coverage/clover.xml + controlplane/coverage/coverage-final.json + retention-days: 14 + codecov-token: ${{ secrets.CODECOV_TOKEN }} + build_push_image: # This is a limitation of GitHub. Only organization members can push to GitHub Container Registry # For now, we will disable the push to the GitHub Container Registry for external contributors @@ -103,3 +113,4 @@ jobs: token: ${{secrets.GITHUB_TOKEN}} image_name: controlplane image_description: "Cosmo Controlplane" + diff --git a/.github/workflows/graphqlmetrics-ci.yaml b/.github/workflows/graphqlmetrics-ci.yaml index 6701e5ece7..15daea0dd7 100644 --- a/.github/workflows/graphqlmetrics-ci.yaml +++ b/.github/workflows/graphqlmetrics-ci.yaml @@ -60,12 +60,20 @@ jobs: - name: Test working-directory: ./graphqlmetrics - run: make test + run: make test-coverage - name: Build working-directory: ./graphqlmetrics run: make build + - name: Upload integration results to Codecov + uses: ./.github/actions/codecov-upload-pr + with: + artifact-name: graphqlmetrics-tests-coverage + coverage-path: graphqlmetrics/coverage.out + retention-days: 14 + codecov-token: ${{ secrets.CODECOV_TOKEN }} + build_push_image: # This is a limitation of GitHub. Only organization members can push to GitHub Container Registry # For now, we will disable the push to the GitHub Container Registry for external contributors diff --git a/.github/workflows/protographic.yaml b/.github/workflows/protographic.yaml index e45c2f1ce3..17b4c1c31a 100644 --- a/.github/workflows/protographic.yaml +++ b/.github/workflows/protographic.yaml @@ -4,7 +4,7 @@ on: paths: - 'pnpm-lock.yaml' - "protographic/**/*" - - ".github/workflows/protographic-ci.yaml" + - ".github/workflows/protographic.yaml" concurrency: group: ${{github.workflow}}-${{github.head_ref}} @@ -36,7 +36,17 @@ jobs: run: pnpm run --filter ./connect --filter ./protographic build - name: Test - run: pnpm run --filter ./protographic test + run: pnpm run --filter ./protographic test:coverage - name: Lint run: pnpm run --filter ./protographic lint + + - name: Upload integration results to Codecov + uses: ./.github/actions/codecov-upload-pr + with: + artifact-name: protographic-tests-coverage + coverage-path: | + protographic/coverage/clover.xml + protographic/coverage/coverage-final.json + retention-days: 14 + codecov-token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/router-ci.yaml b/.github/workflows/router-ci.yaml index ca4197eea4..ba9cec5318 100644 --- a/.github/workflows/router-ci.yaml +++ b/.github/workflows/router-ci.yaml @@ -175,12 +175,20 @@ jobs: - name: Test working-directory: ./router - run: make test + run: make test-coverage - name: Build working-directory: ./router run: make build + - name: Upload integration results to Codecov + uses: ./.github/actions/codecov-upload-pr + with: + artifact-name: router-tests-coverage + coverage-path: router/coverage.out + retention-days: 14 + codecov-token: ${{ secrets.CODECOV_TOKEN }} + integration_test: runs-on: ubuntu-latest-l timeout-minutes: 30 @@ -375,7 +383,7 @@ jobs: with: artifact-name: router-${{ steps.artifact_name.outputs.sanitized }}-nonFlaky coverage-path: router-tests/coverage.out - retention-days: 7 + retention-days: 14 codecov-token: ${{ secrets.CODECOV_TOKEN }} - name: Run Flaky Integration tests ${{ matrix.test_target }} @@ -387,7 +395,7 @@ jobs: with: artifact-name: router-${{ steps.artifact_name.outputs.sanitized }}-flaky coverage-path: router-tests/coverage.out - retention-days: 7 + retention-days: 14 codecov-token: ${{ secrets.CODECOV_TOKEN }} image_scan: diff --git a/.github/workflows/studio-ci.yaml b/.github/workflows/studio-ci.yaml index edb5d962b9..9862b4339e 100644 --- a/.github/workflows/studio-ci.yaml +++ b/.github/workflows/studio-ci.yaml @@ -53,7 +53,17 @@ jobs: run: pnpm run --filter studio lint - name: Test - run: pnpm run --filter studio test + run: pnpm run --filter studio test:coverage + + - name: Upload integration results to Codecov + uses: ./.github/actions/codecov-upload-pr + with: + artifact-name: studio-tests-coverage + coverage-path: | + studio/coverage/clover.xml + studio/coverage/coverage-final.json + retention-days: 14 + codecov-token: ${{ secrets.CODECOV_TOKEN }} build_push_image: # This is a limitation of GitHub. Only organization members can push to GitHub Container Registry diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 60b0cb8a13..822a175af5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -165,6 +165,36 @@ We manage multiple compose files: - `docker-compose.full.yml`: This compose file contains the full Cosmo platform. It is used for demo and testing. - `docker-compose.cosmo.yml`: This compose file allows to build all Cosmo components and manage them in a single compose file. It is used for testing and releasing. +### Code Coverage + +We use Codecov for code coverage. Code coverage is used for both PRs and also our default branch main. + +#### Workaround for uploading to main +Codecov relies on commit hashes to map code to Codecov reports, however unfortunately we use "Squash Merge", which means that the HEAD of any merged PR is never present on main post-merge, leading to no code coverage uploaded for main (which is used as a base for comparisons). + +In order to circumvent this we do the following steps: +* Upload Codecov reports from PR runs to GitHub as artifacts for the PR's HEAD commit +* Upon merge we find the PR and it's HEAD commit using the GitHub rest API +* We find the github artifact from this commit hash +* We then upload it again, but this time it acts as if it was uploaded from main + +#### Adding new projects +When you add a new project (i.e. a subfolder in the cosmo repository root), if you wish to add code coverage for it you can follow these steps: + +* Add a flag in the codecov.yaml for your project with the folder name, this is important so coverage does not get overwritten (for example if a router pr gets merged, cli coverage won't be set to empty for that commit) +```yaml +flags: + router: + paths: + - router + carryforward: true +``` +* You should be running tests in ci for your project via a GH Workflow, You need to add the GH Workflow name to `codecov-post-merge.yaml`, the line you are looking for will look something like this +```yaml +workflow-paths: .github/workflows/cli-ci.yaml,.github/workflows/router-ci.yaml, +``` +Ensure you add the full relative path from the cosmo repository root and it is comma-separated, e.g.: for graphqlmetrics `,.github/workflows/graphqlmetrics-ci.yaml` + **Clean up a compose stack before starting another one!** ### Compose Profiles Overview diff --git a/codecov.yaml b/codecov.yaml index 364bc9884e..029b7fe5fe 100644 --- a/codecov.yaml +++ b/codecov.yaml @@ -7,6 +7,32 @@ coverage: informational: true # We don't want to block PRs based on the result project: default: - target: 90 + target: 30 threshold: 5 - informational: true + informational: true # We don't want to block PRs based on the result + +flags: + router: + paths: + - router + carryforward: true + cli: + paths: + - cli + carryforward: true + studio: + paths: + - studio + carryforward: true + graphqlmetrics: + paths: + - graphqlmetrics + carryforward: true + controlplane: + paths: + - controlplane + carryforward: true + composition: + paths: + - composition + carryforward: true \ No newline at end of file diff --git a/composition-go/Makefile b/composition-go/Makefile index eeb3fd748b..5a18260ac1 100644 --- a/composition-go/Makefile +++ b/composition-go/Makefile @@ -2,4 +2,8 @@ test: go test -v ./... go test -v -tags=wg_composition_v8 ./... +test-coverage: + go test -v -coverprofile=coverage_normal.out -coverpkg=github.com/wundergraph/cosmo/composition-go/... ./... + go test -v -tags=wg_composition_v8 -coverprofile=coverage_v8.out -coverpkg=github.com/wundergraph/cosmo/composition-go/... ./... + .PHONY: test \ No newline at end of file diff --git a/composition/package.json b/composition/package.json index 29da0e5c42..892733292c 100644 --- a/composition/package.json +++ b/composition/package.json @@ -18,6 +18,7 @@ "test:watch": "vitest test", "test": "vitest run", "test:core": "vitest run --exclude ./tests/unstaged-tests", + "test:coverage": "vitest run --coverage", "lint": "prettier --check src tests", "lint:fix": "prettier --write src tests", "postversion": "node ./scripts/get-composition-version.mjs" @@ -38,6 +39,7 @@ }, "devDependencies": { "@types/lodash": "^4.17.0", + "@vitest/coverage-v8": "3.2.4", "del-cli": "^5.0.0", "typescript": "5.5.2", "vitest": "^3.2.4" diff --git a/controlplane/package.json b/controlplane/package.json index 4b4e2fbea6..857ea0f169 100644 --- a/controlplane/package.json +++ b/controlplane/package.json @@ -23,6 +23,7 @@ "db:drop": "drizzle-kit drop --config=drizzle.config.ts", "start": "NODE_ENV=production node dist/index.js", "test": "pnpm lint && tsc -p tsconfig.test.json && vitest run --reporter=default --reporter=hanging-process", + "test:coverage": "pnpm lint && tsc -p tsconfig.test.json && vitest run --reporter=default --reporter=hanging-process --coverage", "lint": "eslint --cache --ext .ts,.mjs,.cjs . && prettier -c src", "lint:fix": "eslint --cache --fix --ext .ts,.mjs,.cjs . && prettier --write -c src", "migrate": "pnpm db:migrate && pnpm ch:migrate", @@ -109,6 +110,7 @@ "@types/prettier": "^3.0.0", "@types/stream-json": "^1.7.7", "@types/uuid": "^9.0.8", + "@vitest/coverage-v8": "3.2.4", "del-cli": "^5.1.0", "drizzle-kit": "^0.26.2", "eslint-config-unjs": "^0.2.1", diff --git a/graphqlmetrics/Makefile b/graphqlmetrics/Makefile index 0b39bf30af..6b59fe545e 100644 --- a/graphqlmetrics/Makefile +++ b/graphqlmetrics/Makefile @@ -1,9 +1,14 @@ +coverage_file := coverage.out + dev: go run cmd/main.go test: go test -race ./... +test-coverage: + go test -race -coverprofile=$(coverage_file) -coverpkg=github.com/wundergraph/cosmo/graphqlmetrics/... ./... + new-migration: dbmate -d "./migrations" new $(name) @@ -18,4 +23,4 @@ VERSION?=dev build: CGO_ENABLED=0 go build -trimpath -ldflags "-extldflags -static -X github.com/wundergraph/cosmo/graphqlmetrics/core.Version=$(VERSION)" -a -o graphqlmetrics cmd/main.go -.PHONY: dev test new-migration migrate build \ No newline at end of file +.PHONY: dev test test-coverage new-migration migrate build \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f77b6626df..82fb7c5ec0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -400,6 +400,9 @@ importers: '@types/lodash': specifier: ^4.17.0 version: 4.17.0 + '@vitest/coverage-v8': + specifier: 3.2.4 + version: 3.2.4(vitest@3.2.4(@types/debug@4.1.12)(@types/node@22.17.0)(jsdom@27.2.0)(terser@5.43.1)) del-cli: specifier: ^5.0.0 version: 5.0.0 @@ -658,6 +661,9 @@ importers: '@types/uuid': specifier: ^9.0.8 version: 9.0.8 + '@vitest/coverage-v8': + specifier: 3.2.4 + version: 3.2.4(vitest@3.2.4(@types/debug@4.1.12)(@types/node@18.19.21)(jsdom@27.2.0)(msw@2.2.11(typescript@5.5.2))(terser@5.43.1)) del-cli: specifier: ^5.1.0 version: 5.1.0 @@ -894,6 +900,9 @@ importers: '@types/node': specifier: ^20.11.5 version: 20.12.12 + '@vitest/coverage-v8': + specifier: 3.2.4 + version: 3.2.4(vitest@3.2.4(@types/debug@4.1.12)(@types/node@20.12.12)(jsdom@27.2.0)(terser@5.43.1)) typescript: specifier: ^5.0.0 version: 5.5.2 @@ -1262,6 +1271,9 @@ importers: '@vitejs/plugin-react': specifier: ^4.2.1 version: 4.2.1(vite@5.4.21(@types/node@20.3.1)(terser@5.43.1)) + '@vitest/coverage-v8': + specifier: 3.2.4 + version: 3.2.4(vitest@3.2.4(@types/debug@4.1.12)(@types/node@20.3.1)(jsdom@23.2.0)(terser@5.43.1)) autoprefixer: specifier: 10.4.14 version: 10.4.14(postcss@8.4.38) @@ -4188,10 +4200,6 @@ packages: resolution: {integrity: sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==} engines: {node: '>=6.0.0'} - '@jridgewell/gen-mapping@0.3.8': - resolution: {integrity: sha512-imAbBGkb+ebQyxKgzv5Hu2nmROxoDOXHh80evxdoXNOrvAnVx7zimzc1Oo5h9RlfV4vPXaE2iM5pOFbvOCClWA==} - engines: {node: '>=6.0.0'} - '@jridgewell/resolve-uri@3.1.2': resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} engines: {node: '>=6.0.0'} @@ -4225,9 +4233,6 @@ packages: '@jridgewell/trace-mapping@0.3.25': resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==} - '@jridgewell/trace-mapping@0.3.30': - resolution: {integrity: sha512-GQ7Nw5G2lTu/BtHTKfXhKHok2WGetd4XYcVKGx00SjAk8GMwgJM3zr6zORiPGuOE+/vkc90KtTosSSvaCjKb2Q==} - '@jridgewell/trace-mapping@0.3.31': resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==} @@ -16033,7 +16038,7 @@ snapshots: dependencies: '@babel/types': 7.28.2 '@jridgewell/gen-mapping': 0.3.3 - '@jridgewell/trace-mapping': 0.3.25 + '@jridgewell/trace-mapping': 0.3.31 jsesc: 2.5.2 '@babel/generator@7.28.0': @@ -18495,12 +18500,6 @@ snapshots: '@jridgewell/sourcemap-codec': 1.5.0 '@jridgewell/trace-mapping': 0.3.25 - '@jridgewell/gen-mapping@0.3.8': - dependencies: - '@jridgewell/set-array': 1.2.1 - '@jridgewell/sourcemap-codec': 1.5.0 - '@jridgewell/trace-mapping': 0.3.25 - '@jridgewell/resolve-uri@3.1.2': {} '@jridgewell/set-array@1.1.2': {} @@ -18514,8 +18513,8 @@ snapshots: '@jridgewell/source-map@0.3.6': dependencies: - '@jridgewell/gen-mapping': 0.3.8 - '@jridgewell/trace-mapping': 0.3.25 + '@jridgewell/gen-mapping': 0.3.13 + '@jridgewell/trace-mapping': 0.3.31 '@jridgewell/sourcemap-codec@1.4.15': {} @@ -18530,11 +18529,6 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.5.0 - '@jridgewell/trace-mapping@0.3.30': - dependencies: - '@jridgewell/resolve-uri': 3.1.2 - '@jridgewell/sourcemap-codec': 1.5.5 - '@jridgewell/trace-mapping@0.3.31': dependencies: '@jridgewell/resolve-uri': 3.1.2 @@ -23300,6 +23294,25 @@ snapshots: transitivePeerDependencies: - supports-color + '@vitest/coverage-v8@3.2.4(vitest@3.2.4(@types/debug@4.1.12)(@types/node@18.19.21)(jsdom@27.2.0)(msw@2.2.11(typescript@5.5.2))(terser@5.43.1))': + dependencies: + '@ampproject/remapping': 2.3.0 + '@bcoe/v8-coverage': 1.0.2 + ast-v8-to-istanbul: 0.3.8 + debug: 4.3.7 + istanbul-lib-coverage: 3.2.2 + istanbul-lib-report: 3.0.1 + istanbul-lib-source-maps: 5.0.6 + istanbul-reports: 3.2.0 + magic-string: 0.30.17 + magicast: 0.3.5 + std-env: 3.9.0 + test-exclude: 7.0.1 + tinyrainbow: 2.0.0 + vitest: 3.2.4(@types/debug@4.1.12)(@types/node@18.19.21)(jsdom@27.2.0)(msw@2.2.11(typescript@5.5.2))(terser@5.43.1) + transitivePeerDependencies: + - supports-color + '@vitest/coverage-v8@3.2.4(vitest@3.2.4(@types/debug@4.1.12)(@types/node@20.12.12)(jsdom@27.2.0)(terser@5.43.1))': dependencies: '@ampproject/remapping': 2.3.0 @@ -23319,6 +23332,44 @@ snapshots: transitivePeerDependencies: - supports-color + '@vitest/coverage-v8@3.2.4(vitest@3.2.4(@types/debug@4.1.12)(@types/node@20.3.1)(jsdom@23.2.0)(terser@5.43.1))': + dependencies: + '@ampproject/remapping': 2.3.0 + '@bcoe/v8-coverage': 1.0.2 + ast-v8-to-istanbul: 0.3.8 + debug: 4.3.7 + istanbul-lib-coverage: 3.2.2 + istanbul-lib-report: 3.0.1 + istanbul-lib-source-maps: 5.0.6 + istanbul-reports: 3.2.0 + magic-string: 0.30.17 + magicast: 0.3.5 + std-env: 3.9.0 + test-exclude: 7.0.1 + tinyrainbow: 2.0.0 + vitest: 3.2.4(@types/debug@4.1.12)(@types/node@20.3.1)(jsdom@23.2.0)(terser@5.43.1) + transitivePeerDependencies: + - supports-color + + '@vitest/coverage-v8@3.2.4(vitest@3.2.4(@types/debug@4.1.12)(@types/node@22.17.0)(jsdom@27.2.0)(terser@5.43.1))': + dependencies: + '@ampproject/remapping': 2.3.0 + '@bcoe/v8-coverage': 1.0.2 + ast-v8-to-istanbul: 0.3.8 + debug: 4.3.7 + istanbul-lib-coverage: 3.2.2 + istanbul-lib-report: 3.0.1 + istanbul-lib-source-maps: 5.0.6 + istanbul-reports: 3.2.0 + magic-string: 0.30.17 + magicast: 0.3.5 + std-env: 3.9.0 + test-exclude: 7.0.1 + tinyrainbow: 2.0.0 + vitest: 3.2.4(@types/debug@4.1.12)(@types/node@22.17.0)(jsdom@27.2.0)(terser@5.43.1) + transitivePeerDependencies: + - supports-color + '@vitest/expect@3.2.4': dependencies: '@types/chai': 5.2.2 @@ -27058,11 +27109,11 @@ snapshots: dependencies: istanbul-lib-coverage: 3.2.2 make-dir: 4.0.0 - supports-color: 7.2.0 + supports-color: 8.1.1 istanbul-lib-source-maps@5.0.6: dependencies: - '@jridgewell/trace-mapping': 0.3.30 + '@jridgewell/trace-mapping': 0.3.31 debug: 4.3.7 istanbul-lib-coverage: 3.2.2 transitivePeerDependencies: diff --git a/protographic/package.json b/protographic/package.json index c585b6d949..eee10a9c67 100644 --- a/protographic/package.json +++ b/protographic/package.json @@ -21,6 +21,7 @@ }, "scripts": { "test": "vitest run", + "test:coverage": "vitest run --coverage", "test:update": "vitest run -u", "build": "tsc", "bench": "vitest bench --run", @@ -31,6 +32,7 @@ "devDependencies": { "@types/lodash-es": "4.17.12", "@types/node": "^20.11.5", + "@vitest/coverage-v8": "3.2.4", "typescript": "^5.0.0", "vitest": "^3.2.4" }, diff --git a/router/Makefile b/router/Makefile index 6e395ef9e3..6a51c0341e 100644 --- a/router/Makefile +++ b/router/Makefile @@ -1,3 +1,5 @@ +coverage_file := coverage.out + ifeq ($(CI),true) FORMAT := github-actions else @@ -16,6 +18,9 @@ update-snapshot: test: gotestsum -f $(FORMAT) -- -race ./... +test-coverage: + gotestsum -f $(FORMAT) -- -race -coverprofile=$(coverage_file) -coverpkg=github.com/wundergraph/cosmo/router/... ./... + test-fresh: clean-testcache test lint: @@ -46,4 +51,4 @@ build-custom: generate-mocks: mockery -.PHONY: dev test build lint bump-engine update-snapshot +.PHONY: dev test test-coverage build lint bump-engine update-snapshot diff --git a/studio/package.json b/studio/package.json index 6523a37314..7a364df2f8 100644 --- a/studio/package.json +++ b/studio/package.json @@ -16,6 +16,7 @@ "start": "next start", "lint": "next lint", "test": "vitest run --reporter=default --reporter=hanging-process", + "test:coverage": "vitest run --reporter=default --reporter=hanging-process --coverage", "lint:fix": "next lint --fix", "preinstall": "npx only-allow pnpm", "postinstall": "pnpm run copy-monaco", @@ -133,6 +134,7 @@ "@types/prismjs": "^1.26.3", "@types/react": "18.3.3", "@types/react-dom": "18.3.0", + "@vitest/coverage-v8": "3.2.4", "@vitejs/plugin-react": "^4.2.1", "autoprefixer": "10.4.14", "cross-env": "^7.0.3",