Skip to content

Commit 468ebc9

Browse files
authored
chore(ci): replace CircleCI with Github Actions workflow (#187)
- 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
1 parent ce407cc commit 468ebc9

File tree

7 files changed

+133
-149
lines changed

7 files changed

+133
-149
lines changed

.circleci/config.yml

Lines changed: 0 additions & 118 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Node CI
2+
3+
on: push
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
9+
env:
10+
TERM: xterm
11+
FORCE_COLOR: 1
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
17+
- name: Use Node.js 18.x
18+
uses: actions/setup-node@v1
19+
with:
20+
node-version: 18
21+
22+
- name: Install
23+
run: yarn --immutable --ignore-engines
24+
25+
- name: Check Code Format
26+
run: yarn format:check
27+
28+
- name: Lint Code
29+
run: yarn lint
30+
31+
- name: Typecheck
32+
run: yarn typecheck
33+
34+
test:
35+
runs-on: ubuntu-latest
36+
37+
env:
38+
CI: true
39+
PGVERSION: ${{ matrix.postgres-version}}
40+
TEST_DATABASE_URL: postgres://postgres:postgres@127.0.0.1:5432/graphile_test_c
41+
TERM: xterm
42+
FORCE_COLOR: 1
43+
44+
strategy:
45+
fail-fast: false
46+
matrix:
47+
postgres-version:
48+
- 11
49+
- 12
50+
- 13
51+
- 14
52+
- 15
53+
node-version:
54+
- 14.x
55+
- 16.x
56+
- 18.x
57+
58+
services:
59+
postgres:
60+
image: postgres:${{ matrix.postgres-version }}
61+
env:
62+
POSTGRES_USER: postgres
63+
POSTGRES_PASSWORD: postgres
64+
POSTGRES_DB: postgres
65+
ports:
66+
- "0.0.0.0:5432:5432"
67+
# needed because the postgres container does not provide a healthcheck
68+
options:
69+
--health-cmd pg_isready --health-interval 10s --health-timeout 5s
70+
--health-retries 5 --name postgres
71+
72+
steps:
73+
- name: Checkout
74+
uses: actions/checkout@v3
75+
76+
- name: Use Node.js ${{ matrix.node-version }}
77+
uses: actions/setup-node@v1
78+
with:
79+
node-version: ${{ matrix.node-version }}
80+
81+
- name: Configure PostgreSQL
82+
run: |
83+
cat .github/workflows/ci/docker-entrypoint-initdb.d/010-setup.sh | docker exec -i postgres bash
84+
85+
- name: Install
86+
run: yarn --immutable --ignore-engines
87+
88+
- name: Test
89+
run: yarn test
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
createdb graphile_test_c -U postgres --template template0 --lc-collate C

.prettierrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"trailingComma": "es5"
3-
}
3+
}

.vscode/launch.json

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
{
2-
// Use IntelliSense to learn about possible attributes.
3-
// Hover to view descriptions of existing attributes.
4-
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5-
"version": "0.2.0",
6-
"configurations": [
7-
{
8-
"name": "Debug Jest Tests",
9-
"type": "node",
10-
"request": "launch",
11-
"runtimeArgs": ["--inspect-brk", "${workspaceRoot}/node_modules/.bin/jest", "--runInBand"],
12-
"console": "integratedTerminal",
13-
"internalConsoleOptions": "neverOpen"
14-
}
15-
]
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Debug Jest Tests",
9+
"type": "node",
10+
"request": "launch",
11+
"runtimeArgs": [
12+
"--inspect-brk",
13+
"${workspaceRoot}/node_modules/.bin/jest",
14+
"--runInBand"
15+
],
16+
"console": "integratedTerminal",
17+
"internalConsoleOptions": "neverOpen"
18+
}
19+
]
1620
}

__tests__/integration/schema/core.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,21 @@ import * as pg from "pg";
22
import { createPostGraphileSchema } from "postgraphile-core";
33
import { printSchemaOrdered, withPgClient } from "../../helpers";
44

5-
export const test = (
6-
schemas: string[],
7-
options: Record<string, unknown>,
8-
setup?: (client: pg.PoolClient) => void
9-
) => (): Promise<void> =>
10-
withPgClient(async (client) => {
11-
if (setup) {
12-
if (typeof setup === "function") {
13-
await setup(client);
14-
} else {
15-
await client.query(setup);
5+
export const test =
6+
(
7+
schemas: string[],
8+
options: Record<string, unknown>,
9+
setup?: (client: pg.PoolClient) => void
10+
) =>
11+
(): Promise<void> =>
12+
withPgClient(async (client) => {
13+
if (setup) {
14+
if (typeof setup === "function") {
15+
await setup(client);
16+
} else {
17+
await client.query(setup);
18+
}
1619
}
17-
}
18-
const schema = await createPostGraphileSchema(client, schemas, options);
19-
expect(printSchemaOrdered(schema)).toMatchSnapshot();
20-
});
20+
const schema = await createPostGraphileSchema(client, schemas, options);
21+
expect(printSchemaOrdered(schema)).toMatchSnapshot();
22+
});

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
"main": "dist/index.js",
66
"scripts": {
77
"build": "tsc",
8-
"format": "prettier --write src/**/*.ts",
8+
"format": "prettier --ignore-path ./.eslintignore",
9+
"format:all": "yarn format '**/*.{json,md,html,js,jsx,ts,tsx}'",
10+
"format:fix": "yarn format:all --write",
11+
"format:check": "yarn format:all --list-different",
912
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
1013
"prepack": "rm -Rf dist && npm run build",
1114
"test": "jest -i",

0 commit comments

Comments
 (0)