Run jobs in parallel (#48)

This commit is contained in:
Kamil Kisiela 2022-05-20 13:51:02 +02:00 committed by GitHub
parent 908061a4e5
commit 57ef12defa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 267 additions and 144 deletions

View file

@ -8,6 +8,7 @@ module.exports = {
'public',
'packages/web/app/src/graphql/index.ts',
'packages/libraries/cli/src/sdk.ts',
'packages/services/storage/src/db/types.ts',
],
parserOptions: {
ecmaVersion: 2020,

View file

@ -1,4 +1,4 @@
name: ci/cd
name: CD
on:
push:
branches:

244
.github/workflows/ci.yaml vendored Normal file
View file

@ -0,0 +1,244 @@
name: CI
on: [pull_request]
jobs:
setup:
name: 'Setup'
runs-on: ubuntu-latest
services:
postgres:
image: postgres:13.1-alpine
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
TURBO_PREFLIGHT: 'true'
TURBO_API_URL: ${{ secrets.TURBO_API_URL }}
steps:
- name: Check out repository code
uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: 16
- name: Install Dependencies
run: yarn --frozen-lockfile
- name: Create Database
working-directory: packages/services/storage
run: yarn db:create
- name: Migrate Database
working-directory: packages/services/storage
run: yarn db:migrator up
- name: Generate Database Types
working-directory: packages/services/storage
run: yarn db:generate
- name: Check if DB types were modified
run: git diff --exit-code ./packages/services/storage/src/db/types.ts
- name: Share node_modules
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ github.sha }}
integration-tests:
name: 'Integration Tests'
runs-on: ubuntu-latest
needs: setup
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
TURBO_PREFLIGHT: 'true'
TURBO_API_URL: ${{ secrets.TURBO_API_URL }}
steps:
- name: Check out repository code
uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: 16
- name: Pull node_modules
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ github.sha }}
- name: Build
run: yarn workspace integration-tests run build-and-pack
env:
NEXT_PUBLIC_STRIPE_PUBLIC_KEY: ${{ secrets.TEST_STRIPE_PUBLIC_KEY }}
- name: Pull images
run: docker-compose -f integration-tests/docker-compose.yml pull
- name: Integration Tests
run: yarn workspace integration-tests run dockest
env:
AUTH0_DOMAIN: ${{ secrets.TEST_AUTH0_DOMAIN }}
AUTH0_CLIENT_ID: ${{ secrets.TEST_AUTH0_CLIENT_ID }}
AUTH0_CLIENT_SECRET: ${{ secrets.TEST_AUTH0_CLIENT_SECRET }}
AUTH0_USER_PASSWORD: ${{ secrets.AUTH0_TESTING_USER_PASSWORD }}
AUTH0_USER_MAIN_EMAIL: contact@the-guild.dev
AUTH0_USER_EXTRA_EMAIL: contact+extra@the-guild.dev
AUTH0_SECRET: ${{ secrets.TEST_AUTH0_SECRET }}
AUTH0_AUDIENCE: ${{ secrets.TEST_AUTH0_AUDIENCE }}
AUTH0_CONNECTION: Username-Password-Authentication
STRIPE_SECRET_KEY: ${{ secrets.TEST_STRIPE_SECRET_KEY }}
- name: Dockest logs
if: always()
run: cat integration-tests/*.log
schema-check:
name: 'Schema Check'
runs-on: ubuntu-latest
needs: setup
env:
HIVE_TOKEN: ${{ secrets.HIVE_TOKEN }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
TURBO_PREFLIGHT: 'true'
TURBO_API_URL: ${{ secrets.TURBO_API_URL }}
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- name: Pull node_modules
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ github.sha }}
- name: Generate Types
run: yarn graphql:generate
- name: Check PR label
if: contains(github.event.pull_request.labels.*.name, 'non-breaking')
run: echo '::set-output name=SAFE_FLAG::--forceSafe'
id: pr-label-check
- name: Schema Check
run: ./packages/libraries/cli/bin/dev schema:check "packages/services/api/src/modules/*/module.graphql.ts" ${{ steps.pr-label-check.outputs.SAFE_FLAG }} --github
test:
name: 'Tests'
runs-on: ubuntu-latest
needs: setup
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
TURBO_PREFLIGHT: 'true'
TURBO_API_URL: ${{ secrets.TURBO_API_URL }}
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- name: Pull node_modules
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ github.sha }}
- name: Generate Types
run: yarn graphql:generate
- name: Test
run: yarn test
build:
name: 'Build'
runs-on: ubuntu-latest
needs: setup
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
TURBO_PREFLIGHT: 'true'
TURBO_API_URL: ${{ secrets.TURBO_API_URL }}
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- name: Pull node_modules
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ github.sha }}
- name: Generate Types
run: yarn graphql:generate
- name: Build
run: yarn build
type-check:
name: 'Check types'
runs-on: ubuntu-latest
needs: setup
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
TURBO_PREFLIGHT: 'true'
TURBO_API_URL: ${{ secrets.TURBO_API_URL }}
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- name: Pull node_modules
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ github.sha }}
- name: Generate Types
run: yarn graphql:generate
- name: Type Check
run: yarn typecheck

View file

