diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 84166db..e85fa42 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -47,3 +47,12 @@ jobs: with: setup-go: "true" - run: make test-ci + subgraphs-check: + name: Check GraphQL schemas + runs-on: ubuntu-latest + env: + COSMO_API_KEY: ${{ secrets.COSMO_API_KEY }} + steps: + - uses: actions/checkout@v6.0.2 + - uses: ./.github/actions/setup + - run: make check-subgraphs diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..701672f --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,17 @@ +name: CI + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + env: + COSMO_API_KEY: ${{ secrets.COSMO_API_KEY }} + steps: + - uses: actions/checkout@v6.0.2 + - uses: ./.github/actions/setup + - run: make check-subgraphs + - run: make publish-ci diff --git a/Makefile b/Makefile index 20c3e92..1671d61 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,9 @@ build-ci: compose: @pnpm compose +check-subgraphs: + @pnpm subgraphs:check + # Build linux plugin binary + Docker image (run `make compose` first if config.json is missing) # for local development # Usage: make docker-local @@ -26,6 +29,9 @@ docker-local: generate: @pnpm generate +publish-ci: + @pnpm publish:ci + # Test all plugins test: @pnpm test diff --git a/README.md b/README.md index 5bbbe66..db6235a 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Run `wgc demo` and make sure you are logged in to your Cosmo Cloud account. Foll ### Implementing `averageRating` field 1. Fork this repo. -2. Add `ROUTER_TOKEN` to your CI secrets (TBD - Github workflow) +2. Create a secret named `COSMO_API_KEY` for your forked repo with your private API key ([Studio API Keys documentation](https://cosmo-docs.wundergraph.com/studio/api-keys)). 3. In `plugins/reviews/src/schema.graphql` expand the schema file: ```diff @@ -64,7 +64,7 @@ Run `wgc demo` and make sure you are logged in to your Cosmo Cloud account. Foll ``` 4. Run `make generate` in `plugins/reviews` directory to generate gRPC methods. -5. Add the new field `AverageRating` to the `Product` struct, using `calculateAverageRating` function that is provided: +5. Add the new field `AverageRating` to the `Product` struct in `plugins/reviews/src/main.go`. Use the `calculateAverageRating` function that is provided to implement the calculation: ```diff @@ -62,6 +62,7 @@ func (s *ReviewsService) LookupProductById(ctx context.Context, req *service.Loo diff --git a/package.json b/package.json index 9649c80..3be75e6 100644 --- a/package.json +++ b/package.json @@ -8,10 +8,12 @@ "build": "pnpm -r build", "build:ci": "pnpm -r --workspace-concurrency=1 build:ci", "compose": "wgc router compose -i ./plugins/graph.yaml -o ./config.json", + "subgraphs:check": "pnpm -r subgraph:check", "format": "pnpm -r format", "generate": "pnpm -r generate", "lint": "pnpm -r lint", "lint:ci": "pnpm -r lint:ci", + "publish:ci": "pnpm -r --workspace-concurrency=1 publish:ci", "test": "pnpm -r test", "test:ci": "pnpm -r --workspace-concurrency=1 test:ci", "start": "pnpm build && pnpm compose && make docker-local && docker run --rm -p 3002:3002 cosmo-demo-local" diff --git a/plugins/products/package.json b/plugins/products/package.json index f5e52af..8833098 100644 --- a/plugins/products/package.json +++ b/plugins/products/package.json @@ -11,6 +11,8 @@ "generate": "wgc router plugin generate .", "lint": "golangci-lint run ./...", "lint:ci": "golangci-lint run --allow-parallel-runners ./...", + "publish:ci": "wgc router plugin publish --namespace default --label graph=demo --fail-on-composition-error .", + "subgraph:check": "wgc subgraph check reviews --namespace default --label graph=demo --schema ./src/schema.graphql", "test": "wgc router plugin test .", "test:ci": "wgc router plugin test . --yes" }, diff --git a/plugins/reviews/package.json b/plugins/reviews/package.json index d82d366..8f84bba 100644 --- a/plugins/reviews/package.json +++ b/plugins/reviews/package.json @@ -11,6 +11,8 @@ "generate": "wgc router plugin generate .", "lint": "golangci-lint run ./...", "lint:ci": "golangci-lint run --allow-parallel-runners ./...", + "publish:ci": "wgc router plugin publish --namespace default --label graph=demo --fail-on-composition-error .", + "subgraph:check": "wgc subgraph check reviews --namespace default --label graph=demo --schema ./src/schema.graphql", "test": "wgc router plugin test .", "test:ci": "wgc router plugin test . --yes" },