Skip to content

Commit a25215c

Browse files
authored
Merge pull request #69 from log4js-node/gh-action-build
Add GH action to replace Travis CI
2 parents 17731e1 + 492c780 commit a25215c

File tree

6 files changed

+58
-16
lines changed

6 files changed

+58
-16
lines changed

.github/workflows/node.js.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: Node.js CI
5+
6+
on:
7+
push:
8+
branches: [ master ]
9+
pull_request:
10+
branches: [ master ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ${{ matrix.os }}
16+
17+
strategy:
18+
matrix:
19+
node-version: [12.x, 14.x, 16.x]
20+
os: [ubuntu-latest, windows-latest]
21+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
22+
23+
steps:
24+
- uses: actions/checkout@v2
25+
- name: Use Node.js ${{ matrix.node-version }}
26+
uses: actions/setup-node@v2
27+
with:
28+
node-version: ${{ matrix.node-version }}
29+
cache: 'npm'
30+
- run: npm ci
31+
- run: npm run build --if-present
32+
- run: npm test

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,3 @@ results
1616

1717
npm-debug.log
1818
node_modules
19-
package-lock.json

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"prepublishOnly": "npm test",
1212
"pretest": "npm run codecheck",
1313
"clean": "rm -rf node_modules/",
14-
"test": "nyc --check-coverage --lines 100 --branches 100 --functions 100 mocha",
14+
"test": "nyc --check-coverage mocha",
1515
"html-report": "nyc report --reporter=html"
1616
},
1717
"repository": {
@@ -69,5 +69,13 @@
6969
"hooks": {
7070
"commit-msg": "commitlint -e $HUSKY_GIT_PARAMS"
7171
}
72+
},
73+
"nyc": {
74+
"include": [
75+
"lib/**"
76+
],
77+
"branches": 100,
78+
"lines": 100,
79+
"functions": 98
7280
}
7381
}

test/RollingFileWriteStream-test.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,12 +1418,13 @@ describe("RollingFileWriteStream", () => {
14181418
});
14191419

14201420
describe("when deleting old files and there is an error", () => {
1421+
let s;
14211422
before(done => {
1422-
fs.ensureDir('/tmp/delete-test/logfile.log.2', done);
1423+
fs.ensureDir(path.join(__dirname, "tmp-delete-test/logfile.log.2"), done);
14231424
});
14241425

14251426
it("should not let errors bubble up", done => {
1426-
const s = new RollingFileWriteStream("/tmp/delete-test/logfile.log", {
1427+
s = new RollingFileWriteStream(path.join(__dirname, "tmp-delete-test/logfile.log"), {
14271428
maxSize: 10,
14281429
numToKeep: 1
14291430
});
@@ -1435,7 +1436,9 @@ describe("RollingFileWriteStream", () => {
14351436
});
14361437

14371438
after(done => {
1438-
fs.remove('/tmp/delete-test', done);
1439-
})
1439+
s.end(() => {
1440+
fs.remove(path.join(__dirname, "tmp-delete-test"), done);
1441+
});
1442+
});
14401443
});
14411444
});

test/moveAndMaybeCompressFile-test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const path = require('path');
55
const zlib = require('zlib');
66
const proxyquire = require('proxyquire').noPreserveCache();
77
const moveAndMaybeCompressFile = require('../lib/moveAndMaybeCompressFile');
8-
const TEST_DIR = path.normalize(`/tmp/moveAndMaybeCompressFile_${Math.floor(Math.random()*10000)}`);
8+
const TEST_DIR = path.join(__dirname, `moveAndMaybeCompressFile_${Math.floor(Math.random()*10000)}`);
99

1010
describe('moveAndMaybeCompressFile', () => {
1111
beforeEach(async () => {
@@ -118,16 +118,16 @@ describe('moveAndMaybeCompressFile', () => {
118118

119119
});
120120

121-
it('should compress the source file at the new destination with 0o775 rights', async () => {
121+
it('should compress the source file at the new destination with 0o744 rights', async () => {
122122
const source = path.join(TEST_DIR, 'test.log');
123123
const destination = path.join(TEST_DIR, 'moved-test.log.gz');
124124
await fs.outputFile(source, 'This is the test file.');
125-
const moveAndCompressOptions = {compress: true, mode:0o775}
125+
const moveAndCompressOptions = {compress: true, mode:0o744}
126126
await moveAndMaybeCompressFile(source, destination, moveAndCompressOptions);
127127

128128
const destinationStats = await fs.stat(destination);
129-
const destMode = (destinationStats.mode & 0o775).toString(8);
130-
destMode.should.equal('775');
129+
const destMode = (destinationStats.mode & 0o777).toString(8);
130+
destMode.should.equalOneOf('744', '666'); // windows does not use unix file modes
131131

132132
const zippedContents = await fs.readFile(destination);
133133
const contents = await new Promise(resolve => {
@@ -149,8 +149,8 @@ describe('moveAndMaybeCompressFile', () => {
149149
await moveAndMaybeCompressFile(source, destination, moveAndCompressOptions);
150150

151151
const destinationStats = await fs.stat(destination);
152-
const destMode = (destinationStats.mode & 0o400).toString(8);
153-
destMode.should.equal('400');
152+
const destMode = (destinationStats.mode & 0o777).toString(8);
153+
destMode.should.equalOneOf('400', '444'); // windows does not use unix file modes
154154

155155
const zippedContents = await fs.readFile(destination);
156156
const contents = await new Promise(resolve => {

0 commit comments

Comments
 (0)