console/.github/workflows/ci.yaml
Laurin Quast 6540155fc7
feat: replace auth0 with supertokens (#303)
* add supertoken container to docker-compose file

* yeah I am sorry this one big commit and I am ashamed of it

* use logOut function

* feat: show header on 404 page

* feat: better handling for organization cookie when not authenticated

* wrap it

* check session within server side props

* add is_admin flag user migration

* simplify and annotate the config

* fix: handle status codes + fix email/password sign up with import from auth0

* no hardcoded env pls

* decode process.env

* secure update user id mapping via a key

* fix: login form

* lol we don't need to hit the API

* fix: do graphql api authorization via authorization header instead of cookie

* implement isAdmin flag

* fix: types :)

* skipit

* yo we can run this

* set env variables

* disable because it annoys the hell out of me

* use the right host

* add not about token length

* refactor: decode environment variables

* feat: store external user id from guthub/google provider in the database

* workaround supertokens omitting null values from the token

* re-enable check

* i have no time for this shit

* add missing env variable

* fix: email test; missing domain extension

* configure pulumi deployment

Co-authored-by: Kamil Kisiela <kamil.kisiela@gmail.com>
Co-authored-by: Dotan Simha <dotansimha@gmail.com>

* configure pulumi deployment

Co-authored-by: Kamil Kisiela <kamil.kisiela@gmail.com>
Co-authored-by: Dotan Simha <dotansimha@gmail.com>

* configure pulumi deployment

Co-authored-by: Kamil Kisiela <kamil.kisiela@gmail.com>
Co-authored-by: Dotan Simha <dotansimha@gmail.com>

* configure pulumi deployment

Co-authored-by: Kamil Kisiela <kamil.kisiela@gmail.com>

* fix: env names

* fix: link google account to the correct db record

* feat: email confirmation emails

* ?

* bump ts-node

* fix types

* omit package form the bundle

* remove it from dependencies...

* add emails apckage to dev deps

* resolve eslint issues

* remove comments

* update dev info + change env variable (no need to expose it on the frontend)

* use correct user id lol

Co-authored-by: Kamil Kisiela <kamil.kisiela@gmail.com>
Co-authored-by: Dotan Simha <dotansimha@gmail.com>
2022-09-06 09:38:31 +02:00

395 lines
10 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
continue-on-error: true
- 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:
STRIPE_SECRET_KEY: ${{ secrets.TEST_STRIPE_SECRET_KEY }}
SUPERTOKENS_CONNECTION_URI: http://127.0.0.1:3567
SUPERTOKENS_API_KEY: bubatzbieber6942096420
- name: Dockest logs
if: always()
run: cat integration-tests/*.log
integration-tests-ff:
name: Integration Tests (with Feature Flags enabled)
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'
# Feature Flags
FF_CLICKHOUSE_V2_TABLES: '1'
steps:
- name: Detect feature flags
id: feature_flags
run: |
total=$(env | grep "FF_.*" -c)
if [ $total -gt 0 ]; then
echo '::set-output name=detected::true'
fi
- name: Check out repository code
if: steps.feature_flags.outputs.detected == 'true'
uses: actions/checkout@v3
with:
fetch-depth: 5
- name: Install Node
if: steps.feature_flags.outputs.detected == 'true'
uses: actions/setup-node@v2
with:
node-version: 16
- name: Pull node_modules
if: steps.feature_flags.outputs.detected == 'true'
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ github.sha }}
- name: Setup Turbo
if: steps.feature_flags.outputs.detected == 'true'
run: node ./scripts/turborepo-setup.js
- name: Build
if: steps.feature_flags.outputs.detected == 'true'
run: yarn workspace integration-tests run build-and-pack
env:
NEXT_PUBLIC_STRIPE_PUBLIC_KEY: ${{ secrets.TEST_STRIPE_PUBLIC_KEY }}
- name: Pull images
if: steps.feature_flags.outputs.detected == 'true'
run: docker-compose -f integration-tests/docker-compose.yml pull
- name: Integration Tests
if: steps.feature_flags.outputs.detected == 'true'
run: yarn workspace integration-tests run dockest
timeout-minutes: 15
env:
STRIPE_SECRET_KEY: ${{ secrets.TEST_STRIPE_SECRET_KEY }}
SUPERTOKENS_CONNECTION_URI: http://127.0.0.1:3567
SUPERTOKENS_API_KEY: bubatzbieber6942096420
- name: Dockest logs
if: steps.feature_flags.outputs.detected == 'true' && 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