From 62971d2a8c25b4d97857bccd32dcd662b67d0d8a Mon Sep 17 00:00:00 2001 From: Rifa Achrinza <25147899+achrinza@users.noreply.github.com> Date: Sun, 3 Nov 2024 02:37:49 +0800 Subject: [PATCH] ci: shell-based test harness Signed-off-by: Rifa Achrinza <25147899+achrinza@users.noreply.github.com> --- .github/workflows/ci.yaml | 40 +++++++++++++++++++++------- .gitmodules | 4 +++ cicd/vendor/setup-db2 | 1 + cicd/well-known/test-harness.sh | 47 +++++++++++++++++++++++++++++++++ test/action.yaml | 2 -- 5 files changed, 82 insertions(+), 12 deletions(-) create mode 100644 .gitmodules create mode 160000 cicd/vendor/setup-db2 create mode 100755 cicd/well-known/test-harness.sh diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8272a3a..f90f4d0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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 @@ -133,8 +131,30 @@ 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 \ + --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 diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..e1b5bfb --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "cicd/vendor/setup-db2"] + path = cicd/vendor/setup-db2 + url = https://github.com/achrinza/setup-db2.git + branch = main diff --git a/cicd/vendor/setup-db2 b/cicd/vendor/setup-db2 new file mode 160000 index 0000000..1ecca51 --- /dev/null +++ b/cicd/vendor/setup-db2 @@ -0,0 +1 @@ +Subproject commit 1ecca51b69f420b59cf0ada9f66a1a476b4061fe diff --git a/cicd/well-known/test-harness.sh b/cicd/well-known/test-harness.sh new file mode 100755 index 0000000..6872190 --- /dev/null +++ b/cicd/well-known/test-harness.sh @@ -0,0 +1,47 @@ +#!/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 + +CI_NODEJS_AUTOINSTALL_DIR="${CI_NODEJSAUTOINSTALL_DIR:-}" +STARTDB2_SCRIPT="$(dirname "$0")/../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))" +} + +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 diff --git a/test/action.yaml b/test/action.yaml index ccf9739..a8150b3 100644 --- a/test/action.yaml +++ b/test/action.yaml @@ -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