Skip to content

Commit

Permalink
ci: shell-based test harness
Browse files Browse the repository at this point in the history
Signed-off-by: Rifa Achrinza <[email protected]>
  • Loading branch information
achrinza committed Nov 3, 2024
1 parent 07cdcec commit b15d4a1
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 12 deletions.
41 changes: 31 additions & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,11 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 1
submodules: true
- name: Run test harness
uses: ./test
with:
node-version: ${{ github.matrix.node-version }}
db2-version: ${{ github.matrix.db2-version }}
_internal-mode: true

env:
DB2_VERSION: ${{ matrix.db2-version }}
run: ./cicd/well-known/test-harness.sh
test-ibmdb:
name: Cross-test (IBM DB)
runs-on: ubuntu-24.04
Expand All @@ -133,8 +131,31 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 1
- name: Run test harness
uses: loopbackio/loopback-ibmdb/test@ci/ghaction-test
path: loopback-connector-db2
- name: Prepare for cross-testing
run: |-
mkdir nodejs-autoinstall
cd loopback-connector-db2
npm ci --ignore-scripts
npm pack --pack-destination ../nodejs-autoinstall
- name: Clone IBM DB repository
run: |-
git clone \
--shallow-submodules \
--branch=ci/ghaction-test \
--depth=1 \
https://github.com/loopbackio/loopback-ibmdb.git
cd loopback-ibmdb
git submodule update --init
- name: Setup Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: ${{ github.matrix.node-version }}
db2-version: ${{ github.matrix.db2-version }}
node-version: 22
cache: npm
cache-dependency-path: |-
./loopback-ibmdb/package-lock.json
./loopback-connector-db2/package-lock.json
- name: Run test harness
env:
DB2_VERSION: ${{ matrix.db2-version }}
run: ./loopback-ibmdb/cicd/well-known/test-harness.sh
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "cicd/vendor/setup-db2"]
path = cicd/vendor/setup-db2
url = https://github.com/achrinza/setup-db2.git
branch = v0.1.0
1 change: 1 addition & 0 deletions cicd/vendor/setup-db2
Submodule setup-db2 added at 1ecca5
53 changes: 53 additions & 0 deletions cicd/well-known/test-harness.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/sh
export POSIXLY_CORRECT=1
set -eu

export DB2_USERNAME=db2inst1
export DB2_PASSWORD=P00lGnorts
export DB2_HOSTNAME=localhost
export DB2_PORTNUM=50000
export DB2_DATABASE=mydb

BASE_DIR="$(dirname "$0")/../.."
CI_NODEJS_AUTOINSTALL_DIR="${CI_NODEJSAUTOINSTALL_DIR:-}"
STARTDB2_SCRIPT="$BASE_DIR/cicd/vendor/setup-db2/start-db2.sh"

STEP_COUNT=1

step () {
printf "\n\n============================================================================\n"
printf 'STEP #%d: %s\n' "$STEP_COUNT" "$1"
printf "\n============================================================================\n\n"
STEP_COUNT="$((STEP_COUNT + 1))"
}

ORIG_DIR="$(pwd)"
cd "$BASE_DIR"

step 'Bootstrap dependencies'
npm ci --prefer-offline

step 'Bootstrap overriding dependencies'
if [ -d "$CI_NODEJS_AUTOINSTALL_DIR" ]; then
find \
"$CI_NODEJS_AUTOINSTALL_DIR" \
-iname '*.tgz' \
-exec \
npm install {} \;
fi
npm install --prefer-offline

step 'Start DB2 LUW server'
"$STARTDB2_SCRIPT" \
-l accept \
-V "$DB2_VERSION" \
-p 'P00lGnorts'

step 'Run tests'
npm run pretest --ignore-scripts
npm test --ignore-scripts

step 'Teardown DB2 LUW server'
"$STARTDB2_SCRIPT" -C

cd "$ORIG_DIR"
2 changes: 0 additions & 2 deletions test/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ runs:
db2-license: accept
db2-version: ${{ matrix.db2-version }}
db2-password: P00lGnorts
- name: Setup FakeTTY
uses: Yuri6037/Action-FakeTTY@1abc69c7d530815855caedcd73842bae5687c1a6 # V1.1
- name: Run tests
env:
DB2_USERNAME: db2inst1
Expand Down

0 comments on commit b15d4a1

Please sign in to comment.