Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
120 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: CI | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [12.x, 14.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Cache Node.js modules | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS | ||
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.OS }}-node- | ||
${{ runner.OS }}- | ||
- run: npm ci | ||
- run: npm build | ||
- run: npm run lint | ||
- run: npm run cover | ||
env: | ||
TESTPLAYER: "76561198028175941" | ||
- name: Test & publish code coverage | ||
uses: paambaati/codeclimate-action@v2.6.0 | ||
env: | ||
CC_TEST_REPORTER_ID: ${{ secrets.CODECLIMATE_TOKEN }} | ||
coverageLocations: | | ||
./coverage/lcov.info:lcov | ||
with: | ||
coverageCommand: npm run cover | ||
- uses: codecov/codecov-action@v1 | ||
with: | ||
file: ./coverage/lcov.info | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: dist | ||
path: ./dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: Release | ||
on: | ||
push: | ||
tags: | ||
- v*.*.* | ||
jobs: | ||
build-and-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js 14 | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 14 | ||
- run: npm ci | ||
- run: npm build | ||
- run: npm run lint | ||
- run: npm run cover | ||
env: | ||
TESTPLAYER: "76561198028175941" | ||
|
||
build-and-publish-npm: | ||
needs: build-and-test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
with: | ||
fetch-depth: 1 | ||
# Setup .npmrc file to publish to npm | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 14 | ||
registry-url: "https://registry.npmjs.org" | ||
- run: npm ci | ||
- run: npm run build | ||
- run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
build-and-publish-gpr: | ||
needs: build-and-test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
with: | ||
fetch-depth: 1 | ||
# Setup .npmrc file to publish to Github packages | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 14 | ||
registry-url: https://npm.pkg.github.com/ | ||
- run: npm ci | ||
- run: npm run build | ||
- run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,24 @@ | ||
'use strict'; | ||
import g from './_globals'; | ||
"use strict"; | ||
import * as chai from 'chai'; | ||
import { getStats } from '../lib/index'; | ||
|
||
describe('/api/getstats', async () => { | ||
it('Returns expected info', async () => { | ||
import { getStats } from '../lib'; | ||
import g from './_globals'; | ||
|
||
describe("/api/getstats", async () => { | ||
it("Returns expected info", async () => { | ||
const response = await getStats(g.getTestServer()); | ||
chai.expect(response.players).to.be.a('number'); | ||
chai.expect(response.animals).to.be.a('number'); | ||
chai.expect(response.hostiles).to.be.a('number'); | ||
chai.expect(response.gametime.days).to.be.a('number'); | ||
chai.expect(response.gametime.hours).to.be.a('number'); | ||
chai.expect(response.gametime.minutes).to.be.a('number'); | ||
chai.expect(response.players).to.be.a("number"); | ||
chai.expect(response.animals).to.be.a("number"); | ||
chai.expect(response.hostiles).to.be.a("number"); | ||
chai.expect(response.gametime.days).to.be.a("number"); | ||
chai.expect(response.gametime.hours).to.be.a("number"); | ||
chai.expect(response.gametime.minutes).to.be.a("number"); | ||
}); | ||
|
||
it('Accepts extra options', async () => { | ||
xit("Accepts extra options", async () => { | ||
// If 7d2d server runs on same machine as you are running tests, this 1 ms timeout is sometimes not enough. | ||
await chai.expect(getStats(g.getTestServer(), { timeout: 1 })).to.be.rejectedWith(Error); | ||
await chai | ||
.expect(getStats(g.getTestServer(), { timeout: 1 })) | ||
.to.be.rejectedWith(Error); | ||
}); | ||
}); | ||
}); |