@ -1,58 +0,0 @@
name: Integration Tests
on: [pull_request]
jobs:
integration-tests:
runs-on: ubuntu-latest
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
TURBO_PREFLIGHT: 'true'
TURBO_API_URL: ${{ secrets.TURBO_API_URL }}
steps:
- name: Check out repository code
uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: 16
- name: Install Dependencies
run: yarn --frozen-lockfile
- uses: actions/cache@v3
name: Turbo cache
with:
path: node_modules/.cache/turbo
key: ${{ runner.os }}-turbo-cache-v1-${{ hashFiles('yarn.lock') }}
- name: Generate Types
run: yarn graphql:generate
- name: Build
run: yarn workspace integration-tests run build-and-pack
env:
NEXT_PUBLIC_STRIPE_PUBLIC_KEY: ${{ secrets.TEST_STRIPE_PUBLIC_KEY }}
- name: Pull images
run: docker-compose -f integration-tests/docker-compose.yml pull
- name: Integration Tests
run: yarn workspace integration-tests run dockest
env:
AUTH0_DOMAIN: ${{ secrets.TEST_AUTH0_DOMAIN }}
AUTH0_CLIENT_ID: ${{ secrets.TEST_AUTH0_CLIENT_ID }}
AUTH0_CLIENT_SECRET: ${{ secrets.TEST_AUTH0_CLIENT_SECRET }}
AUTH0_USER_PASSWORD: ${{ secrets.AUTH0_TESTING_USER_PASSWORD }}
AUTH0_USER_MAIN_EMAIL: contact@the-guild.dev
AUTH0_USER_EXTRA_EMAIL: contact+extra@the-guild.dev
AUTH0_SECRET: ${{ secrets.TEST_AUTH0_SECRET }}
AUTH0_AUDIENCE: ${{ secrets.TEST_AUTH0_AUDIENCE }}
AUTH0_CONNECTION: Username-Password-Authentication
STRIPE_SECRET_KEY: ${{ secrets.TEST_STRIPE_SECRET_KEY }}
- name: Dockest logs
if: always()
run: cat integration-tests/*.log

View file

@ -1,78 +0,0 @@
name: PR Checks
on: [pull_request]
jobs:
pr-checks:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:13.1-alpine
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
HIVE_TOKEN: ${{ secrets.HIVE_TOKEN }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
TURBO_PREFLIGHT: 'true'
TURBO_API_URL: ${{ secrets.TURBO_API_URL }}
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- name: Install Dependencies
run: yarn --frozen-lockfile
- uses: actions/cache@v3
name: Turbo cache
with:
path: node_modules/.cache/turbo
key: ${{ runner.os }}-turbo-cache-v1-${{ hashFiles('yarn.lock') }}
- name: Generate Types
run: yarn graphql:generate
- name: Check PR label
if: contains(github.event.pull_request.labels.*.name, 'non-breaking')
run: echo '::set-output name=SAFE_FLAG::--forceSafe'
id: pr-label-check
- name: Schema Check
run: ./packages/libraries/cli/bin/dev schema:check "packages/services/api/src/modules/*/module.graphql.ts" ${{ steps.pr-label-check.outputs.SAFE_FLAG }} --github
- name: Create Database
working-directory: packages/services/storage
run: yarn db:create
- name: Migrate Database
working-directory: packages/services/storage
run: yarn db:migrator up
- name: Generate Database Types
working-directory: packages/services/storage
run: yarn db:generate
- name: Build
run: yarn build
- name: Test
run: yarn test
- name: Type Check
run: yarn typecheck

View file

@ -12,4 +12,5 @@ coverage
out
dist
temp
__generated__
__generated__
packages/services/storage/src/db/types.ts

View file

@ -1,18 +1,18 @@
/* tslint:disable */
/**
* AUTO-GENERATED FILE @ 2022-05-16 17:20:59 - DO NOT EDIT!
* AUTO-GENERATED FILE - DO NOT EDIT!
*
* This file was automatically generated by schemats v.7.0.0
* $ schemats generate -c postgres://username:password@localhost:5432/registry?sslmode=disable -t activities -t alert_channels -t alerts -t commits -t migration -t organization_member -t organizations -t organizations_billing -t persisted_operations -t projects -t target_validation -t targets -t tokens -t users -t version_commit -t versions -s public
*
*/
export type alert_channel_type = 'SLACK' | 'WEBHOOK';
export type alert_type = 'SCHEMA_CHANGE_NOTIFICATIONS';
export type operation_kind = 'mutation' | 'query' | 'subscription';
export type organization_type = 'PERSONAL' | 'REGULAR';
export type user_role = 'ADMIN' | 'MEMBER';
export type alert_channel_type = "SLACK" | "WEBHOOK";
export type alert_type = "SCHEMA_CHANGE_NOTIFICATIONS";
export type operation_kind = "mutation" | "query" | "subscription";
export type organization_type = "PERSONAL" | "REGULAR";
export type user_role = "ADMIN" | "MEMBER";
export interface activities {
activity_metadata: any;

View file

@ -0,0 +1,13 @@
diff --git a/node_modules/@tgriesser/schemats/src/index.js b/node_modules/@tgriesser/schemats/src/index.js
index 27a7b2e..2490a40 100644
--- a/node_modules/@tgriesser/schemats/src/index.js
+++ b/node_modules/@tgriesser/schemats/src/index.js
@@ -40,7 +40,7 @@ function buildHeader(db, tables, schema, options) {
}
return `
/**
- * AUTO-GENERATED FILE @ ${getTime()} - DO NOT EDIT!
+ * AUTO-GENERATED FILE - DO NOT EDIT!
*
* This file was automatically generated by schemats v.${pkgVersion}
* $ ${commands.join(' ')}