console/.github/workflows/ci.yaml
2022-08-08 14:58:22 +02:00

332 lines
8.3 KiB
YAML

name: CI
on: [pull_request]
jobs:
setup:
name: Setup
runs-on: ubuntu-latest
timeout-minutes: 10
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
- name: Install Node
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
timeout-minutes: 15
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
- name: Install Node
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
timeout-minutes: 5
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
- name: Install Node
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
timeout-minutes: 5
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
- name: Install Node
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
timeout-minutes: 10
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
- name: Install Node
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
rust:
name: Build Rust
runs-on: ubuntu-latest
timeout-minutes: 40
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Install Node
uses: actions/setup-node@v2
with:
node-version: 16
- name: Install Rust
run: |
curl https://sh.rustup.rs -sSf | sh -s -- -y
rustup target add x86_64-unknown-linux-gnu
- name: Cache Rust
uses: Swatinem/rust-cache@v1
with:
key: rust_linux_cross
- name: Build
run: cargo build --target x86_64-unknown-linux-gnu --release
- name: Strip binary from debug symbols
run: strip target/x86_64-unknown-linux-gnu/release/router
- name: Compress
run: ./target/x86_64-unknown-linux-gnu/release/compress ./target/x86_64-unknown-linux-gnu/release/router ./router.tar.gz
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: router-linux
path: target/x86_64-unknown-linux-gnu/release/router
lint:
name: Lint
runs-on: ubuntu-latest
needs: setup
timeout-minutes: 25
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: ESLint cache
uses: actions/cache@v2
with:
path: '.eslintcache'
key: ${{ runner.os }}-eslint-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-eslint
- 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