Skip to content

Commit a108bb4

Browse files
committed
ci: enable ci pipelines
Signed-off-by: Rifa Achrinza <[email protected]>
1 parent f96e589 commit a108bb4

File tree

10 files changed

+7930
-1
lines changed

10 files changed

+7930
-1
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
charset = utf-8
7+
indent_style = space
8+
indent_size = 2
9+
max_line_length = 80

.github/workflows/ci.yaml

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
# SPDX-License-Identifier: MIT
2+
# SPDX-FileCopyrightText: Copyright 2024 LoopBack contributors
3+
name: CI
4+
5+
on:
6+
push:
7+
branches:
8+
- master
9+
pull_request:
10+
branches:
11+
- master
12+
13+
permissions: {}
14+
15+
jobs:
16+
code-lint:
17+
name: Code lint
18+
runs-on: ubuntu-24.04
19+
timeout-minutes: 5
20+
steps:
21+
- name: Harden runner
22+
uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0
23+
with:
24+
egress-policy: audit
25+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
26+
with:
27+
fetch-depth: 0
28+
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
29+
with:
30+
node-version: 22
31+
cache: npm
32+
- name: Bootstrap dependencies
33+
run: npm ci --ignore-scripts
34+
- name: Verify code linting
35+
run: npm run lint --ignore-scripts
36+
commit-lint:
37+
name: Commit lint
38+
runs-on: ubuntu-24.04
39+
timeout-minutes: 5
40+
if: ${{ github.event.pull_request }}
41+
steps:
42+
- name: Harden runner
43+
uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0
44+
with:
45+
egress-policy: audit
46+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
47+
with:
48+
fetch-depth: 0
49+
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
50+
with:
51+
node-version: 22
52+
cache: npm
53+
- name: Bootstrap dependencies
54+
run: npm ci --ignore-scripts
55+
- name: Verify commit linting
56+
run: |-
57+
npm exec \
58+
--no \
59+
--package=@commitlint/cli \
60+
-- \
61+
commitlint \
62+
--from=origin/master \
63+
--to=HEAD \
64+
--verbose
65+
license-lint:
66+
name: License lint
67+
runs-on: ubuntu-24.04
68+
timeout-minutes: 5
69+
steps:
70+
- name: Harden runner
71+
uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0
72+
with:
73+
disable-sudo: true
74+
egress-policy: block
75+
allowed-endpoints: >
76+
github.com:443
77+
- name: Checkout
78+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
79+
with:
80+
fetch-depth: 1
81+
- name: Setup REUSE tool
82+
uses: fsfe/reuse-action@3ae3c6bdf1257ab19397fab11fd3312144692083 # v4.0.0
83+
test:
84+
name: Test
85+
runs-on: ubuntu-24.04
86+
timeout-minutes: 30
87+
strategy:
88+
fail-fast: false
89+
matrix:
90+
node-version:
91+
- 16
92+
- 18
93+
- 20
94+
- 22
95+
db2-version:
96+
- ':11.5.9.0@sha256:77095d4e04cf4448c0257086afcb2c166193d718dc33441da3b949f97e21efd5'
97+
steps:
98+
- name: Harden runner
99+
uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0
100+
with:
101+
egress-policy: audit
102+
- name: Checkout
103+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
104+
with:
105+
fetch-depth: 1
106+
submodules: true
107+
- name: Setup Node.js
108+
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
109+
with:
110+
node-version: 22
111+
cache: npm
112+
- name: Run test harness
113+
env:
114+
DB2_VERSION: ${{ matrix.db2-version }}
115+
run: ./cicd/well-known/test-harness.sh
116+
cross-test:
117+
name: Cross-test
118+
runs-on: ubuntu-24.04
119+
timeout-minutes: 30
120+
strategy:
121+
fail-fast: false
122+
matrix:
123+
node-version:
124+
- 18
125+
- 20
126+
- 22
127+
db2-version:
128+
- :11.5.9.0@sha256:77095d4e04cf4448c0257086afcb2c166193d718dc33441da3b949f97e21efd5
129+
steps:
130+
- name: Harden runner
131+
uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0
132+
with:
133+
egress-policy: audit
134+
- name: Checkout
135+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
136+
with:
137+
fetch-depth: 1
138+
submodules: true
139+
path: loopback-ibmdb
140+
- name: Clone DB2 connector repository
141+
run: |
142+
git clone \
143+
--branch=ci/ghaction-test \
144+
--depth=1 \
145+
https://github.com/loopbackio/loopback-connector-db2.git
146+
cd loopback-connector-db2
147+
git submodule update --init --depth=1
148+
- name: Setup Node.js
149+
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
150+
with:
151+
node-version: ${{ matrix.node-version }}
152+
cache: npm
153+
cache-dependency-path: |
154+
./loopback-connector-db2/package-lock.json
155+
./loopback-ibmdb/package-lock.json
156+
- name: Bootstrap dependencies
157+
run: |
158+
cd loopback-ibmdb
159+
npm ci --ignore-scripts
160+
- name: Setup and run test harness
161+
env:
162+
DB2_VERSION: ${{ matrix.db2-version }}
163+
run: |
164+
./loopback-ibmdb/cicd/well-known/prepare-autoinstall.sh
165+
. ./loopback-ibmdb/cicd/tmp/well-known/set-env/post-prepare-autoinstall.sh
166+
./loopback-connector-db2/cicd/well-known/test-harness.sh

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
node_modules
22
.DS_Store
3+
4+
# CI/CD
5+
/cicd/tmp
6+
7+
# Code editors
8+
\#*#
9+
.#*
10+
*~

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "cicd/vendor/setup-db2"]
2+
path = cicd/vendor/setup-db2
3+
url = https://github.com/achrinza/setup-db2.git
4+
branch = v0.1.0

cicd/vendor/setup-db2

Submodule setup-db2 added at 1ecca51
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/sh
2+
# SPDX-FileCopyrightText: Copyright 2024 LoopBack contributors
3+
# SPDX-License-Identifier: MIT
4+
export POSIXLY_CORRECT=1
5+
set -euv
6+
7+
ORIG_DIR="$(pwd)"
8+
cd "$(dirname "$0")/../.."
9+
BASE_DIR="$(pwd)"
10+
11+
CI_NODEJS_AUTOINSTALL_DIR="$BASE_DIR/cicd/tmp/nodejs-autoinstall"
12+
PREPARE_POSTINSTALL_SCRIPT="$BASE_DIR/cicd/tmp/well-known/set-env/post-prepare-autoinstall.sh"
13+
14+
STEP_COUNT=1
15+
16+
step () {
17+
printf "\n\n============================================================================\n"
18+
printf 'STEP #%d: %s\n' "$STEP_COUNT" "$1"
19+
printf "\n============================================================================\n\n"
20+
STEP_COUNT="$((STEP_COUNT + 1))"
21+
}
22+
23+
step 'Bootstrap dependencies'
24+
npm ci --prefer-offline --ignore-scripts
25+
26+
step 'Pack for autoinstall'
27+
mkdir -p "$CI_NODEJS_AUTOINSTALL_DIR"
28+
npm pack --pack-destination="$CI_NODEJS_AUTOINSTALL_DIR"
29+
30+
mkdir -p "$(dirname "$PREPARE_POSTINSTALL_SCRIPT")"
31+
echo "export CI_NODEJS_AUTOINSTALL_DIR=\"$CI_NODEJS_AUTOINSTALL_DIR\"" >"$PREPARE_POSTINSTALL_SCRIPT"
32+
chmod +x "$PREPARE_POSTINSTALL_SCRIPT"

cicd/well-known/test-harness.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/sh
2+
# SPDX-FileCopyrightText: Copyright 2024 LoopBack contributors
3+
# SPDX-License-Identifier: MIT
4+
export POSIXLY_CORRECT=1
5+
set -euv
6+
7+
export DB2_USERNAME=db2inst1
8+
export DB2_PASSWORD=P00lGnorts
9+
export DB2_HOSTNAME=localhost
10+
export DB2_PORTNUM=50000
11+
export DB2_DATABASE=mydb
12+
13+
ORIG_DIR="$(pwd)"
14+
cd "$(dirname "$0")/../.."
15+
BASE_DIR="$(pwd)"
16+
17+
CI_NODEJS_AUTOINSTALL_DIR="${CI_NODEJS_AUTOINSTALL_DIR:-}"
18+
STARTDB2_SCRIPT="$BASE_DIR/cicd/vendor/setup-db2/start-db2.sh"
19+
20+
STEP_COUNT=1
21+
22+
step () {
23+
printf "\n\n============================================================================\n"
24+
printf 'STEP #%d: %s\n' "$STEP_COUNT" "$1"
25+
printf "\n============================================================================\n\n"
26+
STEP_COUNT="$((STEP_COUNT + 1))"
27+
}
28+
29+
step 'Bootstrap dependencies'
30+
npm ci --prefer-offline
31+
32+
step 'Bootstrap overriding dependencies'
33+
if [ "$CI_NODEJS_AUTOINSTALL_DIR" != '' ]; then
34+
printf "$CI_NODEJS_AUTOINSTALL_DIR" |
35+
xargs -d: \
36+
find \
37+
"$CI_NODEJS_AUTOINSTALL_DIR" \
38+
-iname '*.tgz' \
39+
-exec \
40+
npm install {} \;
41+
fi
42+
npm install --prefer-offline
43+
44+
step 'Start DB2 LUW server'
45+
"$STARTDB2_SCRIPT" \
46+
-l accept \
47+
-V "$DB2_VERSION" \
48+
-p 'P00lGnorts'
49+
50+
step 'Run tests'
51+
npm test --ignore-scripts
52+
53+
step 'Teardown DB2 LUW server'
54+
"$STARTDB2_SCRIPT" -C
55+
56+
cd "$ORIG_DIR"

commitlint.config.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// SPDX-FileCopyrightText: Copyright 2024 LoopBack contributors
2+
// SPDX-License-Identifier: MIT
3+
'use strict';
4+
5+
const isCI = process.env.CI;
6+
7+
module.exports = {
8+
extends: ['@commitlint/config-conventional'],
9+
rules: {
10+
'header-max-length': [2, 'always', 100],
11+
'body-leading-blank': [2, 'always'],
12+
'footer-leading-blank': [0, 'always'],
13+
// Only enforce the rule if CI flag is not set. This is useful for release
14+
// commits to skip DCO
15+
'signed-off-by': [isCI ? 0 : 2, 'always', 'Signed-off-by:'],
16+
},
17+
};

0 commit comments

Comments
 (0)