Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding GitHub checks #7

Merged
merged 12 commits into from
Jul 18, 2023
21 changes: 21 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Setup"
description: "Sets up environment"
inputs:
ssh-private-key:
description: "SSH key used for private git clone"
required: true
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for? The GitHub actions seem to work fine without any "input".

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. It's not needed. We'll remove it.

richardguerre marked this conversation as resolved.
Show resolved Hide resolved
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"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the version in .nvmrc or even try and use the version in .nvmrc using cat .nvmrc. This issue seems to point out how to do it.

richardguerre marked this conversation as resolved.
Show resolved Hide resolved
cache: "npm"
registry-url: "https://npm.pkg.github.com"
- name: Install dependencies
run: |
npm install --immutable --immutable-cache --check-cache
shell: bash
59 changes: 59 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: CI/CD Checks
richardguerre marked this conversation as resolved.
Show resolved Hide resolved

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
richardguerre marked this conversation as resolved.
Show resolved Hide resolved
- 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
richardguerre marked this conversation as resolved.
Show resolved Hide resolved
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
richardguerre marked this conversation as resolved.
Show resolved Hide resolved

richardguerre marked this conversation as resolved.
Show resolved Hide resolved
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
richardguerre marked this conversation as resolved.
Show resolved Hide resolved
- name: Test check
run: npm run test -w apps/server
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason this check is in a loop is because vitest runs in watch mode in a development environment and in run mode when process.env.CI is truthy. Normally GitHub actions already insert CI=true as part of environment variables. You can try adding manually right below the DATABASE_URL env.

richardguerre marked this conversation as resolved.
Show resolved Hide resolved