Skip to content

Commit

Permalink
feat: update pipeline, dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Rifa Achrinza <[email protected]>
  • Loading branch information
achrinza committed Jul 25, 2021
1 parent 5903b26 commit 07340e6
Show file tree
Hide file tree
Showing 21 changed files with 6,537 additions and 106 deletions.
2 changes: 2 additions & 0 deletions .github/codeql/codeql-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
paths-ignore:
- '**/test/**'
28 changes: 28 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "CodeQL"

on:
push:
branches: [master]
pull_request:
# The branches below must be a subset of the branches above
branches: [master]
schedule:
- cron: '0 13 * * 6'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: 'javascript'
config-file: ./.github/codeql/codeql-config.yml

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
98 changes: 98 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Continuous Integration

on:
push:
branches: [master]
pull_request:
# The branches below must be a subset of the branches above
branches: [master]
schedule:
- cron: '0 2 * * 1' # At 02:00 on Monday

env:
NODE_OPTIONS: --max-old-space-size=4096

jobs:
test:
name: Test
timeout-minutes: 15
strategy:
matrix:
os: [ubuntu-latest]
node-version: [8.9, 10, 12, 14, 16]
db2-service-image: ['ibmcom/db2:latest', 'ibmcom/db2:11.5.0.0']
fail-fast: false
runs-on: ${{ matrix.os }}
services:
db2:
image: ${{ matrix.db2-service-image }}
env:
DBNAME: testdb
DB2INSTANCE: db2inst1
DB2INST1_PASSWORD: CIDBPassword123
LICENSE: accept
ports: ['50000:50000']
options: >-
--health-cmd='db2 ping hostdb'
--health-timeout=0
--privileged
env:
DB2_USERNAME: db2inst1
DB2_PASSWORD: CIDBPassword123
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Bootstrap project
if: ${{ matrix.node-version != '8.9' }}
run: npm ci
- name: Bootstrap project (Node v8.9)
if: ${{ matrix.node-version == '8.9' }}
run: npm install
- name: Run tests
run: |
npm run pretest --ignore-scripts
npm test --ignore-scripts
code-lint:
name: Code Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14
uses: actions/setup-node@v2
with:
node-version: 14
- name: Bootstrap project
if: ${{matrix.node-version != '8.9'}}
run: npm ci
- name: Bootstrap project (Node v8.9)
if: ${{matrix.node-version == '8.9'}}
run: npm install
- name: Verify code linting
run: npm run lint

