Browse Source

Chore: Use GitHub actions (#661)

* run cypress on github action

* add lint action

* add test and coverage action

* upgrade testing dependencies

* upgrade linting dependencies

* add bundlesize action

* fix env name, prevent husky

* add npm publish step

* upgrade cypress to latest non-breaking version

* fix postversion script

* don't share full token with bundlesize

* nicer version commit

* add preversion script, use `--atomic` and don't publish tests

* enforce tagged and signed version

* restored bump-cache
pull/662/head
Konstantin Vyatkin 2 years ago
committed by Josh Johnson
parent
commit
bc8a044ab1
  1. 4
      .codecov.yml
  2. 55
      .eslintrc
  3. 38
      .github/workflows/bundlesize.yml
  4. 25
      .github/workflows/cypress.yml
  5. 28
      .github/workflows/lint.yml
  6. 86
      .github/workflows/npmpublish.yml
  7. 41
      .github/workflows/unit-tests.yml
  8. 7
      .mocharc.yml
  9. 4
      .npmrc
  10. 7878
      package-lock.json
  11. 46
      package.json

4
.codecov.yml

@ -0,0 +1,4 @@
coverage:
parsers:
javascript:
enable_partials: yes

55
.eslintrc

@ -1,27 +1,12 @@
{
"parser": "babel-eslint",
"extends": [
"airbnb",
"prettier"
],
"plugins": [
"prettier",
"cypress"
],
"parserOptions": {
"ecmaVersion": 2020
},
"extends": ["airbnb-base", "prettier"],
"plugins": ["prettier"],
"env": {
"es6": true,
"browser": true,
"node": true,
"mocha": true,
"cypress/globals": true
},
"globals": {
"describe": true,
"it": true,
"before": true,
"after": true,
"beforeEach": true,
"afterEach": true
"browser": true
},
"rules": {
"import/no-extraneous-dependencies": [
@ -33,10 +18,7 @@
"no-console": [
"warn",
{
"allow": [
"warn",
"error"
]
"allow": ["warn", "error"]
}
],
"no-plusplus": "off",
@ -49,6 +31,23 @@
"singleQuote": true,
"trailingComma": "all"
}
]
}
}
],
"import/no-useless-path-segments": "warn",
"prefer-destructuring": "warn"
},
"overrides": [
{
"files": ["*.test.js"],
"env": {
"mocha": true
}
},
{
"files": ["cypress/**/*.spec.js"],
"plugins": ["cypress"],
"env": {
"cypress/globals": true
}
}
]
}

38
.github/workflows/bundlesize.yml

@ -0,0 +1,38 @@
name: BundleSize
on:
pull_request:
paths:
- 'src/scripts/**'
- 'src/styles/**'
jobs:
measure:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- uses: actions/setup-node@v1
with:
node-version: 10
- name: Install dependencies and build
run: |
npm ci
npm run build
env:
CYPRESS_INSTALL_BINARY: 0
HUSKY_SKIP_INSTALL: true
- run: npx bundlesize
env:
CI: true
BUNDLESIZE_GITHUB_TOKEN: ${{secrets.BUNDLESIZE_GITHUB_TOKEN}}
CI_REPO_NAME: ${{ github.event.repository.name }}
CI_REPO_OWNER: ${{ github.event.organization.login }}
CI_COMMIT_SHA: ${{ github.sha }}
GIT_COMMIT: ${{ github.sha }}
CI_BRANCH: ${{ github.head_ref }}
FORCE_COLOR: 2

25
.github/workflows/cypress.yml

@ -0,0 +1,25 @@
name: Cypress
on: [pull_request]
jobs:
run-e2e:
name: integration tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- uses: actions/setup-node@v1
with:
node-version: 10
- name: Build library
run: npm ci
- name: run Cypress
run: npm run test:e2e
env:
CI: true
DEBUG: commit-info,cypress:server:record

28
.github/workflows/lint.yml

@ -0,0 +1,28 @@
name: Lint
on:
pull_request:
paths:
- 'src/scripts/**'
jobs:
eslint:
name: ESLint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- uses: actions/setup-node@v1
with:
node-version: 10
- name: Install dependencies
run: npm install --no-optional --no-audit --ignore-scripts
env:
CYPRESS_INSTALL_BINARY: 0
HUSKY_SKIP_INSTALL: true
- name: run eslint
run: npx eslint src/scripts

86
.github/workflows/npmpublish.yml

