From 657e47bdac235b937e7cc065bcf3e72f505569ac Mon Sep 17 00:00:00 2001 From: Cameron Tacklind Date: Sat, 28 Dec 2019 02:28:56 -0800 Subject: [PATCH] Test as dependency on github --- .github/workflows/main.yml | 36 ++++++++++++++++++++++++++++++++++-- test/index.js | 4 +++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 68351d3..49cbce4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,10 +40,42 @@ jobs: # Mocha does not work on 4/5 if: matrix.node >= 6 + install-from-git: + name: Install from Github Test + + runs-on: ubuntu-latest + + steps: + - name: Checkout latest code + uses: actions/checkout@v1 + + - name: Install Node dependencies + run: npm install + + # Prepare Test Environment + + - name: Create Dummy Package.json + run: echo \{\} > test/package.json + + - name: Install Current Version as Git Dependency + working-directory: test + run: npm install ${{ github.repository }}#${{ github.sha }} + + - name: "Debug: List Dependency Folder Contents" + working-directory: test + run: find node_modules/userid -type f -print + + # Ensure the code works + + - name: Run Tests with Prepared Git Dependency + run: npm test + env: + MOCHA_IMPORT_OVERRIDE: userid + coverage: name: Test Coverage runs-on: ubuntu-latest - needs: [test-matrix] + needs: [test-matrix, install-from-git] steps: - name: Checkout latest code @@ -100,7 +132,7 @@ jobs: name: Publish Master if: github.event_name == 'push' && github.ref == 'refs/heads/master' runs-on: ubuntu-latest - needs: [coverage, test-matrix] + needs: [coverage, test-matrix, install-from-git] steps: - name: Checkout latest code diff --git a/test/index.js b/test/index.js index d3d31d0..f09a1dc 100644 --- a/test/index.js +++ b/test/index.js @@ -1,7 +1,9 @@ require("should"); -const userid = require("../lib/userid.js"); + const execSync = require("child_process").execSync; +const userid = require(process.env.MOCHA_IMPORT_OVERRIDE || "../lib/userid.js"); + // Utility functions const execToString = command =>