Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: run on GitHub Actions #251

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: test

on:
pull_request:
push:
branches:
- master

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dcodeIO/setup-node-nvm@v5
with:
node-version: iojs
- run: npm install
- run: npm test
env:
Comment on lines +13 to +19
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i ended up wrapping dcodeIO's action in ljharb/actions/node/install, which I use on 400 projects for node versions ranging from 0.4 to latest. I also have ljharb/actions/node/matrix to easily and dynamically create a matrix. You can also use ljharb/actions/.github/workflows/node.yml to encapsulate all of this in a single swoop.

# Node.js/io.js bundle their own CA store, which is now substantially out of date. io.js predated the `--use-openssl-ca` flag, so we have to disable TLS verification entirely.
# Upon upgrading this test suite to a modern Node.js version, this should be removed.
NODE_TLS_REJECT_UNAUTHORIZED: '0'
3 changes: 0 additions & 3 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# browserify-shim [![build status](https://secure.travis-ci.org/thlorenz/browserify-shim.svg?branch=master)](http://travis-ci.org/thlorenz/browserify-shim)
# browserify-shim

### Make CommonJS-Incompatible Files Browserifyable

Expand Down
2 changes: 1 addition & 1 deletion test/bundle-deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function bundleNcheck(relPath, t) {
browserify( { ignoreGlobals: true })
.require(require.resolve(relPath))
.bundle(function (err, src) {
if (err) { t.fail(err); return t.end(); }
if (err) { t.fail(err.message); return t.end(); }

var ctx = { window: {}, console: console };
ctx.self = ctx.window;
Expand Down
2 changes: 1 addition & 1 deletion test/bundle-ember-bower.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function bundleNcheck(relPath, t) {
browserify( { ignoreGlobals: true })
.require(require.resolve(relPath))
.bundle(function (err, src) {
if (err) { t.fail(err); return t.end(); }
if (err) { t.fail(err.message); return t.end(); }

var ctx = { window: {}, console: console };
ctx.self = ctx.window;
Expand Down
2 changes: 1 addition & 1 deletion test/bundle-expose-globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function bundleNcheck(relPath, t) {
browserify( { ignoreGlobals: true })
.require(require.resolve(relPath))
.bundle(function (err, src) {
if (err) { t.fail(err); return t.end(); }
if (err) { t.fail(err.message); return t.end(); }

var ctx = { window: { $: jquery }, console: console };
ctx.self = ctx.window;
Expand Down
2 changes: 1 addition & 1 deletion test/bundle-invalid-require.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function bundleNcheck(relPath, t) {
browserify( { ignoreGlobals: true })
.require(require.resolve(relPath))
.bundle(function (err, src) {
if (err) { t.fail(err); return t.end(); }
if (err) { t.fail(err.message); return t.end(); }

var ctx = { window: {}, console: console };
ctx.self = ctx.window;
Expand Down
2 changes: 1 addition & 1 deletion test/bundle-multideps.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function bundleNcheck(relPath, t) {
browserify( { ignoreGlobals: true })
.require(require.resolve(relPath))
.bundle(function (err, src) {
if (err) { t.fail(err); return t.end(); }
if (err) { t.fail(err.message); return t.end(); }

var ctx = { window: {}, console: console };
ctx.self = ctx.window;
Expand Down
2 changes: 1 addition & 1 deletion test/bundle-nodeps.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function bundleNcheck(relPath, t) {
browserify( { ignoreGlobals: true })
.require(require.resolve(relPath))
.bundle(function (err, src) {
if (err) { t.fail(err); return t.end(); }
if (err) { t.fail(err.message); return t.end(); }

var ctx = { window: {}, console: console };
ctx.self = ctx.window;
Expand Down
2 changes: 1 addition & 1 deletion test/bundle-pack-bower.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function bundleNcheck(relPath, t) {
browserify( { ignoreGlobals: true })
.require(require.resolve(relPath))
.bundle(function (err, src) {
if (err) { t.fail(err); return t.end(); }
if (err) { t.fail(err.message); return t.end(); }

var ctx = { window: {}, console: console };
ctx.self = ctx.window;
Expand Down
2 changes: 1 addition & 1 deletion test/bundle-packs.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function bundleNcheck(relPath, t) {
browserify( { ignoreGlobals: true })
.require(require.resolve(relPath))
.bundle(function (err, src) {
if (err) { t.fail(err); return t.end(); }
if (err) { t.fail(err.message); return t.end(); }

var ctx = { window: {}, console: console };
ctx.self = ctx.window;
Expand Down
2 changes: 1 addition & 1 deletion test/resolve-shims-bower.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function inspect(obj, depth) {
test('\nresolving a bower component that is shimmed', function (t) {
resolve(require.resolve('./bower/components/jquery-ui/ui/jquery.ui.position.js'), msgs, function (err, res) {

if (err) { t.fail(err); return t.end(); }
if (err) { t.fail(err.message); return t.end(); }
t.deepEqual(res.shim, { exports: null, depends: { jquery: 'jQuery' } }, 'resolves shim correctly')
t.end();
})
Expand Down
20 changes: 10 additions & 10 deletions test/resolve-shims.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,39 @@ function inspect(obj, depth) {

test('\nno dependencies, external shim file, no expose', function (t) {
resolve(require.resolve('./nodeps/extshim/vendor/non-cjs'), msgs, function (err, res) {
if (err) { t.fail(err); return t.end(); }
if (err) { t.fail(err.message); return t.end(); }
t.deepEqual(res.shim, { exports: 'noncjs', depends: undefined }, 'resolves noncjs shim correctly')
t.end();
});
})

test('\nno dependencies, external shim, exposed as non-cjs', function (t) {
resolve(require.resolve('./nodeps/extshim-exposed/vendor/non-cjs'), msgs, function (err, res) {
if (err) { t.fail(err); return t.end(); }
if (err) { t.fail(err.message); return t.end(); }
t.deepEqual(res.shim, { exports: 'noncjs', depends: undefined }, 'resolves noncjs shim correctly')
t.end();
});
})

test('\nno dependencies, inline shims, no expose', function (t) {
resolve(require.resolve('./nodeps/inlineshim/vendor/non-cjs'), msgs, function (err, res) {
if (err) { t.fail(err); return t.end(); }
if (err) { t.fail(err.message); return t.end(); }
t.deepEqual(res.shim, { exports: 'noncjs', depends: undefined }, 'resolves noncjs shim correctly')
t.end();
});
})

test('\nno dependencies, inline shims, exposed as non-cjs', function (t) {
resolve(require.resolve('./nodeps/inlineshim-exposed/vendor/non-cjs'), msgs, function (err, res) {
if (err) { t.fail(err); return t.end(); }
if (err) { t.fail(err.message); return t.end(); }
t.deepEqual(res.shim, { exports: 'noncjs', depends: undefined }, 'resolves noncjs shim correctly')
t.end();
});
})

test('\nnon-cjs-dep depends on non-cjs, external shim file, all exposed', function (t) {
resolve(require.resolve('./deps/extshim/vendor/non-cjs-dep'), msgs, function (err, res) {
if (err) { t.fail(err); return t.end(); }
if (err) { t.fail(err.message); return t.end(); }
t.deepEqual(res.shim
, { exports: 'noncjsdep', depends: { 'non-cjs': 'noncjs' } }
, 'resolves noncjsdep shim correctly'
Expand All @@ -57,7 +57,7 @@ test('\nnon-cjs-dep depends on non-cjs, external shim file, all exposed', functi

test('\nnon-cjs-dep depends on non-cjs, inline shims, all exposed', function (t) {
resolve(require.resolve('./deps/inlineshim/vendor/non-cjs-dep'), msgs, function (err, res) {
if (err) { t.fail(err); return t.end(); }
if (err) { t.fail(err.message); return t.end(); }
t.deepEqual(res.shim
, { exports: 'noncjsdep', depends: { 'non-cjs': 'noncjs' } }
, 'resolves noncjsdep shim correctly'
Expand All @@ -68,7 +68,7 @@ test('\nnon-cjs-dep depends on non-cjs, inline shims, all exposed', function (t)

test('\nnon-cjs-dep depends on non-cjs and non-cjs-core, external shim file, all exposed except non-cjs-core', function (t) {
resolve(require.resolve('./multideps/extshim/vendor/non-cjs-dep'), msgs, function (err, res) {
if (err) { t.fail(err); return t.end(); }
if (err) { t.fail(err.message); return t.end(); }
var corePath = path.join(__dirname, 'multideps/extshim/vendor/non-cjs-core.js');
var depends = { 'non-cjs': 'noncjs' }
depends[corePath] = 'core';
Expand All @@ -83,7 +83,7 @@ test('\nnon-cjs-dep depends on non-cjs and non-cjs-core, external shim file, all

test('\nnon-cjs-dep depends on non-cjs and non-cjs-core, inline shims, all exposed except non-cjs-core', function (t) {
resolve(require.resolve('./multideps/inlineshim/vendor/non-cjs-dep'), msgs, function (err, res) {
if (err) { t.fail(err); return t.end(); }
if (err) { t.fail(err.message); return t.end(); }
var corePath = path.join(__dirname, 'multideps/inlineshim/vendor/non-cjs-core.js');
var depends = { 'non-cjs': 'noncjs' }
depends[corePath] = 'core';
Expand All @@ -98,7 +98,7 @@ test('\nnon-cjs-dep depends on non-cjs and non-cjs-core, inline shims, all expos

test('\nno dependencies, inline shims, no expose, $ exposified as jquery', function (t) {
resolve(require.resolve('./exposify/inlineshim/vendor/non-cjs'), msgs, function (err, res) {
if (err) { t.fail(err); return t.end(); }
if (err) { t.fail(err.message); return t.end(); }
t.deepEqual(res.shim, { exports: 'noncjs', depends: undefined }, 'resolves noncjs shim correctly')
t.deepEqual(res.exposeGlobals, { jquery: '$' }, 'resolves expose globals correctly')
t.end();
Expand All @@ -107,7 +107,7 @@ test('\nno dependencies, inline shims, no expose, $ exposified as jquery', funct

test('\nno dependencies, external shims, no expose, $ exposified as jquery', function (t) {
resolve(require.resolve('./exposify/extshim/vendor/non-cjs'), msgs, function (err, res) {
if (err) { t.fail(err); return t.end(); }
if (err) { t.fail(err.message); return t.end(); }
t.deepEqual(res.shim, { exports: 'noncjs', depends: undefined }, 'resolves noncjs shim correctly')
t.deepEqual(res.exposeGlobals, { jquery: '$' }, 'resolves expose globals correctly')
t.end();
Expand Down
8 changes: 4 additions & 4 deletions test/shim/shim-depends.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ test('\nwhen I shim "jquery" and shim a lib that depends on it', function (t) {
var entry = require.resolve('./fixtures/entry-requires-depend-on-jquery');

runFirstBundle(entry, false, function (err, require_) {
if (err) { t.fail(err); return t.end(); }
if (err) { t.fail(err.message); return t.end(); }

var dep = require_(1);
t.equal(dep.jqVersion, '1.8.3', 'when dependent gets required, $ is attached to the window');
Expand All @@ -79,7 +79,7 @@ test('\nwhen I shim "jquery" and shim a lib that depends on it, using fullPaths'
var entry = require.resolve('./fixtures/entry-requires-depend-on-jquery');

runFirstBundle(entry, true, function (err, require_) {
if (err) { t.fail(err); return t.end(); }
if (err) { t.fail(err.message); return t.end(); }

var dep = require_(entry);
t.equal(dep.jqVersion, '1.8.3', 'when dependent gets required, $ is attached to the window');
Expand Down Expand Up @@ -117,7 +117,7 @@ test('\nwhen I shim "jquery" and _ lib in debug mode and shim a lib that depends

var entry = require.resolve('./fixtures/entry-requires-depend-on-jquery-and-_');
runSecondBundle(entry, false, function (err, require_) {
if (err) { t.fail(err); return t.end(); }
if (err) { t.fail(err.message); return t.end(); }

var dep = require_(1);

Expand All @@ -132,7 +132,7 @@ test('\nwhen I shim "jquery" and _ lib in debug mode and shim a lib that depends

var entry = require.resolve('./fixtures/entry-requires-depend-on-jquery-and-_');
runSecondBundle(entry, true, function (err, require_) {
if (err) { t.fail(err); return t.end(); }
if (err) { t.fail(err.message); return t.end(); }

var dep = require_(entry);

Expand Down