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

Setup CI #8

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Node.js CI

on:
push:
branches:
- main
pull_request:

jobs:

test:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [ 16, 14, 12, 10 ]

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run tests-only
Copy link
Member

Choose a reason for hiding this comment

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

IMO, a lint failure is a test failure. Is there a reason not to also fail on lint errors and so just run npm t in all of them? I have in the past seen the lint configuration fail in a certain version of node, and if that is the case I think we would want to know.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't really have strong opinion here, from my side both variants are OK, so if you'd like to remove separate lint job and run lint on every node version, please let me know.

Copy link
Member

Choose a reason for hiding this comment

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

It keeps it simple, but I would be interested in hearing others opinions on the topic. Lets not consider this a blocker, and if no one shares an opinion we can merge and revisit later.


lint:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [ 16 ]

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run lint
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![NPM Version](https://img.shields.io/npm/v/create-pkg.svg)](https://npmjs.org/package/create-pkg)
[![NPM Downloads](https://img.shields.io/npm/dm/create-pkg.svg)](https://npmjs.org/package/create-pkg)
[![test](https://github.com/pkgjs/create/workflows/Test/badge.svg)](https://github.com/pkgjs/create/actions?query=workflow%3ATest)
[![test](https://github.com/pkgjs/create/workflows/Node.js%20CI/badge.svg)](https://github.com/pkgjs/create/actions?query=workflow%3A%22Node.js+CI%22)
rodion-arr marked this conversation as resolved.
Show resolved Hide resolved
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/standard/standard)

## Usage
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
"create-package": "bin/create-package"
},
"scripts": {
"test": "standard && mocha --timeout=60000",
"lint": "standard",
"pretest": "npm run lint",
"test": "npm run tests-only",
"tests-only": "mocha --timeout=60000",
"test:debug": "mocha --inspect --inspect-brk --timeout=0",
"release": "npm t && standard-version && npm publish",
"postpublish": "git push origin && git push origin --tags"
Expand All @@ -33,6 +36,7 @@
"create-git": "^1.0.0-2",
"create-package-json": "^1.0.0-2",
"loggerr": "^3.0.0-3",
"object.fromentries": "^2.0.3",
"opta": "0.0.6",
"semver": "^7.3.2"
},
Expand Down
7 changes: 5 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { suite, test, before } = require('mocha')
const pkg = require('../package.json')
const fixtures = require('fs-test-fixtures')
const createPackage = require('..')
const fromEntries = require('object.fromentries')

const barePrompt = {
promptor: () => async (prompts) => {
Expand All @@ -17,7 +18,8 @@ const barePrompt = {
}
return [p.name, ret]
}))
return Object.fromEntries(out)

return fromEntries(out)
}
}

Expand All @@ -33,7 +35,8 @@ suite(pkg.name, () => {
cwd: fix.TMP,
push: false,
silent: true,
githubRepo: '__tmp'
githubRepo: '__tmp',
author: 'Unit test'
}, barePrompt)
})
})