From eb1f27bb58a96e7f1399d8c520a092043e174aee Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Thu, 26 Aug 2021 14:47:38 +0200 Subject: [PATCH] added github action script --- .github/workflows/test.yml | 33 +++++++++++++++++++++++++++ test/ci.js | 46 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 .github/workflows/test.yml create mode 100644 test/ci.js diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..e5a5341 --- /dev/null +++ b/.github/workflows/test.yml @@ -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 diff --git a/test/ci.js b/test/ci.js new file mode 100644 index 0000000..f5dd585 --- /dev/null +++ b/test/ci.js @@ -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); + } +})();