added github action script
This commit is contained in:
parent
193658a2ad
commit
eb1f27bb58
33
.github/workflows/test.yml
vendored
Normal file
33
.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
name: Test
|
||||
|
||||
on: [
|
||||
pull_request,
|
||||
push
|
||||
]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
node-version: [10.x, 11.x, 12.x, 13.x, 14.x, 15.x, 16.x]
|
||||
include:
|
||||
- os: macos-latest
|
||||
node-version: 14.x
|
||||
- os: macos-latest
|
||||
node-version: 16.x
|
||||
- os: windows-latest
|
||||
node-version: 14.x
|
||||
- os: windows-latest
|
||||
node-version: 16.x
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- run: npm install
|
||||
- run: node test/ci.js
|
||||
46
test/ci.js
Normal file
46
test/ci.js
Normal file
@ -0,0 +1,46 @@
|
||||
const si = require('../lib/index');
|
||||
|
||||
const testWithTimeout = async (fn) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
(async () => {
|
||||
const timeout = setTimeout(() => {
|
||||
reject('Test Timeout');
|
||||
}, 15000);
|
||||
const result = await fn();
|
||||
clearTimeout(timeout);
|
||||
return resolve(result);
|
||||
})();
|
||||
});
|
||||
};
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
// console.log('Testing osInfo:');
|
||||
// console.log(await testWithTimeout(si.osInfo));
|
||||
|
||||
console.log('Testing networkInterfaces:');
|
||||
console.log(await testWithTimeout(si.networkInterfaces));
|
||||
|
||||
console.log('Testing networkInterfaceDefault:');
|
||||
console.log(await testWithTimeout(si.networkInterfaceDefault));
|
||||
|
||||
console.log('Testing time:');
|
||||
console.log(await testWithTimeout(si.time));
|
||||
|
||||
console.log('Testing currentLoad:');
|
||||
console.log(await testWithTimeout(si.currentLoad));
|
||||
|
||||
console.log('Testing mem:');
|
||||
console.log(await testWithTimeout(si.mem));
|
||||
|
||||
console.log('Testing cpuTemperature:');
|
||||
console.log(await testWithTimeout(si.cpuTemperature));
|
||||
|
||||
console.log('All tests complete.');
|
||||
process.exit(0);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
console.log('One or more tests failed.');
|
||||
process.exit(1);
|
||||
}
|
||||
})();
|
||||
Loading…
x
Reference in New Issue
Block a user