Skip to content

Commit 094e2a0

Browse files
committed
feat: update pipeline, dependencies
Signed-off-by: Rifa Achrinza <[email protected]>
1 parent 5903b26 commit 094e2a0

21 files changed

+6558
-106
lines changed

.github/codeql/codeql-config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
paths-ignore:
2+
- '**/test/**'
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
# The branches below must be a subset of the branches above
8+
branches: [master]
9+
schedule:
10+
- cron: '0 13 * * 6'
11+
12+
jobs:
13+
analyze:
14+
name: Analyze
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v2
20+
21+
- name: Initialize CodeQL
22+
uses: github/codeql-action/init@v1
23+
with:
24+
languages: 'javascript'
25+
config-file: ./.github/codeql/codeql-config.yml
26+
27+
- name: Perform CodeQL Analysis
28+
uses: github/codeql-action/analyze@v1
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Continuous Integration
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
# The branches below must be a subset of the branches above
8+
branches: [master]
9+
schedule:
10+
- cron: '0 2 * * 1' # At 02:00 on Monday
11+
12+
env:
13+
NODE_OPTIONS: --max-old-space-size=4096
14+
15+
jobs:
16+
test:
17+
name: Test
18+
timeout-minutes: 15
19+
strategy:
20+
matrix:
21+
os: [ubuntu-latest]
22+
node-version: [8.9, 10, 12, 14, 16]
23+
db2:
24+
- image-tag: latest
25+
port-num: 50000
26+
- image-tag: '11.5.0.0'
27+
port-num: 25000
28+
fail-fast: false
29+
runs-on: ${{ matrix.os }}
30+
services:
31+
db2:
32+
image: ibmcom/db2:${{ matrix.db2.image-tag }}
33+
env:
34+
DBNAME: STRONGLOOP
35+
DB2INSTANCE: db2inst1
36+
DB2INST1_PASSWORD: CIDBPassword123
37+
LICENSE: accept
38+
ports: ['${{ matrix.db2.port-num }}:${{ matrix.db2.port-num }}']
39+
options: >-
40+
--health-cmd="db2 connect to STRONGLOOP USER db2inst1 USING CIDBPassword123 && db2 ping hostdb"
41+
--health-timeout=0
42+
--health-retries=100
43+
env:
44+
DB2_USERNAME: db2inst1
45+
DB2_PASSWORD: CIDBPassword123
46+
DB2_PORTNUM: ${{ matrix.db2.port-num }}
47+
steps:
48+
- uses: actions/checkout@v2
49+
with:
50+
fetch-depth: 0
51+
- name: Use Node.js ${{ matrix.node-version }}
52+
uses: actions/setup-node@v2
53+
with:
54+
node-version: ${{ matrix.node-version }}
55+
- name: Bootstrap project
56+
if: ${{ matrix.node-version != '8.9' }}
57+
run: npm ci
58+
- name: Bootstrap project (Node v8.9)
59+
if: ${{ matrix.node-version == '8.9' }}
60+
run: npm install
61+
- name: Run tests
62+
run: |
63+
npm run pretest --ignore-scripts
64+
npm test --ignore-scripts
65+
66+
code-lint:
67+
name: Code Lint
68+
runs-on: ubuntu-latest
69+
steps:
70+
- uses: actions/checkout@v2
71+
- name: Use Node.js 14
72+
uses: actions/setup-node@v2
73+
with:
74+
node-version: 14
75+
- name: Bootstrap project
76+
if: ${{matrix.node-version != '8.9'}}
77+
run: npm ci
78+
- name: Bootstrap project (Node v8.9)
79+
if: ${{matrix.node-version == '8.9'}}
80+
run: npm install
81+
- name: Verify code linting
82+
run: npm run lint
83+
84+
commit-lint:
85+
name: Commit Lint
86+
runs-on: ubuntu-latest
87+
if: ${{ github.event.pull_request }}
88+
steps:
89+
- uses: actions/checkout@v2
90+
with:
91+
fetch-depth: 0
92+
- name: Use Node.js 14
93+
uses: actions/setup-node@v2
94+
with:
95+
node-version: 14
96+
- name: Bootstrap project
97+
if: ${{matrix.node-version != '8.9'}}
98+
run: npm ci
99+
- name: Bootstrap project (Node v8.9)
100+
if: ${{matrix.node-version == '8.9'}}
101+
run: npm install
102+
- name: Verify commit linting
103+
run: npx commitlint --from origin/master --to HEAD --verbose

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
package-lock=true
2+
scripts-prepend-node-path=true

