Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 80
181 changes: 181 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: Copyright 2024 LoopBack contributors
name: CI

on:
push:
branches:
- master
pull_request:
branches:
- master

permissions: {}

jobs:
code-lint:
name: Code lint
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- name: Harden runner
uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: 22
cache: npm
- name: Bootstrap dependencies
run: npm ci --ignore-scripts
- name: Verify code linting
run: npm run lint --ignore-scripts
commit-lint:
name: Commit lint
runs-on: ubuntu-24.04
timeout-minutes: 5
if: ${{ github.event.pull_request }}
steps:
- name: Harden runner
uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: 22
cache: npm
- name: Bootstrap dependencies
run: npm ci --ignore-scripts
- name: Verify commit linting
run: |-
npm exec \
--no \
--package=@commitlint/cli \
-- \
commitlint \
--from=origin/master \
--to=HEAD \
--verbose
license-lint:
name: License lint
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- name: Harden runner
uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
github.com:443
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 1
- name: Setup REUSE tool
uses: fsfe/reuse-action@3ae3c6bdf1257ab19397fab11fd3312144692083 # v4.0.0
test:
name: Test
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- os: macos-13
node-version: 22
db2-version: :11.5.9.0@sha256:77095d4e04cf4448c0257086afcb2c166193d718dc33441da3b949f97e21efd5
os:
- ubuntu-24.04
node-version:
- 16
- 18
- 20
- 22
db2-version:
- :11.5.9.0@sha256:77095d4e04cf4448c0257086afcb2c166193d718dc33441da3b949f97e21efd5
steps:
- name: Harden runner
uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0
with:
egress-policy: audit
- name: Setup Docker (macOS)
if: matrix.os == 'macos-13'
uses: douglascamata/setup-docker-macos-action@8d5fa43892aed7eee4effcdea113fd53e4d4bf83 # v1-alpha.14
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 1
submodules: true
- name: Setup Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: 22
cache: npm
- name: Run test harness
env:
DB2_VERSION: ${{ matrix.db2-version }}
run: ./cicd/well-known/test-harness.sh
cross-test:
name: Cross-test
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os:
- ubuntu-24.04
- macos-13
node-version:
- 18
- 20
- 22
db2-version:
- :11.5.9.0@sha256:77095d4e04cf4448c0257086afcb2c166193d718dc33441da3b949f97e21efd5
steps:
- name: Harden runner
uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0
with:
egress-policy: audit
- name: Setup Docker (macOS)
if: matrix.os == 'macos-13'
uses: douglascamata/setup-docker-macos-action@8d5fa43892aed7eee4effcdea113fd53e4d4bf83 # v1-alpha.14
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 1
submodules: true
path: loopback-ibmdb
- name: Clone DB2 connector repository
run: |
git clone \
--branch=ci/ghaction-test \
--depth=1 \
https://github.com/loopbackio/loopback-connector-db2.git
cd loopback-connector-db2
git submodule update --init --depth=1
- name: Setup Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: ${{ matrix.node-version }}
cache: npm
cache-dependency-path: |
./loopback-connector-db2/package-lock.json
./loopback-ibmdb/package-lock.json
- name: Bootstrap dependencies
run: |
cd loopback-ibmdb
npm ci --ignore-scripts
- name: Setup and run test harness
env:
DB2_VERSION: ${{ matrix.db2-version }}
run: |
./loopback-ibmdb/cicd/well-known/prepare-autoinstall.sh
. ./loopback-ibmdb/cicd/tmp/well-known/set-env/post-prepare-autoinstall.sh
./loopback-connector-db2/cicd/well-known/test-harness.sh
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
node_modules
.DS_Store

# CI/CD
/cicd/tmp

# Code editors
\#*#
.#*
*~
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
32 changes: 32 additions & 0 deletions cicd/well-known/prepare-autoinstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh
# SPDX-FileCopyrightText: Copyright 2024 LoopBack contributors
# SPDX-License-Identifier: MIT
export POSIXLY_CORRECT=1
set -euv

ORIG_DIR="$(pwd)"
cd "$(dirname "$0")/../.."
BASE_DIR="$(pwd)"

CI_NODEJS_AUTOINSTALL_DIR="$BASE_DIR/cicd/tmp/nodejs-autoinstall"
PREPARE_POSTINSTALL_SCRIPT="$BASE_DIR/cicd/tmp/well-known/set-env/post-prepare-autoinstall.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 --ignore-scripts

step 'Pack for autoinstall'
mkdir -p "$CI_NODEJS_AUTOINSTALL_DIR"
npm pack --pack-destination="$CI_NODEJS_AUTOINSTALL_DIR"

mkdir -p "$(dirname "$PREPARE_POSTINSTALL_SCRIPT")"
echo "export CI_NODEJS_AUTOINSTALL_DIR=\"$CI_NODEJS_AUTOINSTALL_DIR\"" >"$PREPARE_POSTINSTALL_SCRIPT"
chmod +x "$PREPARE_POSTINSTALL_SCRIPT"
56 changes: 56 additions & 0 deletions cicd/well-known/test-harness.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/sh
# SPDX-FileCopyrightText: Copyright 2024 LoopBack contributors
# SPDX-License-Identifier: MIT
export POSIXLY_CORRECT=1
set -euv

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

ORIG_DIR="$(pwd)"
cd "$(dirname "$0")/../.."
BASE_DIR="$(pwd)"

CI_NODEJS_AUTOINSTALL_DIR="${CI_NODEJS_AUTOINSTALL_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))"
}

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

step 'Bootstrap overriding dependencies'
if [ "$CI_NODEJS_AUTOINSTALL_DIR" != '' ]; then
printf "$CI_NODEJS_AUTOINSTALL_DIR" |
xargs -d: \
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 test --ignore-scripts

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

cd "$ORIG_DIR"
17 changes: 17 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-FileCopyrightText: Copyright 2024 LoopBack contributors
// SPDX-License-Identifier: MIT
'use strict';

const isCI = process.env.CI;

module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'header-max-length': [2, 'always', 100],
'body-leading-blank': [2, 'always'],
'footer-leading-blank': [0, 'always'],
// Only enforce the rule if CI flag is not set. This is useful for release
// commits to skip DCO
'signed-off-by': [isCI ? 0 : 2, 'always', 'Signed-off-by:'],
},
};
Loading
Loading