Skip to content

Commit

Permalink
Merge branch 'main' into lookup-babel
Browse files Browse the repository at this point in the history
  • Loading branch information
targos authored Mar 16, 2021
2 parents 424c0e3 + d170bd6 commit 215174c
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 29 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ jobs:
run: npm run lint

test:
name: Test on Node.js ${{ matrix.node-version }} and ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
Expand All @@ -41,6 +39,7 @@ jobs:
- 10.x
- 12.x
- 14.x
- 15.x

runs-on: ${{ matrix.os }}

Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/test-module.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Test a module with CITGM

on:
workflow_dispatch:
inputs:
module:
description: 'Module to test'
required: true
repository:
description: 'CITGM repository to checkout'
required: true
default: nodejs/citgm
ref:
description: 'CITGM GitHub ref to checkout'
required: true
default: main

jobs:
show-parameters:
name: Parameters for testing "${{ github.event.inputs.module }}"

runs-on: ubuntu-latest

steps:
- name: Log workflow parameters
env:
WORKFLOW_PARAMETERS: ${{ toJSON(github.event.inputs) }}
run: echo "$WORKFLOW_PARAMETERS"

test-module:
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
node-version:
- 10.x
- 12.x
- 14.x
- 15.x

runs-on: ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
repository: ${{ github.event.inputs.repository }}
ref: ${{ github.event.inputs.ref }}

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Install packages
run: npm install