.travis.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
arch:
2+
- ppc64le
3+
- s390x
4+
dist: bionic
5+
language: node_js
6+
services: [docker]
7+
node_js: [8.9, 9, 10, 12, 14, 16]
8+
9+
git:
10+
depth: 1
11+
12+
env:
13+
DB2_USERNAME: db2inst1
14+
DB2_PASSWORD: CIDBPassword123
15+
DB2_PORTNUM: 50000
16+
17+
matrix:
18+
include:
19+
env:
20+
DB2_PORTNUM: 50000
21+
DB2_IMAGE_TAG: latest
22+
env:
23+
DB2_PORTNUM: 25000
24+
DB2_IMAGE_TAG: '11.5.0.0'
25+
26+
before_install:
27+
- |-
28+
docker pull ibmcom/db1:$DB2_IMAGE_TAG
29+
docker run -dit \
30+
-p $DB2_PORTNUM:$DB2_PORTNUM \
31+
-e DBNAME=testdb\
32+
-e DB2INSTANCE=db2inst1 \
33+
-e DB2INST1_PASSWORD=CIDBPassword123 \
34+
-e LICENSE=accept
35+
ibmcom/db2
36+
# - |-
37+
# docker pull ibmcom/db2:11.5.0.0
38+
# docker run -dit \
39+
# -p 25000:25000 \
40+
# -e DBNAME=testdb\
41+
# -e DB2INSTANCE=db2inst1 \
42+
# -e DB2INST1_PASSWORD=CIDBPassword123 \
43+
# -e LICENSE=accept \
44+
# --health-cmd="db2 ping hostdb" \
45+
# --health-timeout=0 \
46+
# --health-retries=100 \
47+
# ibmcom/db2

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# loopback-connector-db2
22