@ -0,0 +1,86 @@
name: Publish Package
on:
push:
branches:
- master
tags:
- v*
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- uses: actions/setup-node@v1
with:
node-version: 10
# run all tests
- run: |
npm ci
npm run build
npx bundlesize
npm run coverage
npm run test:e2e
env:
CI: true
CI_REPO_NAME: ${{ github.event.repository.name }}
CI_REPO_OWNER: ${{ github.event.organization.login }}
CI_COMMIT_SHA: ${{ github.sha }}
GIT_COMMIT: ${{ github.sha }}
CI_BRANCH: ${{ github.head_ref }}
FORCE_COLOR: 2
HUSKY_SKIP_INSTALL: true
- name: Upload coverage to Codecov
run: bash <(curl -s https://codecov.io/bash)
-f ./coverage/lcov.info
-B ${{ github.head_ref }}
-C ${{ github.sha }}
-Z || echo 'Codecov upload failed'
env:
CI: true
GITLAB_CI: true # pretend we are GitLab CI, while Codecov adding support for Github Actions
CODECOV_ENV: github-action
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- uses: actions/setup-node@v1
with:
node-version: 10
registry-url: https://registry.npmjs.org/
- run: npm ci
env:
CYPRESS_INSTALL_BINARY: 0
HUSKY_SKIP_INSTALL: true
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
publish-gpr:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- uses: actions/setup-node@v1
with:
node-version: 10
registry-url: https://npm.pkg.github.com/
scope: "@jshjohnson"
- run: npm ci
env:
CYPRESS_INSTALL_BINARY: 0
HUSKY_SKIP_INSTALL: true
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

41
.github/workflows/unit-tests.yml

@ -0,0 +1,41 @@
name: Unit Tests
on:
pull_request:
paths:
- 'src/scripts/**'
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- uses: actions/setup-node@v1
with:
node-version: 10
- name: Install dependencies
run: npm install --no-optional --no-audit --ignore-scripts
env:
CYPRESS_INSTALL_BINARY: 0
HUSKY_SKIP_INSTALL: true
- run: npm run coverage
env:
FORCE_COLOR: 2
- name: Upload coverage to Codecov
run: bash <(curl -s https://codecov.io/bash)
-f ./coverage/lcov.info
-B ${{ github.head_ref }}
-C ${{ github.event.after }}
-P ${{ github.event.number }}
-Z || echo 'Codecov upload failed'
env:
CI: true
GITLAB_CI: true # pretend we are GitLab CI, while Codecov adding support for Github Actions
CODECOV_ENV: github-action
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}

7
.mocharc.yml

@ -0,0 +1,7 @@
require:
- '@babel/register'
- './config/jsdom.js'
exit: true
spec: src/**/*.test.js

4
.npmrc

@ -0,0 +1,4 @@
message="chore(release): :bookmark: version %s"
git-tag-version=true
sign-git-tag=true
sign-git-commit=true

7878
package-lock.json

File diff suppressed because it is too large

46
package.json

@ -7,14 +7,14 @@
"scripts": {
"start": "run-p js:watch css:watch",
"build": "npm run js:build && npm run css:build",
"lint": "eslint $(find src -name '*.js')",
"coverage": "nyc npm run test:unit",
"lint": "eslint src/scripts",
"coverage": "nyc --reporter=lcov --reporter=text --reporter=text-summary mocha",
"bundlesize": "bundlesize",
"cypress:run": "$(npm bin)/cypress run",
"cypress:open": "$(npm bin)/cypress open",
"test": "npm run test:unit && npm run test:e2e",
"test:unit": "mocha --require ./config/jsdom.js --require @babel/register $(find src -name '*.test.js') --exit",
"test:unit:watch": "npm run test:unit -- --watch --inspect=5556",
"test:unit": "mocha",
"test:unit:watch": "mocha --watch --inspect=5556",
"test:e2e": "run-p --race start cypress:run",
"js:watch": "NODE_ENV=development node server.js",
"js:build": "webpack --config webpack.config.prod.js",
@ -25,8 +25,10 @@
"css:min": "csso public/assets/styles/base.css public/assets/styles/base.min.css && csso public/assets/styles/choices.css public/assets/styles/choices.min.css",
"bump-cache": "node bump-cache.js --current $npm_package_version",
"deploy": "git subtree push --prefix public origin gh-pages",
"postversion": "npm run js:build && npm run bump-cache",
"prepush": "run-p lint test:unit && npm run bundlesize"
"prepush": "run-p lint test:unit && npm run bundlesize",
"preversion": "npm test",
"postversion": "npm run bump-cache && git commit --all --no-verify -m 'updated version to $npm_package_version' && git push --no-verify --atomic",
"prepublishOnly": "npm run build"
},
"repository": {
"type": "git",
@ -38,6 +40,7 @@
"public/assets/scripts",
"public/assets/styles",
"src",
"!src/**/*.test.js",
"types"
],
"bugs": {
@ -60,33 +63,30 @@
"@babel/preset-env": "^7.3.1",
"@babel/register": "^7.0.0",
"autoprefixer": "^6.3.3",
"babel-eslint": "^9.0.0",
"babel-loader": "^8.0.5",
"bundlesize": "^0.17.1",
"bundlesize": "^0.18.0",
"chai": "^4.2.0",
"csso": "^1.8.2",
"cypress": "^3.1.5",
"eslint": "^3.19.0",
"eslint-config-airbnb": "^15.1.0",
"eslint-config-prettier": "^2.10.0",
"eslint-loader": "^2.1.2",
"eslint-plugin-cypress": "^2.2.0",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-prettier": "^2.7.0",
"eslint-plugin-react": "^7.12.4",
"cypress": "3.2.0",
"eslint": "^6.5.1",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-config-prettier": "^6.4.0",
"eslint-loader": "^3.0.2",
"eslint-plugin-cypress": "^2.7.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-prettier": "^3.1.1",
"express": "^4.16.4",
"husky": "^0.14.3",
"jsdom": "^11.12.0",
"mocha": "^5.2.0",
"husky": "^3.0.9",
"jsdom": "^15.2.0",
"mocha": "^6.2.2",
"node-sass": "^4.11.0",
"nodemon": "^1.18.10",
"npm-run-all": "^4.1.5",
"nyc": "^11.9.0",
"nyc": "^14.1.1",
"opn": "^5.4.0",
"postcss-cli": "^2.5.1",
"prettier": "^1.16.4",
"sinon": "^2.4.0",
"sinon": "^7.5.0",
"unminified-webpack-plugin": "^2.0.0",
"webpack": "^4.29.3",
"webpack-cli": "^3.2.3",

Loading…
Cancel
Save