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

ci: move to travis #324

Merged
merged 22 commits into from
Feb 12, 2019
Merged
Show file tree
Hide file tree
Changes from 21 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
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* text=auto
test/fixtures/** text eol=lf
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ node_modules
/docs
.nyc_output
*.log
.vscode
40 changes: 40 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
language: node_js
cache: npm
stages:
- check
- test
- cov

node_js:
- '10'

os:
- linux
- osx
- windows

script: npx nyc -s npm run test:node -- --bail
after_success: npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov

jobs:
include:
- stage: check
script:
- node cli.js commitlint --travis
- node cli.js dep-check -- -i aegir
- npm run lint

- stage: test
name: chrome
addons:
chrome: stable
script: npm run test:browser

- stage: test
name: firefox
addons:
firefox: latest
script: npm run test:browser -- -- --browsers FirefoxHeadless

notifications:
email: false
111 changes: 84 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# AEgir

[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) [![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) [![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
[![Travis CI](https://flat.badgen.net/travis/ipfs/aegir)](https://travis-ci.com/ipfs/aegir)
[![Dependency Status](https://david-dm.org/ipfs/aegir.svg?style=flat-square)](https://david-dm.org/ipfs/aegir)

> Automated JavaScript project management.
Expand All @@ -9,19 +10,6 @@

[Hugo Dias](https://github.com/hugomrdias)

[![Throughput Graph](https://graphs.waffle.io/ipfs/aegir/throughput.svg)](https://waffle.io/ipfs/aegir/metrics/throughput)

## Table of Contents

[Soon™](http://0.media.dorkly.cvcdn.com/11/66/90a5442391c143173baf1fd82e5b2449-10-gifs-of-soon-moments-in-games.jpg)

## Scoped Github Token

Performing a release involves creating new commits and tags and then pushing them back to the repository you are releasing from. In order to do this you should create a [GitHub personal access token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/) and store it in the environmental variable `AEGIR_GHTOKEN`.

The only access scope it needs is `public_repo`.

Be aware that by storing it in `~/.profile` or similar you will make it available to any program that runs on your computer.

## Project Structure

Expand All @@ -48,11 +36,69 @@ Your `package.json` should have the following entries and should pass `aegir lin
"build": "aegir build",
"test": "aegir test",
"test:node": "aegir test --target node",
"test:browser": "aegir test --target browser",
"coverage": "aegir coverage",
"coverage-publish": "aegir coverage --upload"
"test:browser": "aegir test --target browser"
}
```
## Add CI to your repo
### Fix line endings in Windows
Create a .gitattributes file with the following content:
```
* text=auto
test/fixtures/** text eol=lf
# add more like the line above as needed
```
You will probably only need this if in your tests you compare file contents or file CIDs.

Create a file named .travis.yml with the following content:

```yaml
language: node_js
cache: npm
stages:
- check
- test
- cov

node_js:
- '10'

os:
- linux
- osx
- windows

script: npx nyc -s npm run test:node -- --bail
after_success: npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov

jobs:
include:
- stage: check
script:
- npx aegir commitlint --travis
- npx aegir dep-check
- npm run lint

- stage: test
name: chrome
addons:
chrome: stable
script: npx aegir test -t browser

- stage: test
name: firefox
addons:
firefox: latest
script: npx aegir test -t browser -- --browsers FirefoxHeadless

notifications:
email: false

```
To add a CI badge to your README use :

```yaml
[![Travis CI](https://flat.badgen.net/travis/ipfs/aegir)](https://travis-ci.com/ipfs/aegir)
```

## Stack Requirements

Expand Down Expand Up @@ -144,34 +190,37 @@ module.exports = {

### Coverage

You can run it using
#### Node
You can run your tests with `nyc` using

```bash
$ aegir coverage
$ npx nyc -s aegir test -t node
```
#### Browser
> Not available yet PR open.


To auto publish coverage reports from Travis to Codecov add this to
your `.travis.yml` file.

```yml
script:
- npm run coverage -- -upload
after_success: npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov
```

### Building

This will build a browser ready version into `dist`, so after publishing the results will be available under

```
https://unpkg.com/<module-name>/dist/index.js
https://unpkg.com/<module-name>/dist/index.min.js
```

You can run it using

```bash
$ aegir build
```
This will build a browser ready version into `dist`, so after publishing the results will be available under

```
https://unpkg.com/<module-name>/dist/index.js
https://unpkg.com/<module-name>/dist/index.min.js
```

**Specifying a custom entry file for Webpack**

Expand Down Expand Up @@ -239,9 +288,17 @@ in `--no-changelog`.

If you want no documentation generation you can pass `--no-docs` to the release task to disable documentation builds.

#### Scoped Github Token

Performing a release involves creating new commits and tags and then pushing them back to the repository you are releasing from. In order to do this you should create a [GitHub personal access token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/) and store it in the environmental variable `AEGIR_GHTOKEN`.

The only access scope it needs is `public_repo`.

Be aware that by storing it in `~/.profile` or similar you will make it available to any program that runs on your computer.

### Documentation

You can use `aegir-docs` to generate documentation. This uses [documentation.js](http://documentation.js.org/) with the theme [clean-documentation-theme](https://github.com/dignifiedquire/clean-documentation-theme).
You can use `aegir docs` to generate documentation. This uses [documentation.js](http://documentation.js.org/) with the theme [clean-documentation-theme](https://github.com/dignifiedquire/clean-documentation-theme).

To publish the documentation automatically to the `gh-pages` branch you can run

Expand Down
2 changes: 0 additions & 2 deletions ci/Jenkinsfile

This file was deleted.

56 changes: 40 additions & 16 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,49 @@ updateNotifier({
isGlobal: false
}).notify()

require('yargs') // eslint-disable-line
.env('AEGIR')
const cli = require('yargs')
cli.env('AEGIR')
.usage('Usage: $0 <command> [options]')
.example('$0 build', 'Runs the build command to bundle JS code for the browser.')
.example('npx $0 build', 'Can be used with `npx` to use a local version')
.example('$0 test -t webworker -- --browsers Firefox', 'If the command supports `--` can be used to forward options to the underlying tool.')
.example('npm test -- -- --browsers Firefox', 'If `npm test` translates to `aegir test -t browser` and you want to forward options you need to use `-- --` instead.')
.epilog('Use `$0 <command> --help` to learn more about each command.')
.commandDir('cmds')
.demandCommand()
.demandCommand(1, 'You need at least one command.')
.option('d', {
desc: 'Show debug output.',
type: 'boolean',
default: false,
alias: 'debug'
})
.help()
.fail((msg, err, yargs) => {
// errors from execa output the child_process stderr
if (err && err.stderr) {
console.error('Error running command: ', err.cmd, '\n')
console.error(err.stderr)
} else {
if (msg) {
console.error(chalk.red(msg))
}
if (err) {
console.error(chalk.red(err.message))
.alias('h', 'help')
.alias('v', 'version')
.group(['help', 'version', 'debug'], 'Global Options:')
.wrap(cli.terminalWidth())
// .strict() // this doesnt allow for cross-env AEGIR_TEST=hello node cli.js test -t node --files 'test/**/*.spec.js' "--bail"