3+
[![Build Status](https://travis-ci.com/loopbackio/loopback-connector-db2.svg?branch=master)](https://travis-ci.com/loopbackio/loopback-connector-db2)
4+
[![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)
5+
[![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)
6+
37
[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.
48
It is optimized to deliver industry-leading performance while lowering costs. The `loopback-connector-db2` module is the LoopBack connector for DB2.
59

commitlint.config.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright IBM Corp. 2017,2018. All Rights Reserved.
2+
// Node module: loopback-next
3+
// This file is licensed under the MIT License.
4+
// License text available at https://opensource.org/licenses/MIT
5+
'use strict';
6+
7+
const isCI = process.env.CI;
8+
module.exports = {
9+
extends: [
10+
'@commitlint/config-conventional',
11+
],
12+
rules: {
13+
'header-max-length': [2, 'always', 100],
14+
'body-leading-blank': [2, 'always'],
15+
'footer-leading-blank': [0, 'always'],
16+
// Only enforce the rule if CI flag is not set. This is useful for release
17+
// commits to skip DCO
18+
'signed-off-by': [isCI ? 0 : 2, 'always', 'Signed-off-by:'],
19+
},
20+
};

example/example.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55

66
'use strict';
77

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

11-
var config = {
11+
const config = {
1212
username: process.env.DB2_USERNAME,
1313
password: process.env.DB2_PASSWORD,
1414
hostname: process.env.DB2_HOSTNAME,
1515
port: 50000,
1616
database: 'SQLDB',
1717
};
1818

19-
var db = new DataSource(DB2, config);
19+
const db = new DataSource(DB2, config);
2020

21-
var User = db.define('User', {name: {type: String}, email: {type: String},
21+
const User = db.define('User', {name: {type: String}, email: {type: String},
2222
});
2323

2424
db.autoupdate('User', function(err) {
@@ -39,6 +39,6 @@ db.autoupdate('User', function(err) {
3939
});
4040

4141
User.destroyAll(function() {
42-
console.log('example complete');
42+
console.log('example compconste');
4343
});
4444
});

lib/db2.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
/*!
99
* DB2 connector for LoopBack
1010
*/
11-
var IBMDB = require('loopback-ibmdb').IBMDB;
12-
var util = require('util');
13-
var debug = require('debug')('loopback:connector:db2');
11+
const IBMDB = require('loopback-ibmdb').IBMDB;
12+
const util = require('util');
13+
const debug = require('debug')('loopback:connector:db2');
1414

1515
/**
1616
* Initialize the IBMDB connector for the given data source
@@ -48,10 +48,10 @@ util.inherits(DB2, IBMDB);
4848
DB2.prototype.create = function(model, data, options, callback) {
4949
debug('DB2.prototype.create: model=%s, data=%j, options=%j',
5050
model, data, options);
51-
var self = this;
52-
var stmt = self.buildInsert(model, data, options);
53-
var idName = self.idColumn(model);
54-
var sql;
51+
const self = this;
52+
const stmt = self.buildInsert(model, data, options);
53+
const idName = self.idColumn(model);
54+
let sql;
5555

5656
if (!data[idName]) {
5757
sql = 'SELECT \"' + idName + '\" FROM FINAL TABLE (' +
@@ -84,15 +84,15 @@ DB2.prototype.create = function(model, data, options, callback) {
8484
DB2.prototype.update = function(model, where, data, options, cb) {
8585
debug('DB2.prototype.update: model=%s, where=%j, data=%j options=%j',
8686
model, where, data, options);
87-
var self = this;
88-
var stmt = self.buildUpdate(model, where, data, options);
89-
var idName = self.idColumn(model);
90-
var sql = 'SELECT COUNT(\"' + idName + '\") AS \"affectedRows\" ' +
87+
const self = this;
88+
const stmt = self.buildUpdate(model, where, data, options);
89+
const idName = self.idColumn(model);
90+
const sql = 'SELECT COUNT(\"' + idName + '\") AS \"affectedRows\" ' +
9191
'FROM FINAL TABLE (' + stmt.sql + ')';
9292
self.execute(sql, stmt.params, options, function(err, info) {
9393
if (cb) {
9494
if (!err && info && info.length > 0) {
95-
var count = Number.parseInt(info[0].affectedRows, 10);
95+
const count = Number.parseInt(info[0].affectedRows, 10);
9696
return cb(null, {count: count});
9797
}
9898
cb(err);
@@ -111,15 +111,15 @@ DB2.prototype.update = function(model, where, data, options, cb) {
111111
DB2.prototype.destroyAll = function(model, where, options, cb) {
112112
debug('DB2.prototype.destroyAll: model=%s, where=%j, options=%j',
113113
model, where, options);
114-
var self = this;
115-
var stmt = self.buildDelete(model, where, options);
116-
var idName = self.idColumn(model);
117-
var sql = 'SELECT COUNT(\"' + idName + '\") AS \"affectedRows\" ' +
114+
const self = this;
115+
const stmt = self.buildDelete(model, where, options);
116+
const idName = self.idColumn(model);
117+
const sql = 'SELECT COUNT(\"' + idName + '\") AS \"affectedRows\" ' +
118118
'FROM OLD TABLE (' + stmt.sql + ')';
119119
self.execute(sql, stmt.params, options, function(err, info) {
120120
if (cb) {
121121
if (!err && info && info.length > 0) {
122-
var count = Number.parseInt(info[0].affectedRows, 10);
122+
const count = Number.parseInt(info[0].affectedRows, 10);
123123
return cb(null, {count: count});
124124
}
125125
cb(err);

0 commit comments

Comments
 (0)