Skip to content

Commit

Permalink
Merge b940adb into a8aa5d7
Browse files Browse the repository at this point in the history
  • Loading branch information
niekcandaele committed Sep 9, 2020
2 parents a8aa5d7 + b940adb commit 8e2138c
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 14 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/CI.yml
@@ -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/
56 changes: 56 additions & 0 deletions .github/workflows/release.yml
@@ -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 }}
31 changes: 17 additions & 14 deletions test/getStats.test.ts
@@ -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);
});
});
});

0 comments on commit 8e2138c

Please sign in to comment.