From 68f9c018866a6ad04254eafdc15d86b748077174 Mon Sep 17 00:00:00 2001 From: Tom <25043847+Douile@users.noreply.github.com> Date: Sun, 14 Jan 2024 21:17:11 +0000 Subject: [PATCH] feat: Add ID tests to CI (#456) * tools: Add script to run ID tests * ci: Add game ID tests * tools/id-tests: Import games directly from file * ci/id: Update ID tests to official repo * ci/id: Cache rust deps even if tests fail * Add newlines --- .github/workflows/id-tests.yml | 36 ++++++++++++++++++++++++++++++++++ tools/run-id-tests.js | 18 +++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 .github/workflows/id-tests.yml create mode 100644 tools/run-id-tests.js diff --git a/.github/workflows/id-tests.yml b/.github/workflows/id-tests.yml new file mode 100644 index 0000000..41f0c4d --- /dev/null +++ b/.github/workflows/id-tests.yml @@ -0,0 +1,36 @@ +name: ID tests + +on: + push: + paths: + - "lib/games.js" + - ".github/workflows/id-tests.yml" # This action + pull_request: + paths: + - "lib/games.js" + - ".github/workflows/id-tests.yml" # This action + workflow_dispatch: + +jobs: + test: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Use Node + uses: actions/setup-node@v3 + with: + node-version: 18.x + + - name: Cache rust dependencies + uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: 'true' + + - name: Install ID tester + run: cargo install --git https://github.com/gamedig/rust-gamedig.git gamedig-id-tests + + - name: Run ID tests + run: node tools/run-id-tests.js diff --git a/tools/run-id-tests.js b/tools/run-id-tests.js new file mode 100644 index 0000000..2504e2e --- /dev/null +++ b/tools/run-id-tests.js @@ -0,0 +1,18 @@ +import { spawnSync } from 'node:child_process'; +import process from 'node:process'; + +// Import directly from file so that this script works without dependencies installed. +import { games } from './../lib/games.js'; + +const ID_TEST_BIN = process.env["GAMEDIG_ID_TESTER"] || "gamedig-id-tests"; + +const result = spawnSync(ID_TEST_BIN, { + input: JSON.stringify(games), + stdio: ['pipe', 'inherit', 'inherit'], +}); + +if (result.error) { + throw result.error; +} + +process.exit(result.status);