- name: Run CITGM
run: node bin/citgm.js ${{ github.event.inputs.module }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ For syntax, see [lookup.json](./lib/lookup.json), the available attributes are:

```
"npm": true Download the module from npm instead of github
"master": true Use the master branch
"head": true Use the head of the default branch
"prefix": "v" Specify the prefix used in the module version.
"flaky": true Ignore failures
"skip": true Completely skip the module
Expand Down
4 changes: 3 additions & 1 deletion lib/grab-project.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ async function grabProject(context) {
}

return new Promise((resolve, reject) => {
const packageManager =
context.options.yarn || context.module.useYarn ? 'yarn' : 'npm';
let packageName = context.module.raw;
if (context.module.type === 'directory') {
context.module.raw = context.module.name = path.basename(packageName);
Expand All @@ -21,7 +23,7 @@ async function grabProject(context) {
context.emit(
'data',
'info',
`${context.module.name} npm:`,
`${context.module.name} ${packageManager}:`,
`Downloading project: ${packageName}`
);
let options = createOptions(context.path, context);
Expand Down
34 changes: 27 additions & 7 deletions lib/lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function makeUrl(repo, spec, tags, prefix, sha) {
let version;
if (!spec)
// Spec should already have defaulted to latest.
version = 'master';
version = 'HEAD';
else if (tags[spec]) version = tags[spec];
// Matches npm tags like 'latest' or 'next'.
// `spec` must match one of `meta.versions` as npm info call passed.
Expand All @@ -30,7 +30,7 @@ function makeUrl(repo, spec, tags, prefix, sha) {

function makeClone(repo, spec, tags, prefix) {
let version;
if (!spec) version = 'master';
if (!spec) version = 'HEAD';
else version = (prefix || '') + tags[spec];
return {
url: `${repo}.git`,
Expand All @@ -56,7 +56,27 @@ function getLookupTable(options) {
if (typeof options.lookup === 'string') {
name = path.resolve(process.cwd(), options.lookup);
}
return require(name);
const lookup = require(name);

// Backwards-compatibility: replace "master" key with "head".
let warningEmitted = false;
for (const moduleName of Object.keys(lookup)) {
const moduleConfig = lookup[moduleName];
if (moduleConfig.master !== undefined) {
if (!warningEmitted) {
process.emitWarning(
'The "master" key in lookup entries is deprecated. Use "head" instead. ' +
`Found in "${name}" for module "${moduleName}".`,
'DeprecationWarning'
);
warningEmitted = true;
}
moduleConfig.head = moduleConfig.master;
delete moduleConfig.master;
}
}

return lookup;
} catch (err) {
return undefined;
}
Expand Down Expand Up @@ -107,7 +127,7 @@ function resolve(context) {
if (rep.useGitClone) {
const { url, ref } = makeClone(
getRepo(rep.repo, meta),
rep.master ? null : detail.fetchSpec,
rep.head ? null : detail.fetchSpec,
meta['dist-tags'],
rep.prefix
);
Expand All @@ -121,12 +141,12 @@ function resolve(context) {
context.module.raw = url;
context.module.ref = ref;
} else {
const gitHead = rep.master || rep.ignoreGitHead ? null : meta.gitHead;
const gitHead = rep.head || rep.ignoreGitHead ? null : meta.gitHead;
const url = makeUrl(
getRepo(rep.repo, meta),
rep.master ? null : detail.fetchSpec,
rep.head ? null : detail.fetchSpec,
meta['dist-tags'],
rep.master ? null : rep.prefix,
rep.head ? null : rep.prefix,
context.options.sha || rep.sha || gitHead
);
context.emit(
Expand Down
41 changes: 28 additions & 13 deletions lib/lookup.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
"scripts": ["build", "test"],
"skip": ["10.x", "win32", "aix", "s390"]
},
"@hapi/hapi": {
"prefix": "v",
"maintainers": ["devinivy", "DavidTPate", "AdriVanHoudt"],
"skip": ["10", "osx", "aix"]
},
"@hapi/shot": {
"maintainers": "cjihrig",
"prefix": "v"
Expand Down Expand Up @@ -91,7 +96,7 @@
},
"cheerio": {
"skip": "win32",
"master": true,
"head": true,
"maintainers": ["matthewmueller", "jugglinmike"]
},
"clinic": {
Expand Down Expand Up @@ -143,7 +148,7 @@
"envVar": { "YARN_IGNORE_ENGINES": "true" },
"prefix": "v",
"flaky": ["win32", "rhel", "sles"],
"master": true,
"head": true,
"expectFail": "fips",
"maintainers": ["stefanpenner", "rwjblue", "Turbo87", "kellyselden"]
},
Expand All @@ -160,12 +165,6 @@
"maintainers": ["nzakas", "mysticatea", "not-an-aardvark"],
"comment": "Skipped because libX11 is required for headless Chrome"
},
"eslint-plugin-jest": {
"prefix": "v",
"maintainers": "SimenB",
"yarn": true,
"skip": ["aix", "s390x"]
},
"esprima": {
"maintainers": "ariya",
"expectFail": "fips",
Expand Down Expand Up @@ -257,6 +256,15 @@
"prefix": "v",
"maintainers": "juliangruber"
},
"jest": {
"prefix": "v",
"maintainers": ["cpojer", "scotthovestadt", "SimenB", "thymikee", "jeysal"],
"yarn": true,
"scripts": ["build:js", "test-ci-partial"],
"envVar": { "CI": true },
"skip": ["aix", "s390x", "ppc", "10.x", "darwin", "win32"],
"timeout": 1800000
},
"jquery": {
"skip": "win32",
"flaky": ["linux", "aix", "darwin"],
Expand Down Expand Up @@ -304,7 +312,7 @@
"maintainers": "substack"
},
"mkdirp": {
"master": true,
"head": true,
"skip": true,
"maintainers": "substack"
},
Expand Down Expand Up @@ -349,6 +357,11 @@
"comment": "Flaky because of test timeouts",
"skip": true
},
"npm": {
"maintainers": ["nodejs/npm"],
"prefix": "v",
"skip": "s390"
},
"path-to-regexp": {
"prefix": "v",
"maintainers": "blakeembrey",
Expand Down Expand Up @@ -446,7 +459,7 @@
},
"socket.io": {
"maintainers": "rauchg",
"master": true
"head": true
},
"spawn-wrap": {
"prefix": "v",
Expand All @@ -469,7 +482,7 @@
"split2": {
"prefix": "v",
"maintainers": "mcollina",
"master": true
"head": true
},
"sqlite3": {
"prefix": "v",
Expand Down Expand Up @@ -526,6 +539,7 @@
"maintainers": "jashkenas"
},
"undici": {
"prefix": "v",
"maintainers": ["mcollina", "ronag"]
},
"uuid": {
Expand All @@ -540,7 +554,7 @@
},
"vinyl-fs": {
"prefix": "v",
"master": true,
"head": true,
"maintainers": ["contra", "phated"],
"skip": true
},
Expand Down Expand Up @@ -573,7 +587,8 @@
"prefix": "v",
"flaky": ["ppc", "rhel"],
"expectFail": "fips",
"maintainers": ["SBoudrias", "sindresorhus"]
"maintainers": ["SBoudrias", "sindresorhus"],
"skip": "10.x"
},
"zeromq": {
"prefix": "v",
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/custom-lookup-log.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"omg-i-pass": {
"install": ["--extra-param"],
"master": true,
"head": true,
"replace": true,
"repo": "https://github.com/nodejs/citgm"
}
Expand Down
8 changes: 4 additions & 4 deletions test/test-lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ test('lookup: makeUrl', (t) => {

const sha = 'abc123';

let expected = `${repo}/archive/master.tar.gz`;
let expected = `${repo}/archive/HEAD.tar.gz`;
let url = makeUrl(repo);
t.equal(url, expected, 'by default makeUrl should give a link to master');
t.equal(url, expected, 'by default makeUrl should give a link to HEAD');

expected = `${repo}/archive/${tags.latest}.tar.gz`;
url = makeUrl(repo, 'latest', tags);
Expand Down Expand Up @@ -171,7 +171,7 @@ test('lookup: module in table', (t) => {
lookup(context);
t.equals(
context.module.raw,
'https://github.com/lodash/lodash/archive/master.tar.gz',
'https://github.com/lodash/lodash/archive/HEAD.tar.gz',
'raw should be truthy if the module was in the list'
);
t.end();
Expand Down Expand Up @@ -404,7 +404,7 @@ test('lookup: logging', (t) => {
{
type: 'info',
key: 'omg-i-pass lookup-replace',
msg: 'https://github.com/nodejs/citgm/archive/master.tar.gz'
msg: 'https://github.com/nodejs/citgm/archive/HEAD.tar.gz'
},
{
type: 'verbose',
Expand Down

0 comments on commit 215174c

Please sign in to comment.