commit-lint:
name: Commit Lint
runs-on: ubuntu-latest
if: ${{ github.event.pull_request }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Use Node.js 14
uses: actions/setup-node@v2
with:
node-version: 14
- name: Bootstrap project
if: ${{matrix.node-version != '8.9'}}
run: npm ci
- name: Bootstrap project (Node v8.9)
if: ${{matrix.node-version == '8.9'}}
run: npm install
- name: Verify commit linting
run: npx commitlint --from origin/master --to HEAD --verbose
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package-lock=true
scripts-prepend-node-path=true
31 changes: 31 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
arch:
- ppc64le
- s390x
- arm64
language: node_js
services: [docker]
node_js: [8.9, 9, 10, 12, 14, 16]

env:
DB2_USERNAME: db2inst1
DB2_PASSWORD: CIDBPassword123

before_install:
- |
docker pull ibmcom/db2
docker run ibmcom/db2 \
-d \
-p 25000:25000 \
-e DBNAME=testdb\
-e DB2INSTANCE=db2inst1 \
-e DB2INST1_PASSWORD=CIDBPassword123 \
-e LICENSE=accept
- |
docker pull ibmcom/db2:11.5.0.0
docker run ibmcom/db2
-d \
-p 25000:25000 \
-e DBNAME=testdb\
-e DB2INSTANCE=db2inst1 \
-e DB2INST1_PASSWORD=CIDBPassword123 \
-e LICENSE=accept
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# loopback-connector-db2

[![Build Status](https://travis-ci.com/loopbackio/loopback-connector-db2.svg?branch=master)](https://travis-ci.com/loopbackio/loopback-connector-db2)
[![Continuous Integration](https://github.com/loopbackio/loopback-connector-db2/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/loopbackio/loopback-connector-db2/actions/workflows/continuous-integration.yml)
[![CodeQL](https://github.com/loopbackio/loopback-connector-db2/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/loopbackio/loopback-connector-db2/actions/workflows/codeql-analysis.yml)

[IBM® DB2®](http://www.ibm.com/analytics/us/en/technology/db2/) is the database of choice for robust, enterprise-wide solutions handling high-volume workloads.
It is optimized to deliver industry-leading performance while lowering costs. The `loopback-connector-db2` module is the LoopBack connector for DB2.

Expand Down
20 changes: 20 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright IBM Corp. 2017,2018. All Rights Reserved.
// Node module: loopback-next
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/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:'],
},
};
12 changes: 6 additions & 6 deletions example/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@

'use strict';

var DataSource = require('loopback-datasource-juggler').DataSource;
var DB2 = require('../'); // loopback-connector-db2
const DataSource = require('loopback-datasource-juggler').DataSource;
const DB2 = require('../'); // loopback-connector-db2

var config = {
const config = {
username: process.env.DB2_USERNAME,
password: process.env.DB2_PASSWORD,
hostname: process.env.DB2_HOSTNAME,
port: 50000,
database: 'SQLDB',
};

var db = new DataSource(DB2, config);
const db = new DataSource(DB2, config);

var User = db.define('User', {name: {type: String}, email: {type: String},
const User = db.define('User', {name: {type: String}, email: {type: String},
});

db.autoupdate('User', function(err) {
Expand All @@ -39,6 +39,6 @@ db.autoupdate('User', function(err) {
});

User.destroyAll(function() {
console.log('example complete');
console.log('example compconste');
});
});
34 changes: 17 additions & 17 deletions lib/db2.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
/*!
* DB2 connector for LoopBack
*/
var IBMDB = require('loopback-ibmdb').IBMDB;
var util = require('util');
var debug = require('debug')('loopback:connector:db2');
const IBMDB = require('loopback-ibmdb').IBMDB;
const util = require('util');
const debug = require('debug')('loopback:connector:db2');

/**
* Initialize the IBMDB connector for the given data source
Expand Down Expand Up @@ -48,10 +48,10 @@ util.inherits(DB2, IBMDB);
DB2.prototype.create = function(model, data, options, callback) {
debug('DB2.prototype.create: model=%s, data=%j, options=%j',
model, data, options);
var self = this;
var stmt = self.buildInsert(model, data, options);
var idName = self.idColumn(model);
var sql;
const self = this;
const stmt = self.buildInsert(model, data, options);
const idName = self.idColumn(model);
let sql;

if (!data[idName]) {
sql = 'SELECT \"' + idName + '\" FROM FINAL TABLE (' +
Expand Down Expand Up @@ -84,15 +84,15 @@ DB2.prototype.create = function(model, data, options, callback) {
DB2.prototype.update = function(model, where, data, options, cb) {
debug('DB2.prototype.update: model=%s, where=%j, data=%j options=%j',
model, where, data, options);
var self = this;
var stmt = self.buildUpdate(model, where, data, options);
var idName = self.idColumn(model);
var sql = 'SELECT COUNT(\"' + idName + '\") AS \"affectedRows\" ' +
const self = this;
const stmt = self.buildUpdate(model, where, data, options);
const idName = self.idColumn(model);
const sql = 'SELECT COUNT(\"' + idName + '\") AS \"affectedRows\" ' +
'FROM FINAL TABLE (' + stmt.sql + ')';
self.execute(sql, stmt.params, options, function(err, info) {
if (cb) {
if (!err && info && info.length > 0) {
var count = Number.parseInt(info[0].affectedRows, 10);
const count = Number.parseInt(info[0].affectedRows, 10);
return cb(null, {count: count});
}
cb(err);
Expand All @@ -111,15 +111,15 @@ DB2.prototype.update = function(model, where, data, options, cb) {
DB2.prototype.destroyAll = function(model, where, options, cb) {
debug('DB2.prototype.destroyAll: model=%s, where=%j, options=%j',
model, where, options);
var self = this;
var stmt = self.buildDelete(model, where, options);
var idName = self.idColumn(model);
var sql = 'SELECT COUNT(\"' + idName + '\") AS \"affectedRows\" ' +
const self = this;
const stmt = self.buildDelete(model, where, options);
const idName = self.idColumn(model);
const sql = 'SELECT COUNT(\"' + idName + '\") AS \"affectedRows\" ' +
'FROM OLD TABLE (' + stmt.sql + ')';
self.execute(sql, stmt.params, options, function(err, info) {
if (cb) {
if (!err && info && info.length > 0) {
var count = Number.parseInt(info[0].affectedRows, 10);
const count = Number.parseInt(info[0].affectedRows, 10);
return cb(null, {count: count});
}
cb(err);
Expand Down
Loading

0 comments on commit 07340e6

Please sign in to comment.