Skip to content

Commit

Permalink
feat: prepare release pipeline (wundergraph#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
StarpTech authored Aug 23, 2023
1 parent 748e072 commit 747aa47
Show file tree
Hide file tree
Showing 41 changed files with 3,932 additions and 154 deletions.
64 changes: 0 additions & 64 deletions .github/workflows/images-tags.yaml

This file was deleted.

19 changes: 16 additions & 3 deletions .github/workflows/images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ jobs:
- container_name: studio
dockerfile: studio/Dockerfile
context_path: .
- container_name: keycloak
dockerfile: keycloak/Dockerfile
context_path: keycloak
- container_name: otelcollector
dockerfile: otelcollector/Dockerfile
context_path: otelcollector

runs-on: ubuntu-latest
permissions:
Expand All @@ -35,7 +41,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
- name: Log in to Github Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
Expand All @@ -46,11 +52,16 @@ jobs:
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.container_name }}
images: |
${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.container_name }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha,format=long,prefix=sha256-
type=sha
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
# use custom value instead of git tag
type=match,pattern=[a-zA-Z-_]+@(.*),group=1
- name: Install Docker Buildx
uses: docker/setup-buildx-action@v2
Expand All @@ -63,3 +74,5 @@ jobs:
context: ${{ matrix.context_path }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.container_name }}:buildcache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.container_name }}:buildcache,mode=max
48 changes: 48 additions & 0 deletions .github/workflows/packages-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: NPM Packages Release

on:
workflow_dispatch:

concurrency:
group: ${{github.workflow}}-${{github.head_ref}}
cancel-in-progress: false

env:
CI: true

jobs:
stable-version:
# https://docs.npmjs.com/generating-provenance-statements#publishing-packages-with-provenance-via-github-actions
permissions:
id-token: write
timeout-minutes: 20
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.GH_TOKEN_WORKFLOW_PUBLISH }}
- uses: ./.github/actions/node
with:
working-directory: ${{ env.WORKING_DIRECTORY }}
repo-token: ${{ secrets.GITHUB_TOKEN }}

- run: npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
shell: bash
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Install
run: pnpm install

- name: Build
run: pnpm build

