From a9486c8b4676e8b617289840174df4c4a63cfdbf Mon Sep 17 00:00:00 2001 From: Milinda Dias Date: Wed, 10 Dec 2025 20:11:05 +0530 Subject: [PATCH 01/11] feat: add coverage for other services --- .github/workflows/composition-ci.yaml | 20 +++++ .github/workflows/controlplane-ci.yaml | 13 +++- .github/workflows/graphqlmetrics-ci.yaml | 8 ++ .github/workflows/protographic.yaml | 12 ++- .github/workflows/router-ci.yaml | 10 ++- .github/workflows/studio-ci.yaml | 12 ++- composition-go/Makefile | 4 + composition/package.json | 2 + controlplane/package.json | 2 + graphqlmetrics/Makefile | 5 ++ pnpm-lock.yaml | 97 ++++++++++++++++++------ protographic/package.json | 2 + router/Makefile | 5 ++ studio/package.json | 2 + 14 files changed, 167 insertions(+), 27 deletions(-) diff --git a/.github/workflows/composition-ci.yaml b/.github/workflows/composition-ci.yaml index ac44fd5ca7..d871807f2d 100644 --- a/.github/workflows/composition-ci.yaml +++ b/.github/workflows/composition-ci.yaml @@ -50,6 +50,16 @@ jobs: - 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: 7 + codecov-token: ${{ secrets.CODECOV_TOKEN }} + - name: Run linter on composition-go uses: ./.github/actions/go-linter with: @@ -62,3 +72,13 @@ jobs: - name: Test Go library with V8 run: go test -tags wg_composition_v8 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: 7 + 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..2b6412bf88 100644 --- a/.github/workflows/controlplane-ci.yaml +++ b/.github/workflows/controlplane-ci.yaml @@ -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: cli-one + coverage-path: | + controlplane/coverage/clover.xml + controlplane/coverage/coverage-final.json + retention-days: 7 + 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..f1552ab76d 100644 --- a/.github/workflows/graphqlmetrics-ci.yaml +++ b/.github/workflows/graphqlmetrics-ci.yaml @@ -66,6 +66,14 @@ jobs: 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: 7 + 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..a37661cb15 100644 --- a/.github/workflows/protographic.yaml +++ b/.github/workflows/protographic.yaml @@ -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: 7 + codecov-token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/router-ci.yaml b/.github/workflows/router-ci.yaml index ca4197eea4..90d5d5c056 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: 7 + codecov-token: ${{ secrets.CODECOV_TOKEN }} + integration_test: runs-on: ubuntu-latest-l timeout-minutes: 30 diff --git a/.github/workflows/studio-ci.yaml b/.github/workflows/studio-ci.yaml index edb5d962b9..3b533b4177 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: 7 + 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/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..741f8e25de 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) 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..f364149053 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: 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", From 1ea81994269f87d3c40aeaffdcb67f6e88f4a177 Mon Sep 17 00:00:00 2001 From: Milinda Dias Date: Wed, 10 Dec 2025 20:26:20 +0530 Subject: [PATCH 02/11] fix: cleanup --- .github/workflows/codecov-post-merge.yaml | 2 +- .github/workflows/controlplane-ci.yaml | 4 ++-- .github/workflows/protographic.yaml | 2 +- graphqlmetrics/Makefile | 2 +- router/Makefile | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/codecov-post-merge.yaml b/.github/workflows/codecov-post-merge.yaml index 6496de799f..5e219cafa3 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/router-ci.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/controlplane-ci.yaml b/.github/workflows/controlplane-ci.yaml index 2b6412bf88..60914a458f 100644 --- a/.github/workflows/controlplane-ci.yaml +++ b/.github/workflows/controlplane-ci.yaml @@ -81,14 +81,14 @@ jobs: run: nohup .github/scripts/setup-keycloak.sh & - name: Test - run: pnpm run --filter controlplane test-coverage + 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: cli-one + artifact-name: controlplane-tests-coverage coverage-path: | controlplane/coverage/clover.xml controlplane/coverage/coverage-final.json diff --git a/.github/workflows/protographic.yaml b/.github/workflows/protographic.yaml index a37661cb15..f7c711677a 100644 --- a/.github/workflows/protographic.yaml +++ b/.github/workflows/protographic.yaml @@ -36,7 +36,7 @@ jobs: run: pnpm run --filter ./connect --filter ./protographic build - name: Test - run: pnpm run --filter ./protographic test-coverage + run: pnpm run --filter ./protographic test:coverage - name: Lint run: pnpm run --filter ./protographic lint diff --git a/graphqlmetrics/Makefile b/graphqlmetrics/Makefile index 741f8e25de..6b59fe545e 100644 --- a/graphqlmetrics/Makefile +++ b/graphqlmetrics/Makefile @@ -23,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/router/Makefile b/router/Makefile index f364149053..6a51c0341e 100644 --- a/router/Makefile +++ b/router/Makefile @@ -51,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 From b7355200a23bcba06d0567dee9667bdbfaeb1a3c Mon Sep 17 00:00:00 2001 From: Milinda Dias Date: Wed, 10 Dec 2025 20:27:31 +0530 Subject: [PATCH 03/11] fix: ci --- .github/workflows/graphqlmetrics-ci.yaml | 2 +- .github/workflows/protographic.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/graphqlmetrics-ci.yaml b/.github/workflows/graphqlmetrics-ci.yaml index f1552ab76d..c3132c0ddb 100644 --- a/.github/workflows/graphqlmetrics-ci.yaml +++ b/.github/workflows/graphqlmetrics-ci.yaml @@ -60,7 +60,7 @@ jobs: - name: Test working-directory: ./graphqlmetrics - run: make test + run: make test-coverage - name: Build working-directory: ./graphqlmetrics diff --git a/.github/workflows/protographic.yaml b/.github/workflows/protographic.yaml index f7c711677a..c5ae45e115 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}} From d9b63cafa1adeb19538f1cbec75a4e7ba6f613fb Mon Sep 17 00:00:00 2001 From: Milinda Dias Date: Wed, 10 Dec 2025 21:55:20 +0530 Subject: [PATCH 04/11] fix: codecov --- .github/workflows/codecov-post-merge.yaml | 2 +- .github/workflows/composition-ci.yaml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codecov-post-merge.yaml b/.github/workflows/codecov-post-merge.yaml index 5e219cafa3..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,.github/workflows/composition-ci.yaml,.github/workflows/controlplane-ci.yaml,.github/workflows/graphqlmetrics-ci.yaml,.github/workflows/protographic.yaml,.github/workflows/router-ci.yaml,.github/workflows/studio-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 d871807f2d..3b8c5534eb 100644 --- a/.github/workflows/composition-ci.yaml +++ b/.github/workflows/composition-ci.yaml @@ -45,7 +45,7 @@ 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 @@ -66,11 +66,11 @@ jobs: 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 From 65b24d3960a7e660a013f31b1ebdcd846306c8f5 Mon Sep 17 00:00:00 2001 From: Milinda Dias Date: Wed, 10 Dec 2025 22:12:53 +0530 Subject: [PATCH 05/11] fix: add carryforward flags --- codecov.yaml | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/codecov.yaml b/codecov.yaml index 364bc9884e..9b324e8852 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: 50 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 From ff81f04fe227c687978f1cd251ea49559f742a8d Mon Sep 17 00:00:00 2001 From: Milinda Dias Date: Wed, 10 Dec 2025 22:16:54 +0530 Subject: [PATCH 06/11] fix: increase timeout --- .github/workflows/controlplane-ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/controlplane-ci.yaml b/.github/workflows/controlplane-ci.yaml index 60914a458f..dd7cdc9ed5 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: 17 runs-on: ubuntu-latest services: redis: From f41db33529b2def5a1c34b30c96680527fde1364 Mon Sep 17 00:00:00 2001 From: Milinda Dias Date: Thu, 11 Dec 2025 01:46:28 +0530 Subject: [PATCH 07/11] fix: updates --- .github/workflows/controlplane-ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/controlplane-ci.yaml b/.github/workflows/controlplane-ci.yaml index dd7cdc9ed5..ac0d5ab3e8 100644 --- a/.github/workflows/controlplane-ci.yaml +++ b/.github/workflows/controlplane-ci.yaml @@ -20,7 +20,7 @@ env: jobs: build_test: - timeout-minutes: 17 + timeout-minutes: 12 runs-on: ubuntu-latest services: redis: From cb7c1e23ef272201ffbddb2a7e8cefa269270508 Mon Sep 17 00:00:00 2001 From: Milinda Dias Date: Thu, 11 Dec 2025 01:46:38 +0530 Subject: [PATCH 08/11] fix: updates --- .github/workflows/controlplane-ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/controlplane-ci.yaml b/.github/workflows/controlplane-ci.yaml index ac0d5ab3e8..87a6a436f4 100644 --- a/.github/workflows/controlplane-ci.yaml +++ b/.github/workflows/controlplane-ci.yaml @@ -20,7 +20,7 @@ env: jobs: build_test: - timeout-minutes: 12 + timeout-minutes: 15 runs-on: ubuntu-latest services: redis: From 74452111b5ca72cde17dfd84cbe0180769ab222e Mon Sep 17 00:00:00 2001 From: Milinda Dias Date: Thu, 11 Dec 2025 15:47:36 +0530 Subject: [PATCH 09/11] fix: ci and retenteion related updates --- .github/workflows/cli-ci.yaml | 2 +- .github/workflows/composition-ci.yaml | 4 ++-- .github/workflows/controlplane-ci.yaml | 2 +- .github/workflows/graphqlmetrics-ci.yaml | 2 +- .github/workflows/protographic.yaml | 2 +- .github/workflows/router-ci.yaml | 6 +++--- .github/workflows/studio-ci.yaml | 2 +- codecov.yaml | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) 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/composition-ci.yaml b/.github/workflows/composition-ci.yaml index 3b8c5534eb..cdc8ae4fea 100644 --- a/.github/workflows/composition-ci.yaml +++ b/.github/workflows/composition-ci.yaml @@ -57,7 +57,7 @@ jobs: coverage-path: | composition/coverage/clover.xml composition/coverage/coverage-final.json - retention-days: 7 + retention-days: 14 codecov-token: ${{ secrets.CODECOV_TOKEN }} - name: Run linter on composition-go @@ -80,5 +80,5 @@ jobs: coverage-path: | composition-go/coverage_normal.out composition-go/coverage_v8.out - retention-days: 7 + 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 87a6a436f4..4a30855a49 100644 --- a/.github/workflows/controlplane-ci.yaml +++ b/.github/workflows/controlplane-ci.yaml @@ -92,7 +92,7 @@ jobs: coverage-path: | controlplane/coverage/clover.xml controlplane/coverage/coverage-final.json - retention-days: 7 + retention-days: 14 codecov-token: ${{ secrets.CODECOV_TOKEN }} build_push_image: diff --git a/.github/workflows/graphqlmetrics-ci.yaml b/.github/workflows/graphqlmetrics-ci.yaml index c3132c0ddb..15daea0dd7 100644 --- a/.github/workflows/graphqlmetrics-ci.yaml +++ b/.github/workflows/graphqlmetrics-ci.yaml @@ -71,7 +71,7 @@ jobs: with: artifact-name: graphqlmetrics-tests-coverage coverage-path: graphqlmetrics/coverage.out - retention-days: 7 + retention-days: 14 codecov-token: ${{ secrets.CODECOV_TOKEN }} build_push_image: diff --git a/.github/workflows/protographic.yaml b/.github/workflows/protographic.yaml index c5ae45e115..17b4c1c31a 100644 --- a/.github/workflows/protographic.yaml +++ b/.github/workflows/protographic.yaml @@ -48,5 +48,5 @@ jobs: coverage-path: | protographic/coverage/clover.xml protographic/coverage/coverage-final.json - retention-days: 7 + retention-days: 14 codecov-token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/router-ci.yaml b/.github/workflows/router-ci.yaml index 90d5d5c056..ba9cec5318 100644 --- a/.github/workflows/router-ci.yaml +++ b/.github/workflows/router-ci.yaml @@ -186,7 +186,7 @@ jobs: with: artifact-name: router-tests-coverage coverage-path: router/coverage.out - retention-days: 7 + retention-days: 14 codecov-token: ${{ secrets.CODECOV_TOKEN }} integration_test: @@ -383,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 }} @@ -395,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 3b533b4177..9862b4339e 100644 --- a/.github/workflows/studio-ci.yaml +++ b/.github/workflows/studio-ci.yaml @@ -62,7 +62,7 @@ jobs: coverage-path: | studio/coverage/clover.xml studio/coverage/coverage-final.json - retention-days: 7 + retention-days: 14 codecov-token: ${{ secrets.CODECOV_TOKEN }} build_push_image: diff --git a/codecov.yaml b/codecov.yaml index 9b324e8852..029b7fe5fe 100644 --- a/codecov.yaml +++ b/codecov.yaml @@ -7,7 +7,7 @@ coverage: informational: true # We don't want to block PRs based on the result project: default: - target: 50 + target: 30 threshold: 5 informational: true # We don't want to block PRs based on the result From 9d21adbd1a9b53ab84503d5c99f4bb538ff9e286 Mon Sep 17 00:00:00 2001 From: Milinda Dias Date: Thu, 11 Dec 2025 15:50:10 +0530 Subject: [PATCH 10/11] fix: update contributing --- CONTRIBUTING.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 60b0cb8a13..f7985bda19 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) +``` +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 +``` +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 From 7c63acc7ec70332fbf62cd7b29b79a22141ee83b Mon Sep 17 00:00:00 2001 From: Milinda Dias Date: Thu, 11 Dec 2025 17:04:58 +0530 Subject: [PATCH 11/11] fix: review comments --- CONTRIBUTING.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f7985bda19..822a175af5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -170,7 +170,7 @@ We manage multiple compose files: 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). +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 @@ -182,7 +182,7 @@ In order to circumvent this we do the following steps: 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: @@ -190,10 +190,10 @@ flags: 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` +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!**