mirror of
https://github.com/graphql-hive/console
synced 2026-04-21 14:37:17 +00:00
* feat: retreive stripe public key via runtime environment variable instead of a build-time environment variable * feat: retreive google and github enabled environment variable via runtime environment variable instead of a build-time environment variable * feat: retreive app base url environment variable via runtime environment variable instead of a build-time environment variable * feat: retreive mixpanel token environment variable via runtime environment variable instead of a build-time environment variable * lazy initialize app info * feat: provide ga tarcking id and crisp website id via environment variable * make docs url optional * feat: load sentry config from environment variables * document hive app environment variables * add application dockerfile * add docker build instructions * lul * set working directory * pls fix * lol this is apollo-router not graphql-hive * feat: only show sentry stuff if sentry environment variables are set * use LTS node version * No mixpanel * Fallback Co-authored-by: Kamil Kisiela <kamil.kisiela@gmail.com>
460 lines
12 KiB
YAML
460 lines
12 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
|
|
|
|
outputs:
|
|
hive_token_present: ${{ steps.secrets_present.outputs.hive_token }}
|
|
|
|
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_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-file: .node-version
|
|
|
|
- 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 }}
|
|
|
|
- name: Check for Presence of Repository Secrets
|
|
id: secrets_present
|
|
run: echo "::set-output name=hive_token::${{ env.HIVE_TOKEN != '' }}"
|
|
|
|
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-file: .node-version
|
|
|
|
- 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
|
|
|
|
- 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_PUBLIC_KEY: ${{ secrets.TEST_STRIPE_PUBLIC_KEY }}
|
|
STRIPE_SECRET_KEY: ${{ secrets.TEST_STRIPE_SECRET_KEY }}
|
|
SUPERTOKENS_CONNECTION_URI: http://127.0.0.1:3567
|
|
SUPERTOKENS_API_KEY: bubatzbieber6942096420
|
|
EXTERNAL_COMPOSITION_SECRET: secretsecret
|
|
|
|
- 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-file: .node-version
|
|
|
|
- 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
|
|
|
|
- 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_PUBLIC_KEY: ${{ secrets.TEST_STRIPE_PUBLIC_KEY }}
|
|
STRIPE_SECRET_KEY: ${{ secrets.TEST_STRIPE_SECRET_KEY }}
|
|
SUPERTOKENS_CONNECTION_URI: http://127.0.0.1:3567
|
|
SUPERTOKENS_API_KEY: bubatzbieber6942096420
|
|
EXTERNAL_COMPOSITION_SECRET: secretsecret
|
|
|
|
- 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
|
|
if: needs.setup.outputs.hive_token_present == 'true'
|
|
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-file: .node-version
|
|
|
|
- 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-file: .node-version
|
|
|
|
- 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-file: .node-version
|
|
|
|
- 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-file: .node-version
|
|
|
|
- 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-file: .node-version
|
|
|
|
- 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
|
|
|
|
publish_app:
|
|
needs: setup
|
|
name: Publish for Docker
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 40
|
|
|
|
env:
|
|
REGISTRY: ghcr.io
|
|
IMAGE_NAME: ${{ github.repository }}
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Install Node
|
|
uses: actions/setup-node@v2
|
|
with:
|
|
node-version-file: .node-version
|
|
|
|
- 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
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Login to registry
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v3
|
|
with:
|
|
file: packages/web/app/Dockerfile
|
|
context: ./packages/web/app
|
|
push: true
|
|
tags: ${{ env.REGISTRY }}/${{ github.repository }}/app:${{ github.sha }}
|