- name: Publish packages & Create Github Releases
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
pnpm release
env:
GH_TOKEN: ${{ secrets.GH_TOKEN_WORKFLOW_PUBLISH }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ strict-peer-dependencies=false # If this is enabled, commands will fail if there
fetch-retries="10"
ignore-workspace-root-check=true
dedupe-peer-dependents=false
provenance=true
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ setup-tools:
go install github.com/bufbuild/connect-go/cmd/protoc-gen-connect-go@latest
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install github.com/yannh/kubeconform/cmd/kubeconform@latest
go install github.com/maykonlf/semver-cli/cmd/semver@latest

prerequisites: setup-tools
go version
Expand Down Expand Up @@ -88,11 +89,11 @@ docker-push-local:
docker compose --file docker-compose.cosmo.yml push

docker-build-minikube: docker-build-local
minikube image load us-docker.pkg.dev/wg-cosmo/cloud/studio:latest & \
minikube image load us-docker.pkg.dev/wg-cosmo/cloud/controlplane:latest & \
minikube image load us-docker.pkg.dev/wg-cosmo/cosmo/otelcollector:latest & \
minikube image load us-docker.pkg.dev/wg-cosmo/cloud/router:latest & \
minikube image load us-docker.pkg.dev/wg-cosmo/cosmo/otelcollector:latest
minikube image load ghcr.io/wundergraph/cosmo/studio:latest & \
minikube image load ghcr.io/wundergraph/cosmo/controlplane:latest & \
minikube image load ghcr.io/wundergraph/cosmo/otelcollector:latest & \
minikube image load ghcr.io/wundergraph/cosmo/router:latest & \
minikube image load ghcr.io/wundergraph/cosmo/keycloak:latest
minikube cache reload

new-ch-migration:
Expand All @@ -111,4 +112,4 @@ migrate-ch-dump:
dbmate -d "./controlplane/clickhouse/migrations" -s "./controlplane/db/schema.sql" -e CLICKHOUSE_DSN dump

build-kc-theme:
(cd keycloak/theme && npm i && ./build.sh)
(cd keycloak/theme && npm i && ./build.sh)
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ _Clean up all containers and volumes by running `make full-demo-down`._
- [NodeJS 18+](https://nodejs.org/en/download/)
- [PNPM 8+](https://pnpm.io/installation)
- [Go 1.20+](https://golang.org/doc/install)
- [Java 17 SDK](https://www.oracle.com/java/technologies/downloads/#java17)

Bootstrapping your development environment is easy. Just run the following commands in order:

Expand Down
2 changes: 1 addition & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wgc",
"version": "0.0.1",
"version": "0.0.0",
"description": "The official CLI tool to manage the GraphQL Federation Platform Cosmo",
"type": "module",
"main": "dist/index.js",
Expand Down
2 changes: 0 additions & 2 deletions composition/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
"scripts": {
"dev": "tsc --watch",
"build": "del dist && tsc",
"prepublish": "pnpm run build && pnpm run test",
"release": "pnpm publish --access restricted --tag latest",
"test": "vitest test"
},
"main": "./dist/index.js",
Expand Down
6 changes: 3 additions & 3 deletions controlplane/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "cosmo-controlplane",
"name": "controlplane",
"version": "0.0.0",
"private": true,
"version": "0.1.0",
"description": "",
"description": "WunderGraph Cosmo Controlplane",
"type": "module",
"main": "dist/index.js",
"author": {
Expand Down
2 changes: 1 addition & 1 deletion controlplane/src/core/test-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { randomUUID } from 'node:crypto';
import postgres from 'postgres';
import nuid from 'nuid';
import { drizzle } from 'drizzle-orm/postgres-js';
import { ExpiresAt } from 'node_modules/@wundergraph/cosmo-connect/dist/platform/v1/platform_pb.js';
import { ExpiresAt } from '@wundergraph/cosmo-connect/dist/platform/v1/platform_pb';
import { Label, UserAuthContext } from '../types/index.js';
import * as schema from '../db/schema.js';
import { Authenticator } from './services/Authentication.js';
Expand Down
14 changes: 13 additions & 1 deletion controlplane/test/api-keys.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe('API Keys', (ctx) => {
adminUser: 'admin',
adminPassword: 'changeme',
apiUrl: 'http://localhost:8080',
frontendUrl: 'http://localhost:8080',
clientId: 'studio',
},
}),
Expand Down Expand Up @@ -84,7 +85,18 @@ describe('API Keys', (ctx) => {
expect(response.response?.code).toBe(EnumStatusCode.ERR_ALREADY_EXISTS);

// test when api key name is wrong
response = await client.createAPIKey({ name: 'a b', expires: ExpiresAt.NEVER, userID: userTestData.userId });
response = await client.createAPIKey({
name: 'a'.repeat(100),
expires: ExpiresAt.NEVER,
userID: userTestData.userId,
});
expect(response.response?.code).toBe(EnumStatusCode.ERR);

response = await client.createAPIKey({
name: '',
expires: ExpiresAt.NEVER,
userID: userTestData.userId,
});
expect(response.response?.code).toBe(EnumStatusCode.ERR);

let deleteResponse = await client.deleteAPIKey({ name: 'test' });
Expand Down
1 change: 1 addition & 0 deletions controlplane/test/apollo-federation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ describe('Apollo Federated Graph', (ctx) => {
adminUser: 'admin',
adminPassword: 'changeme',
apiUrl: 'http://localhost:8080',
frontendUrl: 'http://localhost:8080',
clientId: 'studio',
},
}),
Expand Down
3 changes: 1 addition & 2 deletions controlplane/test/authenthication.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ describe('Authentication', (ctx) => {
},
allowedOrigins: [],
auth: {
clientId: 'test',
secret: 'secret',
openIdApiBaseUrl: 'http://localhost:8080',
redirectUri: 'http://localhost:3000',
webBaseUrl: 'http://localhost:3000',
webErrorPath: '/error',
Expand All @@ -43,6 +41,7 @@ describe('Authentication', (ctx) => {
adminUser: 'admin',
adminPassword: 'changeme',
apiUrl: 'http://localhost:8080',
frontendUrl: 'http://localhost:8080',
clientId: 'studio',
},
});
Expand Down
1 change: 1 addition & 0 deletions controlplane/test/check-federated-graph.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe('CheckFederatedGraph', (ctx) => {
adminUser: 'admin',
adminPassword: 'changeme',
apiUrl: 'http://localhost:8080',
frontendUrl: 'http://localhost:8080',
clientId: 'studio',
},
}),
Expand Down
3 changes: 3 additions & 0 deletions controlplane/test/check-subgraph-schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ describe('CheckSubgraphSchema', (ctx) => {
adminUser: 'admin',
adminPassword: 'changeme',
apiUrl: 'http://localhost:8080',
frontendUrl: 'http://localhost:8080',
clientId: 'studio',
},
}),
Expand Down Expand Up @@ -140,6 +141,7 @@ describe('CheckSubgraphSchema', (ctx) => {
adminUser: 'admin',
adminPassword: 'changeme',
apiUrl: 'http://localhost:8080',
frontendUrl: 'http://localhost:8080',
clientId: 'studio',
},
}),
Expand Down Expand Up @@ -222,6 +224,7 @@ describe('CheckSubgraphSchema', (ctx) => {
adminUser: 'admin',
adminPassword: 'changeme',
apiUrl: 'http://localhost:8080',
frontendUrl: 'http://localhost:8080',
clientId: 'studio',
},
}),
Expand Down
1 change: 1 addition & 0 deletions controlplane/test/compose-federationv1-graphs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ describe('ComposeFederationV1Graphs', (ctx) => {
adminUser: 'admin',
adminPassword: 'changeme',
apiUrl: 'http://localhost:8080',
frontendUrl: 'http://localhost:8080',
clientId: 'studio',
},
}),
Expand Down
1 change: 1 addition & 0 deletions controlplane/test/compose-federationv2-graphs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ describe('ComposeFederationV2Graphs', (ctx) => {
adminUser: 'admin',
adminPassword: 'changeme',
apiUrl: 'http://localhost:8080',
frontendUrl: 'http://localhost:8080',
clientId: 'studio',
},
}),
Expand Down
1 change: 1 addition & 0 deletions controlplane/test/composition-errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ describe('CompositionErrors', (ctx) => {
adminUser: 'admin',
adminPassword: 'changeme',
apiUrl: 'http://localhost:8080',
frontendUrl: 'http://localhost:8080',
clientId: 'studio',
},
}),
Expand Down
1 change: 1 addition & 0 deletions controlplane/test/delete-federated-graph.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ describe('DeleteFederatedGraph', (ctx) => {
adminUser: 'admin',
adminPassword: 'changeme',
apiUrl: 'http://localhost:8080',
frontendUrl: 'http://localhost:8080',
clientId: 'studio',
},
}),
Expand Down
1 change: 1 addition & 0 deletions controlplane/test/delete-subgraph.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ describe('DeleteSubgraph', (ctx) => {
adminUser: 'admin',
adminPassword: 'changeme',
apiUrl: 'http://localhost:8080',
frontendUrl: 'http://localhost:8080',
clientId: 'studio',
},
}),
Expand Down
Loading

0 comments on commit 747aa47

Please sign in to comment.