console/.github/workflows/ci.yaml
Kamil Kisiela c82b22ac05
Simplify the schema publishing logic (#156)
- Removes the uniqueness requirement of commit it
- Makes the logic of schema publishing simpler and more readable
- Updating the service url results in a new version (previously an update of existing version)
- Introduces a requirement of defining service url in federated projects (new `SchemaPublishMissingUrlError` type)
2022-06-23 10:00:43 +02:00

272 lines
6.7 KiB
YAML

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_API_URL: ${{ secrets.TURBO_API_URL }}
TURBO_REMOTE_ONLY: 'true'
steps:
- name: Check out repository code
uses: actions/checkout@v3
with:
fetch-depth: 1
- 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_API_URL: ${{ secrets.TURBO_API_URL }}
TURBO_REMOTE_ONLY: 'true'
steps:
- name: Check out repository code
uses: actions/checkout@v3
with:
fetch-depth: 5
- 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: Setup Turbo
run: node ./scripts/turborepo-setup.js
- 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
timeout-minutes: 15
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_API_URL: ${{ secrets.TURBO_API_URL }}
TURBO_REMOTE_ONLY: 'true'
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 5
- 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_API_URL: ${{ secrets.TURBO_API_URL }}
TURBO_REMOTE_ONLY: 'true'
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 1
- 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_API_URL: ${{ secrets.TURBO_API_URL }}
TURBO_REMOTE_ONLY: 'true'
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 5
- 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: Setup Turbo
run: node ./scripts/turborepo-setup.js
- name: Generate Types
run: yarn graphql:generate
- name: Build
run: yarn build
lint:
name: Lint
runs-on: ubuntu-latest
needs: setup
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
TURBO_API_URL: ${{ secrets.TURBO_API_URL }}
TURBO_REMOTE_ONLY: 'true'
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 5
- 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: Setup Turbo
run: node ./scripts/turborepo-setup.js
- name: Generate Types
run: yarn graphql:generate
- name: Type Check
run: yarn typecheck
- name: Lint ESLint
run: yarn lint
- name: Lint Prettier
run: yarn lint:prettier