Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/cli-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codecov-post-merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment thread
StarpTech marked this conversation as resolved.
override-commit: ${{ github.sha }}
merge-commit-sha: ${{ steps.find-pr-commit.outputs.merge_commit_sha }}
codecov-token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
26 changes: 23 additions & 3 deletions .github/workflows/composition-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
15 changes: 13 additions & 2 deletions .github/workflows/controlplane-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ env:

jobs:
build_test:
timeout-minutes: 10
timeout-minutes: 15
runs-on: ubuntu-latest
services:
redis:
Expand Down Expand Up @@ -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 }}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

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
Expand All @@ -103,3 +113,4 @@ jobs:
token: ${{secrets.GITHUB_TOKEN}}
image_name: controlplane
image_description: "Cosmo Controlplane"

10 changes: 9 additions & 1 deletion .github/workflows/graphqlmetrics-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/protographic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down Expand Up @@ -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 }}
14 changes: 11 additions & 3 deletions .github/workflows/router-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand All @@ -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:
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/studio-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 28 additions & 2 deletions codecov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Comment thread
SkArchon marked this conversation as resolved.
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
4 changes: 4 additions & 0 deletions composition-go/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions composition/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions controlplane/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
7 changes: 6 additions & 1 deletion graphqlmetrics/Makefile
Original file line number Diff line number Diff line change
@@ -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/... ./...
Comment thread
coderabbitai[bot] marked this conversation as resolved.

new-migration:
dbmate -d "./migrations" new $(name)

Expand All @@ -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
.PHONY: dev test test-coverage new-migration migrate build
Loading
Loading