From a28290703b08dee7d0e68fcb31819a0c48ad7a98 Mon Sep 17 00:00:00 2001 From: gitstart Date: Thu, 29 Jun 2023 11:05:55 +0000 Subject: [PATCH 1/8] Adding GitHub checks Co-authored-by: MayanjaAndrew <68685849+MayanjaAndrew@users.noreply.github.com> --- .github/actions/setup/action.yml | 21 ++++++++++++ .github/workflows/checks.yml | 59 ++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 .github/actions/setup/action.yml create mode 100644 .github/workflows/checks.yml diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 00000000..71c716b6 --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,21 @@ +name: "Setup" +description: "Sets up environment" +inputs: + ssh-private-key: + description: "SSH key used for private git clone" + required: true +runs: + using: "composite" + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: "18.13.0" + cache: "npm" + registry-url: "https://npm.pkg.github.com" + - name: Install dependencies + run: | + npm install --immutable --immutable-cache --check-cache + shell: bash diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 00000000..dc109464 --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,59 @@ +name: CI/CD Checks + +on: + push: + branches: [main] + pull_request: + +jobs: + format-check: + runs-on: ubuntu-latest + + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - name: Setup environment (node, npm install) + uses: ./.github/actions/setup + - name: Format check + run: npm run format:check + + build-check: + runs-on: ubuntu-latest + + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - name: Setup environment (node, npm install) + uses: ./.github/actions/setup + - name: Build check + run: npm run build + + server-test: + services: + postgres: + image: postgres + env: + POSTGRES_PASSWORD: pg + POSTGRES_DB: flow_test + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + + runs-on: ubuntu-latest + timeout-minutes: 5 + env: + DATABASE_URL: postgresql://postgres@localhost:5432/flow + + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - name: Setup environment (node, npm install) + uses: ./.github/actions/setup + - name: Prisma Gen + run: npm run gen -w apps/server + - name: Test check + run: npm run test -w apps/server From d46d61a51dde7f5bd65c5478850de9695d2f45d6 Mon Sep 17 00:00:00 2001 From: Richard Guerre Date: Mon, 17 Jul 2023 11:03:48 +0800 Subject: [PATCH 2/8] Make requested changes --- .github/actions/setup/action.yml | 6 +----- .github/workflows/checks.yml | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 71c716b6..47953e09 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -1,9 +1,5 @@ name: "Setup" description: "Sets up environment" -inputs: - ssh-private-key: - description: "SSH key used for private git clone" - required: true runs: using: "composite" steps: @@ -12,7 +8,7 @@ runs: - name: Use Node.js uses: actions/setup-node@v3 with: - node-version: "18.13.0" + node-version: "18.12.1" cache: "npm" registry-url: "https://npm.pkg.github.com" - name: Install dependencies diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index dc109464..c3d2daff 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -47,6 +47,7 @@ jobs: timeout-minutes: 5 env: DATABASE_URL: postgresql://postgres@localhost:5432/flow + CI: true steps: - name: Check out repository code From 2a318f205f2826163a98b9734c574a54b6ae354d Mon Sep 17 00:00:00 2001 From: Richard Guerre Date: Mon, 17 Jul 2023 11:35:41 +0800 Subject: [PATCH 3/8] Add NODE_ENV and ORIGIN envs --- .github/workflows/checks.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index c3d2daff..a42f1f6c 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -46,8 +46,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 env: - DATABASE_URL: postgresql://postgres@localhost:5432/flow CI: true + NODE_ENV: test + DATABASE_URL: postgresql://postgres@localhost:5432/flow + ORIGIN: http://localhost:4000 steps: - name: Check out repository code From 69607bbb5117b0e481ddbe1c7b2ba39adf432032 Mon Sep 17 00:00:00 2001 From: Richard Guerre Date: Tue, 18 Jul 2023 11:39:31 +0800 Subject: [PATCH 4/8] See if testing one file works --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index a42f1f6c..69f48eaf 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -59,4 +59,4 @@ jobs: - name: Prisma Gen run: npm run gen -w apps/server - name: Test check - run: npm run test -w apps/server + run: npm run test -w apps/server -- test/utils/pluralize.test.ts From cbe85bac485eec0850664f51cb4b5d2ec177ab42 Mon Sep 17 00:00:00 2001 From: Richard Guerre Date: Tue, 18 Jul 2023 11:53:26 +0800 Subject: [PATCH 5/8] Run DB migrations instead of just Prisma gen + test Item.test.ts - Prisma gen doesn't migrate the DB with the latest tables which might be why the tests were stuck in an infinite loop. - Check if using `npm run db:dev` instead of `gen -w apps/server` works by running `Item.test.ts` --- .github/workflows/checks.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 69f48eaf..989ebc39 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -56,7 +56,7 @@ jobs: uses: actions/checkout@v3 - name: Setup environment (node, npm install) uses: ./.github/actions/setup - - name: Prisma Gen - run: npm run gen -w apps/server + - name: Run DB migrations + run: npm run db:dev - name: Test check - run: npm run test -w apps/server -- test/utils/pluralize.test.ts + run: npm run test -w apps/server -- test/graphql/Item.test.ts From b8d0f1e5b385fdb7a5c9f095e30d55a18e3e5861 Mon Sep 17 00:00:00 2001 From: Richard Guerre Date: Tue, 18 Jul 2023 12:01:27 +0800 Subject: [PATCH 6/8] Add DATABASE_URL to run migrations + comment on why flow vs flow_test --- .github/workflows/checks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 989ebc39..2eb17fe5 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -48,7 +48,7 @@ jobs: env: CI: true NODE_ENV: test - DATABASE_URL: postgresql://postgres@localhost:5432/flow + DATABASE_URL: postgresql://postgres@localhost:5432/flow # `flow` will get replaced with `flow_test` (see .vitest/prisma.ts) as `flow` is the local development DB and `flow_test` is the test DB. ORIGIN: http://localhost:4000 steps: @@ -57,6 +57,6 @@ jobs: - name: Setup environment (node, npm install) uses: ./.github/actions/setup - name: Run DB migrations - run: npm run db:dev + run: DATABASE_URL=postgres://postgres:postgres@localhost:5432/flow_test npm run db:dev - name: Test check run: npm run test -w apps/server -- test/graphql/Item.test.ts From 826b1cd04cfd87036e74713074dae42cdaba5c52 Mon Sep 17 00:00:00 2001 From: Richard Guerre Date: Tue, 18 Jul 2023 12:05:18 +0800 Subject: [PATCH 7/8] Change POSTGRES_PASSWORD --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 2eb17fe5..40808395 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -33,7 +33,7 @@ jobs: postgres: image: postgres env: - POSTGRES_PASSWORD: pg + POSTGRES_PASSWORD: postgres POSTGRES_DB: flow_test options: >- --health-cmd pg_isready From 392689bee4336efe6a78e01f355863ca6748dd10 Mon Sep 17 00:00:00 2001 From: Richard Guerre Date: Tue, 18 Jul 2023 12:24:16 +0800 Subject: [PATCH 8/8] Make workflow name shorter + comment out tests --- .github/workflows/checks.yml | 66 ++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 40808395..f0f802f7 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -1,4 +1,4 @@ -name: CI/CD Checks +name: CI on: push: @@ -28,35 +28,35 @@ jobs: - name: Build check run: npm run build - server-test: - services: - postgres: - image: postgres - env: - POSTGRES_PASSWORD: postgres - POSTGRES_DB: flow_test - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - 5432:5432 - - runs-on: ubuntu-latest - timeout-minutes: 5 - env: - CI: true - NODE_ENV: test - DATABASE_URL: postgresql://postgres@localhost:5432/flow # `flow` will get replaced with `flow_test` (see .vitest/prisma.ts) as `flow` is the local development DB and `flow_test` is the test DB. - ORIGIN: http://localhost:4000 - - steps: - - name: Check out repository code - uses: actions/checkout@v3 - - name: Setup environment (node, npm install) - uses: ./.github/actions/setup - - name: Run DB migrations - run: DATABASE_URL=postgres://postgres:postgres@localhost:5432/flow_test npm run db:dev - - name: Test check - run: npm run test -w apps/server -- test/graphql/Item.test.ts + # server-test: + # services: + # postgres: + # image: postgres + # env: + # POSTGRES_PASSWORD: postgres + # POSTGRES_DB: flow_test + # options: >- + # --health-cmd pg_isready + # --health-interval 10s + # --health-timeout 5s + # --health-retries 5 + # ports: + # - 5432:5432 + + # runs-on: ubuntu-latest + # timeout-minutes: 5 + # env: + # CI: true + # NODE_ENV: test + # DATABASE_URL: postgresql://postgres@localhost:5432/flow # `flow` will get replaced with `flow_test` (see .vitest/prisma.ts) as `flow` is the local development DB and `flow_test` is the test DB. + # ORIGIN: http://localhost:4000 + + # steps: + # - name: Check out repository code + # uses: actions/checkout@v3 + # - name: Setup environment (node, npm install) + # uses: ./.github/actions/setup + # - name: Run DB migrations + # run: DATABASE_URL=postgres://postgres:postgres@localhost:5432/flow_test npm run db:dev + # - name: Run tests + # run: npm run test -w apps/server