From 5f7464af4860a3efe29dc409d6f28424bc14705c Mon Sep 17 00:00:00 2001 From: Anix Date: Fri, 14 Feb 2020 15:22:53 +0530 Subject: [PATCH] chore: migrate CI to github, refactore CI and npm scripts, linting fixes (#1023) --- .github/workflows/{CI.yml => e2e.yml} | 2 -- .github/workflows/lint.yml | 31 +++++++++++++++++++++++++ .github/workflows/unit.yml | 31 +++++++++++++++++++++++++ .travis.yml | 23 ------------------ package.json | 5 ++-- src/core/config.js | 4 ++++ src/core/render/compiler.js | 3 ++- test/unit/{base.js => base.test.js} | 0 test/unit/{render.js => render.test.js} | 0 test/unit/{util.js => util.test.js} | 0 10 files changed, 71 insertions(+), 28 deletions(-) rename .github/workflows/{CI.yml => e2e.yml} (93%) create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/unit.yml delete mode 100644 .travis.yml rename test/unit/{base.js => base.test.js} (100%) rename test/unit/{render.js => render.test.js} (100%) rename test/unit/{util.js => util.test.js} (100%) diff --git a/.github/workflows/CI.yml b/.github/workflows/e2e.yml similarity index 93% rename from .github/workflows/CI.yml rename to .github/workflows/e2e.yml index 5dd6bbf5d..09fd229fa 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/e2e.yml @@ -27,7 +27,5 @@ jobs: run: npm run bootstrap - name: Build run: npm run build - - name: linting - run: npm run lint - name: end to end run: npm run test:e2e diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..8e40422e8 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,31 @@ +name: Linting Checks + +on: + push: + branches: + - master + - develop + pull_request: + branches: + - master + - develop + +jobs: + build: + runs-on: ubuntu-16.04 + strategy: + matrix: + node-version: [10.x, 12.x, 13.x] + + steps: + - uses: actions/checkout@v1 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: bootstrap + run: npm run bootstrap + - name: Build + run: npm run build + - name: Linting + run: npm run lint diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml new file mode 100644 index 000000000..45c001f7a --- /dev/null +++ b/.github/workflows/unit.yml @@ -0,0 +1,31 @@ +name: Unit tests Suite + +on: + push: + branches: + - master + - develop + pull_request: + branches: + - master + - develop + +jobs: + build: + runs-on: ubuntu-16.04 + strategy: + matrix: + node-version: [10.x, 12.x, 13.x] + + steps: + - uses: actions/checkout@v1 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: bootstrap + run: npm run bootstrap + - name: Build + run: npm run build + - name: Unit tests + run: npm run test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 49cfc9814..000000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -sudo: false -language: node_js -node_js: stable -node_js: - - '10' - - '8' - - '12' -branches: - only: - - master - - develop -cache: - directories: - - node_modules -before_install: - - npm update -install: - - npm install -script: - - npm run build - - npm run test:e2e -script: - - npm run lint diff --git a/package.json b/package.json index 0e13bc351..a7b79c863 100644 --- a/package.json +++ b/package.json @@ -26,8 +26,9 @@ "serve:ssr": "cross-env SSR=1 node server", "dev": "run-p serve watch:*", "dev:ssr": "run-p serve:ssr watch:*", - "lint": "eslint . --fix", - "test": "mocha test/*/**", + "lint": "eslint .", + "fixlint" : "eslint . --fix", + "test": "mocha ./test/**/*.test.js", "testServer": "node cypress/setup.js", "test:e2e": "start-server-and-test testServer http://localhost:3000 cy:run", "posttest:e2e": "rimraf cypress/fixtures/docs", diff --git a/src/core/config.js b/src/core/config.js index 607bc1152..7ffdb0fd2 100644 --- a/src/core/config.js +++ b/src/core/config.js @@ -58,15 +58,19 @@ export default function () { if (config.loadSidebar === true) { config.loadSidebar = '_sidebar' + config.ext } + if (config.loadNavbar === true) { config.loadNavbar = '_navbar' + config.ext } + if (config.coverpage === true) { config.coverpage = '_coverpage' + config.ext } + if (config.repo === true) { config.repo = '' } + if (config.name === true) { config.name = '' } diff --git a/src/core/render/compiler.js b/src/core/render/compiler.js index 60602f1ae..132f51413 100644 --- a/src/core/render/compiler.js +++ b/src/core/render/compiler.js @@ -22,10 +22,11 @@ export function getAndRemoveConfig(str = '') { .replace(/^'/, '') .replace(/'$/, '') .replace(/(?:^|\s):([\w-]+:?)=?([\w-]+)?/g, (m, key, value) => { - if(key.indexOf(':') === -1){ + if (key.indexOf(':') === -1) { config[key] = (value && value.replace(/"/g, '')) || true return '' } + return m }) .trim() diff --git a/test/unit/base.js b/test/unit/base.test.js similarity index 100% rename from test/unit/base.js rename to test/unit/base.test.js diff --git a/test/unit/render.js b/test/unit/render.test.js similarity index 100% rename from test/unit/render.js rename to test/unit/render.test.js diff --git a/test/unit/util.js b/test/unit/util.test.js similarity index 100% rename from test/unit/util.js rename to test/unit/util.test.js