Skip to content

Commit

Permalink
Test as dependency on github
Browse files Browse the repository at this point in the history
  • Loading branch information
cinderblock committed Dec 28, 2019
1 parent 2bd3d2a commit 657e47b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
36 changes: 34 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
@@ -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 =>
Expand Down

0 comments on commit 657e47b

Please sign in to comment.