Skip to content

Commit

Permalink
chore(ci): replace CircleCI with Github Actions workflow (#187)
Browse files Browse the repository at this point in the history
- Add a GitHub Actions config for running tests, typechecking and linting
- Test against all supported versions of Postgres (11-15) and Node.js (14-18)
- Remove the CircleCI config
- Format with prettier
  • Loading branch information
mattbretl authored Dec 1, 2022
1 parent ce407cc commit 468ebc9
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 149 deletions.
118 changes: 0 additions & 118 deletions .circleci/config.yml

This file was deleted.

89 changes: 89 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Node CI

on: push

jobs:
lint:
runs-on: ubuntu-latest

env:
TERM: xterm
FORCE_COLOR: 1

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Use Node.js 18.x
uses: actions/setup-node@v1
with:
node-version: 18

- name: Install
run: yarn --immutable --ignore-engines

- name: Check Code Format
run: yarn format:check

- name: Lint Code
run: yarn lint

- name: Typecheck
run: yarn typecheck

test:
runs-on: ubuntu-latest

env:
CI: true
PGVERSION: ${{ matrix.postgres-version}}
TEST_DATABASE_URL: postgres://postgres:[email protected]:5432/graphile_test_c
TERM: xterm
FORCE_COLOR: 1

strategy:
fail-fast: false
matrix:
postgres-version:
- 11
- 12
- 13
- 14
- 15
node-version:
- 14.x
- 16.x
- 18.x

services:
postgres:
image: postgres:${{ matrix.postgres-version }}
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- "0.0.0.0:5432:5432"
# needed because the postgres container does not provide a healthcheck
options:
--health-cmd pg_isready --health-interval 10s --health-timeout 5s
--health-retries 5 --name postgres

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Configure PostgreSQL
run: |
cat .github/workflows/ci/docker-entrypoint-initdb.d/010-setup.sh | docker exec -i postgres bash
- name: Install
run: yarn --immutable --ignore-engines

- name: Test
run: yarn test
4 changes: 4 additions & 0 deletions .github/workflows/ci/docker-entrypoint-initdb.d/010-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -e

createdb graphile_test_c -U postgres --template template0 --lc-collate C
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"trailingComma": "es5"
}
}
32 changes: 18 additions & 14 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug Jest Tests",
"type": "node",
"request": "launch",
"runtimeArgs": ["--inspect-brk", "${workspaceRoot}/node_modules/.bin/jest", "--runInBand"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug Jest Tests",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/node_modules/.bin/jest",
"--runInBand"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}
32 changes: 17 additions & 15 deletions __tests__/integration/schema/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@ import * as pg from "pg";
import { createPostGraphileSchema } from "postgraphile-core";
import { printSchemaOrdered, withPgClient } from "../../helpers";

export const test = (
schemas: string[],
options: Record<string, unknown>,
setup?: (client: pg.PoolClient) => void
) => (): Promise<void> =>
withPgClient(async (client) => {
if (setup) {
if (typeof setup === "function") {
await setup(client);
} else {
await client.query(setup);
export const test =
(
schemas: string[],
options: Record<string, unknown>,
setup?: (client: pg.PoolClient) => void
) =>
(): Promise<void> =>
withPgClient(async (client) => {
if (setup) {
if (typeof setup === "function") {
await setup(client);
} else {
await client.query(setup);
}
}
}
const schema = await createPostGraphileSchema(client, schemas, options);
expect(printSchemaOrdered(schema)).toMatchSnapshot();
});
const schema = await createPostGraphileSchema(client, schemas, options);
expect(printSchemaOrdered(schema)).toMatchSnapshot();
});
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
"main": "dist/index.js",
"scripts": {
"build": "tsc",
"format": "prettier --write src/**/*.ts",
"format": "prettier --ignore-path ./.eslintignore",
"format:all": "yarn format '**/*.{json,md,html,js,jsx,ts,tsx}'",
"format:fix": "yarn format:all --write",
"format:check": "yarn format:all --list-different",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"prepack": "rm -Rf dist && npm run build",
"test": "jest -i",
Expand Down

0 comments on commit 468ebc9

Please sign in to comment.