Skip to content

Commit ce4632b

Browse files
committed
👷 Separate PostgreSQL pipeline
1 parent c3a9386 commit ce4632b

4 files changed

Lines changed: 114 additions & 46 deletions

File tree

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: 'Create project'
2+
description: 'Runs create-node-project and performs tests'
3+
inputs:
4+
options:
5+
description: 'create-node-app options'
6+
required: true
7+
default: 'postgresql://postgres:postgres@postgres:5432/postgres'
8+
runs:
9+
using: 'composite'
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v3
13+
14+
- name: Cache dependencies
15+
uses: actions/cache@v3
16+
with:
17+
path: ~/.npm
18+
key: npm-${{ hashFiles('package-lock.json') }}
19+
restore-keys: npm-
20+
21+
- name: Install dependencies
22+
run: npm ci --ignore-scripts
23+
shell: bash
24+
25+
- name: Build the project
26+
run: npm run build
27+
shell: bash
28+
29+
- name: Run npm link
30+
run: npm link
31+
shell: bash
32+
33+
- name: Create project
34+
run: create-node-app ${{ inputs.options }}
35+
shell: bash
36+
37+
- name: Build created project
38+
working-directory: ./node-app
39+
run: npm run build
40+
shell: bash
41+
42+
- name: Run lint
43+
working-directory: ./node-app
44+
run: npm run ci-lint
45+
shell: bash
46+
47+
- name: Run tests
48+
working-directory: ./node-app
49+
run: npm run ci-test
50+
shell: bash
51+
env:
52+
DB_CONNECTION_STRING: ${{inputs.dbConnection}}
53+
54+
- name: Run start
55+
if: ${{ !contains(inputs.options, '--api none') }}
56+
working-directory: ./node-app
57+
run: |
58+
npm run start &
59+
start_pid=$!
60+
sleep 10
61+
kill $start_pid
62+
shell: bash
63+
env:
64+
DB_CONNECTION_STRING: ${{inputs.dbConnection}}
65+
66+
- name: Run start
67+
if: ${{ contains(inputs.options, '--api none') }}
68+
working-directory: ./node-app
69+
shell: bash
70+
run: npm run start
71+
env:
72+
DB_CONNECTION_STRING: ${{inputs.dbConnection}}

‎.github/workflows/create-projects.yml‎

Lines changed: 35 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -17,54 +17,44 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
create-app-command:
21-
- "create-node-app -f --api rest --database postgres-knex --pipeline cloudrun-gitlab"
22-
- "create-node-app -f --api graphql --database postgres-knex --pipeline cloudrun-gitlab"
23-
- "create-node-app -f --api rest --database none --pipeline cloudrun-gitlab"
24-
- "create-node-app -f --api graphql --database none --pipeline cloudrun-gitlab"
25-
- "create-node-app -f --api rest --database none --pipeline none"
26-
- "create-node-app -f --api none --database none --pipeline cloudrun-gitlab"
20+
create-app-options:
21+
- "--api rest --database none --pipeline cloudrun-gitlab"
22+
- "--api graphql --database none --pipeline cloudrun-gitlab"
23+
- "--api rest --database none --pipeline none"
24+
- "--api none --database none --pipeline cloudrun-gitlab"
2725
runs-on: ubuntu-latest
2826

2927
steps:
30-
- name: Checkout
31-
uses: actions/checkout@v3
32-
33-
- name: Cache dependencies
34-
uses: actions/cache@v3
28+
- uses: actions/checkout@v4
29+
- id: create-node-app
30+
uses: ./.github/actions/test-create-project
3531
with:
36-
path: ~/.npm
37-
key: npm-${{ hashFiles('package-lock.json') }}
38-
restore-keys: npm-
39-
40-
- name: Install dependencies
41-
run: npm ci --ignore-scripts
42-
43-
- name: Build the project
44-
run: npm run build
45-
46-
- name: Run npm link
47-
run: npm link
48-
49-
- name: Create project
50-
run: ${{ matrix.create-app-command }}
51-
52-
- name: Build created project
53-
working-directory: ./node-app
54-
run: npm run build
32+
options: ${{ matrix.create-app-options }}
5533

56-
- name: Run lint
57-
working-directory: ./node-app
58-
run: npm run ci-lint
34+
create-projects-with-postgres:
35+
needs: "build"
36+
services:
37+
postgres:
38+
image: postgres
39+
env:
40+
POSTGRES_PASSWORD: postgres
41+
options: >-
42+
--health-cmd pg_isready
43+
--health-interval 10s
44+
--health-timeout 5s
45+
--health-retries 5
46+
strategy:
47+
fail-fast: false
48+
matrix:
49+
create-app-options:
50+
- "--api none --database postgres-knex --pipeline none"
51+
- "--api rest --database postgres-knex --pipeline cloudrun-gitlab"
52+
- "--api graphql --database postgres-knex --pipeline cloudrun-gitlab"
53+
runs-on: ubuntu-latest
5954

60-
- name: Run tests
61-
working-directory: ./node-app
62-
run: npm run ci-test
63-
64-
- name: Run start
65-
working-directory: ./node-app
66-
run: |
67-
npm run start &
68-
start_pid=$!
69-
sleep 10
70-
kill $start_pid
55+
steps:
56+
- uses: actions/checkout@v4
57+
- id: create-node-app
58+
uses: ./.github/actions/test-create-project
59+
with:
60+
options: ${{ matrix.create-app-options }}

‎starter/_base/src/index.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { config } from './config.js'
21
import { createContainer } from './container.js'
32
import { RequestContext } from './context.js'
43

‎starter/api/rest/src/domain/health-check.service.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import * as healthz from 'node-healthz'
2+
import { config } from '../config.js'
23

34
export const healthCheckService = {
45
check: async (): Promise<healthz.Result> => {
6+
7+
console.log('TEST')
8+
console.log((config as any)?.db?.connectionString)
9+
console.log('TEST2')
10+
console.log(process.env.DB_CONNECTION_STRING)
11+
512
return await healthz.check({
613
checks: [
714
{

0 commit comments

Comments
 (0)