chore: fix scripts, broken code and add command to ensure gql schema #1689
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI - API | |
on: | |
push: | |
paths: | |
- 'api/**' | |
- 'package.json' | |
- '.github/workflows/main-api.yml' | |
env: | |
NODE_VERSION: '18' | |
PNPM_VERSION: 8 | |
jobs: | |
cache-modules: | |
name: Cache Node Modules | |
runs-on: ubuntu-latest | |
outputs: | |
should_skip: ${{ steps.skip_check.outputs.should_skip }} | |
steps: | |
- name: Check for dupe action | |
id: skip_check | |
uses: fkirc/skip-duplicate-actions@v5 | |
continue-on-error: true | |
- uses: actions/checkout@v3 | |
if: steps.skip_check.outputs.should_skip != 'true' | |
- name: Install pnpm | |
if: steps.skip_check.outputs.should_skip != 'true' | |
uses: pnpm/action-setup@v2 | |
with: | |
version: ${{ env.PNPM_VERSION }} | |
- uses: actions/setup-node@v3 | |
if: steps.skip_check.outputs.should_skip != 'true' | |
id: setup-node | |
with: | |
cache: 'pnpm' | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Install packages | |
if: steps.skip_check.outputs.should_skip != 'true' && steps.setup-node.outputs.cache-hit != 'true' | |
run: pnpm install --frozen-lockfile --ignore-scripts | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
needs: [cache-modules] | |
if: needs.cache-modules.outputs.should_skip != 'true' && contains(fromJson('["ved-bot", "renovate[bot]"]'), github.actor) == false | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: ${{ env.PNPM_VERSION }} | |
- uses: actions/setup-node@v3 | |
with: | |
cache: 'pnpm' | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Install packages | |
run: pnpm install | |
- name: Lint Source | |
run: pnpm run --filter ./api lint:src | |
- name: Lint Tests | |
run: pnpm run --filter ./api lint:tests | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
needs: [cache-modules] | |
if: needs.cache-modules.outputs.should_skip != 'true' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: ${{ env.PNPM_VERSION }} | |
- uses: actions/setup-node@v3 | |
with: | |
cache: 'pnpm' | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Install packages | |
run: pnpm install | |
- name: Build | |
run: pnpm run --filter ./api build | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
needs: [cache-modules] | |
if: needs.cache-modules.outputs.should_skip != 'true' && contains(fromJson('["ved-bot"]'), github.actor) == false | |
services: | |
postgres: | |
image: postgres:13.4 | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: postgres | |
ports: | |
- 5432/tcp | |
# needed because the postgres container does not provide a healthcheck | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: ${{ env.PNPM_VERSION }} | |
- uses: actions/setup-node@v3 | |
with: | |
cache: 'pnpm' | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Install packages | |
run: pnpm install | |
- name: Init | |
run: pnpm run init --no-client | |
env: | |
DATABASE_URL: 'postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres' | |
- name: Test Seed | |
run: pnpm run --filter ./api seed | |
env: | |
DATABASE_URL: 'postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres' | |
- name: Test Specs | |
run: pnpm run --filter ./api test:specs | |
- name: Test E2E | |
run: pnpm run --filter ./api test:e2e | |
env: | |
TEST_DATABASE_URL: 'postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres' |