Skip to content
Snippets Groups Projects
Unverified Commit b7bad38d authored by Jordan Harband's avatar Jordan Harband
Browse files

[Tests] build tests first, so CI can build/test in different stages

parent 2cb51c1f
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,14 @@ ...@@ -3,6 +3,14 @@
"test": { "test": {
"presets": [["airbnb", { looseClasses: true }]], "presets": [["airbnb", { looseClasses: true }]],
"plugins": [ "plugins": [
["import-path-replace", {
"rules": [
{
"match": "../src/",
"replacement": "../lib/"
}
]
}],
["inline-react-svg", { ["inline-react-svg", {
"svgo": false "svgo": false
}], }],
......
...@@ -14,11 +14,31 @@ jobs: ...@@ -14,11 +14,31 @@ jobs:
with: with:
type: 'majors' type: 'majors'
versionsAsRoot: true versionsAsRoot: true
preset: '>=6' preset: '>=4'
# to test in node < 6, we need to run the build in one stage, including the tests, and then run the tests in the desired node version later
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/install@main
with:
node-version: 'lts/*'
- uses: actions/cache@v2
id: cache
with:
path: |
lib
esm
test-build
key: ${{ runner.os }}-${{ hashFiles('package.json', 'src/**', 'test/**', 'scripts/buildCSS.js') }}
- run: npm run build
if: steps.cache.outputs.cache-hit != 'true'
- run: npm run build:test
if: steps.cache.outputs.cache-hit != 'true'
majors: majors:
needs: [matrix] needs: [build, matrix]
name: 'latest minors' name: 'latest minors'
runs-on: ubuntu-latest runs-on: ubuntu-latest
...@@ -34,7 +54,7 @@ jobs: ...@@ -34,7 +54,7 @@ jobs:
- '15' - '15'
- '15.5' - '15.5'
- '15.0' - '15.0'
# - '0.14' # TODO: fix pure-component-fallbacl - '0.14'
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
...@@ -42,13 +62,25 @@ jobs: ...@@ -42,13 +62,25 @@ jobs:
name: 'nvm install ${{ matrix.node-version }} && npm install' name: 'nvm install ${{ matrix.node-version }} && npm install'
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
skip-ls-check: ${{ !startsWith(matrix.node-version, '5.') && !startsWith(matrix.node-version, '4.') && 'true' || 'false' }}
- uses: actions/cache@v2
id: cache
with:
path: |
lib
esm
test-build
key: ${{ runner.os }}-${{ hashFiles('package.json', 'src/**', 'test/**', 'scripts/buildCSS.js') }}
- run: npm run react
env:
REACT: ${{ matrix.react }}
- run: npm run tests-only - run: npm run tests-only
env: env:
REACT: ${{ matrix.react }} REACT: ${{ matrix.react }}
- uses: codecov/codecov-action@v2 - uses: codecov/codecov-action@v2
node: node:
name: 'node 6+' name: 'node.js'
needs: [majors] needs: [majors]
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
......
...@@ -35,6 +35,7 @@ node_modules ...@@ -35,6 +35,7 @@ node_modules
# build folder # build folder
lib lib
esm esm
test-build
.idea .idea
# gh-pages # gh-pages
......
...@@ -44,5 +44,6 @@ public ...@@ -44,5 +44,6 @@ public
react-dates-demo.gif react-dates-demo.gif
stories stories
test test
test-build
css css
!lib/css !lib/css
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
"src" "src"
], ],
"require": [ "require": [
"@babel/register"
], ],
"reporter": [ "reporter": [
"text", "text",
......
...@@ -5,22 +5,23 @@ ...@@ -5,22 +5,23 @@
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"prebuild": "npm run clean", "prebuild": "npm run clean",
"build": "npm run build:cjs && npm run build:esm && npm run build:css -- --optimize ", "build": "npm run build:cjs && npm run build:esm && npm run build:css -- --optimize",
"postbuild": "npm run build:test",
"build:cjs": "BABEL_ENV=cjs babel src/ -d lib/", "build:cjs": "BABEL_ENV=cjs babel src/ -d lib/",
"build:esm": "BABEL_ENV=esm babel src/ -d esm/", "build:esm": "BABEL_ENV=esm babel src/ -d esm/",
"build:test": "BABEL_ENV=test babel test/ -d test-build/",
"prebuild:css": "rimraf lib/css && mkdirp lib/css", "prebuild:css": "rimraf lib/css && mkdirp lib/css",
"build:css": "node scripts/buildCSS.js", "build:css": "node scripts/buildCSS.js",
"clean": "rimraf lib esm", "clean": "rimraf lib esm test-build",
"lint": "eslint --ext .js,.jsx src test", "lint": "eslint --ext .js,.jsx src test",
"mocha": "mocha ./test/_helpers", "mocha": "mocha ./test-build/_helpers",
"storybook:uninstall": "npm uninstall --no-save @storybook/react && rimraf node_modules/@storybook node_modules/react-modal node_modules/react-dom-factories", "storybook:uninstall": "npm uninstall --no-save @storybook/react && rimraf node_modules/@storybook node_modules/react-modal node_modules/react-dom-factories",
"react": "NPM_CONFIG_LEGACY_PEER_DEPS=true enzyme-adapter-react-install 16", "react": "NPM_CONFIG_LEGACY_PEER_DEPS=true enzyme-adapter-react-install 16",
"pretest": "npm run --silent lint", "pretest": "npm run --silent lint",
"pretests-only": "npm run react",
"tests-only": "cross-env NODE_ENV=test nyc npm run mocha --silent", "tests-only": "cross-env NODE_ENV=test nyc npm run mocha --silent",
"pretests-karma": "npm run react", "pretests-karma": "npm run react",
"tests-karma": "karma start", "tests-karma": "karma start",
"test": "npm run build && npm run tests-only", "test": "npm run react && npm run build && npm run build:test && npm run tests-only",
"storybook": "start-storybook -p 6006", "storybook": "start-storybook -p 6006",
"storybook:css": "npm run build:css && start-storybook -p 6006 -c .storybook-css", "storybook:css": "npm run build:css && start-storybook -p 6006 -c .storybook-css",
"tag": "git tag v$npm_package_version", "tag": "git tag v$npm_package_version",
...@@ -64,12 +65,14 @@ ...@@ -64,12 +65,14 @@
"airbnb-js-shims": "^2.2.1", "airbnb-js-shims": "^2.2.1",
"aphrodite": "^2.4.0", "aphrodite": "^2.4.0",
"babel-loader": "^8.2.2", "babel-loader": "^8.2.2",
"babel-plugin-import-path-replace": "^0.1.0",
"babel-plugin-inline-react-svg": "^1.1.2", "babel-plugin-inline-react-svg": "^1.1.2",
"babel-plugin-inline-svg": "^1.2.0", "babel-plugin-inline-svg": "^1.2.0",
"babel-plugin-istanbul": "^5.2.0", "babel-plugin-istanbul": "^5.2.0",
"babel-plugin-transform-replace-object-assign": "^2.0.0", "babel-plugin-transform-replace-object-assign": "^2.0.0",
"babel-preset-airbnb": "^4.5.0", "babel-preset-airbnb": "^4.5.0",
"chai": "^4.2.0", "chai": "^4.2.0",
"cheerio": "=1.0.0-rc.3",
"clean-css": "^4.2.3", "clean-css": "^4.2.3",
"cross-env": "^5.2.1", "cross-env": "^5.2.1",
"enzyme": "^3.11.0", "enzyme": "^3.11.0",
...@@ -104,7 +107,7 @@ ...@@ -104,7 +107,7 @@
"rimraf": "^2.7.1", "rimraf": "^2.7.1",
"safe-publish-latest": "^1.1.4", "safe-publish-latest": "^1.1.4",
"sass-loader": "^7.3.1", "sass-loader": "^7.3.1",
"sinon": "^8.1.1", "sinon": "^7.5.0",
"sinon-sandbox": "^2.0.6", "sinon-sandbox": "^2.0.6",
"style-loader": "^0.20.3", "style-loader": "^0.20.3",
"typescript": "*", "typescript": "*",
......
--require @babel/register
--require airbnb-js-shims --require airbnb-js-shims
test/**/*.{js,jsx} test-build/**/*.js
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment