Skip to content

Commit dc2f83f

Browse files
committed
ci: shell-based test harness
Signed-off-by: Rifa Achrinza <[email protected]>
1 parent 07cdcec commit dc2f83f

File tree

6 files changed

+118
-12
lines changed

6 files changed

+118
-12
lines changed

.github/workflows/ci.yaml

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,11 @@ jobs:
103103
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
104104
with:
105105
fetch-depth: 1
106+
submodules: true
106107
- name: Run test harness
107-
uses: ./test
108-
with:
109-
node-version: ${{ github.matrix.node-version }}
110-
db2-version: ${{ github.matrix.db2-version }}
111-
_internal-mode: true
112-
108+
env:
109+
DB2_VERSION: ${{ matrix.db2-version }}
110+
run: ./cicd/well-known/test-harness.sh
113111
test-ibmdb:
114112
name: Cross-test (IBM DB)
115113
runs-on: ubuntu-24.04
@@ -133,8 +131,28 @@ jobs:
133131
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
134132
with:
135133
fetch-depth: 1
136-
- name: Run test harness
137-
uses: loopbackio/loopback-ibmdb/test@ci/ghaction-test
134+
path: loopback-connector-db2
135+
submodules: true
136+
- name: Clone IBM DB base connector repository
137+
run: |-
138+
git clone \
139+
--branch=ci/ghaction-test \
140+
--depth=1 \
141+
https://github.com/loopbackio/loopback-ibmdb.git
142+
cd loopback-ibmdb
143+
git submodule update --init --depth=1
144+
- name: Setup Node.js
145+
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
138146
with:
139-
node-version: ${{ github.matrix.node-version }}
140-
db2-version: ${{ github.matrix.db2-version }}
147+
node-version: ${{ matrix.node-version }}
148+
cache: npm
149+
cache-dependency-path: |-
150+
./loopback-ibmdb/package-lock.json
151+
./loopback-connector-db2/package-lock.json
152+
- name: Setup and run test harness
153+
env:
154+
DB2_VERSION: ${{ matrix.db2-version }}
155+
run: |-
156+
./loopback-ibmdb/cicd/well-known/prepare-autoinstall.sh
157+
. ./loopback-ibmdb/cicd/tmp/well-known/set-env/post-prepare-autoinstall.sh
158+
./loopback-connector-db2/cicd/well-known/test-harness.sh

.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+
export POSIXLY_CORRECT=1
3+
set -euv
4+
5+
ORIG_DIR="$(pwd)"
6+
cd "$(dirname "$0")/../.."
7+
BASE_DIR="$(pwd)"
8+
9+
CI_NODEJS_AUTOINSTALL_DIR="$BASE_DIR/cicd/tmp/nodejs-autoinstall"
10+
PREPARE_POSTINSTALL_SCRIPT="$BASE_DIR/cicd/tmp/well-known/set-env/post-prepare-autoinstall.sh"
11+
12+
STEP_COUNT=1
13+
14+
step () {
15+
printf "\n\n============================================================================\n"
16+
printf 'STEP #%d: %s\n' "$STEP_COUNT" "$1"
17+
printf "\n============================================================================\n\n"
18+
STEP_COUNT="$((STEP_COUNT + 1))"
19+
}
20+
21+
step 'Bootstrap dependencies'
22+
npm ci --prefer-offline --ignore-scripts
23+
24+
step 'Pack for autoinstall'
25+
mkdir -p "CI_NODEJS_AUTOINSTALL_DIR"
26+
npm pack --pack-destination="$CI_NODEJS_AUTOINSTALL_DIR"
27+
28+
mkdir -p "$(dirname "$PREPARE_POSTINSTALL_SCRIPT")"
29+
echo "export CI_NODEJS_AUTOINSTALL_DIR=\"$CI_NODEJS_AUTOINSTALL_DIR\"" >"$PREPARE_POSTINSTALL_SCRIPT"
30+
chmod +x "$PREPARE_POSTINSTALL_SCRIPT"
31+
32+
cd "$ORIG_DIR"

cicd/well-known/test-harness.sh

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

test/action.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ runs:
4242
db2-license: accept
4343
db2-version: ${{ matrix.db2-version }}
4444
db2-password: P00lGnorts
45-
- name: Setup FakeTTY
46-
uses: Yuri6037/Action-FakeTTY@1abc69c7d530815855caedcd73842bae5687c1a6 # V1.1
4745
- name: Run tests
4846
env:
4947
DB2_USERNAME: db2inst1

0 commit comments

Comments
 (0)