const args = cli.fail((msg, err, yargs) => {
if (msg) {
yargs.showHelp()
console.error(chalk.red(msg))
}

if (err) {
console.error(chalk.red(err.message))

if (args.debug) {
// errors from execa output the child_process stderr
if (err && err.stderr) {
console.error('Error running command: ', err.cmd, '\n')
console.error(err.stderr)
} else {
console.error(chalk.gray(err.stack))
}
}
process.exit(1)
})
}

process.exit(1)
})
.argv
23 changes: 15 additions & 8 deletions cmds/build.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
'use strict'

const EPILOG = `
This command outputs two bundles, one in development mode (index.js) and another in production mode (index.min.js) plus respective source-maps, files are written to ./dist folder.
Supports options forwarding with '--' for more info check https://webpack.js.org/api/cli/
`
module.exports = {
command: 'build',
desc: 'Build ready to release',
builder: {
analyze: {
alias: 'a',
describe: 'Analyze mode. Opens webpack-bundle-analyzer and write stats to disk',
default: false
}
desc: 'Builds browser bundles with Webpack.',
builder: (yargs) => {
yargs
.epilog(EPILOG)
.options({
analyze: {
alias: 'a',
describe: 'Analyze mode. Opens webpack-bundle-analyzer and write stats to disk',
default: false
}
})
},
handler (argv) {
const build = require('../src/build')
Expand Down
53 changes: 0 additions & 53 deletions cmds/coverage.js

This file was deleted.

23 changes: 0 additions & 23 deletions cmds/lint-commits.js

This file was deleted.

Loading