Skip to content

Commit 07340e6

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

21 files changed

+6537
-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/**'

.github/workflows/codeql-analysis.yml

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: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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-service-image: ['ibmcom/db2:latest', 'ibmcom/db2:11.5.0.0']
24+
fail-fast: false
25+
runs-on: ${{ matrix.os }}
26+
services:
27+
db2:
28+
image: ${{ matrix.db2-service-image }}
29+
env:
30+
DBNAME: testdb
31+
DB2INSTANCE: db2inst1
32+
DB2INST1_PASSWORD: CIDBPassword123
33+
LICENSE: accept
34+
ports: ['50000:50000']
35+
options: >-
36+
--health-cmd='db2 ping hostdb'
37+
--health-timeout=0
38+
--privileged
39+
env:
40+
DB2_USERNAME: db2inst1
41+
DB2_PASSWORD: CIDBPassword123
42+
steps:
43+
- uses: actions/checkout@v2
44+
with:
45+
fetch-depth: 0
46+
- name: Use Node.js ${{ matrix.node-version }}
47+
uses: actions/setup-node@v2
48+
with:
49+
node-version: ${{ matrix.node-version }}
50+
- name: Bootstrap project
51+
if: ${{ matrix.node-version != '8.9' }}
52+
run: npm ci
53+
- name: Bootstrap project (Node v8.9)
54+
if: ${{ matrix.node-version == '8.9' }}
55+
run: npm install
56+
- name: Run tests
57+
run: |
58+
npm run pretest --ignore-scripts
59+
npm test --ignore-scripts
60+
61+
code-lint:
62+
name: Code Lint
63+
runs-on: ubuntu-latest
64+
steps:
65+
- uses: actions/checkout@v2
66+
- name: Use Node.js 14
67+
uses: actions/setup-node@v2
68+
with:
69+
node-version: 14
70+
- name: Bootstrap project
71+
if: ${{matrix.node-version != '8.9'}}
72+
run: npm ci
73+
- name: Bootstrap project (Node v8.9)
74+
if: ${{matrix.node-version == '8.9'}}
75+
run: npm install
76+
- name: Verify code linting
77+
run: npm run lint
78+
79+
commit-lint:
80+
name: Commit Lint
81+
runs-on: ubuntu-latest
82+
if: ${{ github.event.pull_request }}
83+
steps:
84+
- uses: actions/checkout@v2
85+
with:
86+
fetch-depth: 0
87+
- name: Use Node.js 14
88+
uses: actions/setup-node@v2
89+
with:
90+
node-version: 14
91+
- name: Bootstrap project
92+
if: ${{matrix.node-version != '8.9'}}
93+
run: npm ci
94+
- name: Bootstrap project (Node v8.9)
95+
if: ${{matrix.node-version == '8.9'}}
96+
run: npm install
97+
- name: Verify commit linting
98+
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: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
arch:
2+
- ppc64le
3+
- s390x
4+
- arm64
5+
language: node_js
6+
services: [docker]
7+
node_js: [8.9, 9, 10, 12, 14, 16]
8+
9+
env:
10+
DB2_USERNAME: db2inst1
11+
DB2_PASSWORD: CIDBPassword123
12+
13+
before_install:
14+
- |
15+
docker pull ibmcom/db2
16+
docker run ibmcom/db2 \
17+
-d \
18+
-p 25000:25000 \
19+
-e DBNAME=testdb\
20+
-e DB2INSTANCE=db2inst1 \
21+
-e DB2INST1_PASSWORD=CIDBPassword123 \
22+
-e LICENSE=accept
23+
- |
24+
docker pull ibmcom/db2:11.5.0.0
25+
docker run ibmcom/db2
26+
-d \
27+
-p 25000:25000 \
28+
-e DBNAME=testdb\
29+
-e DB2INSTANCE=db2inst1 \
30+
-e DB2INST1_PASSWORD=CIDBPassword123 \
31+
-e LICENSE=accept

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)