From 18f005974391f402ed6dd56cd92bebd1e18b3232 Mon Sep 17 00:00:00 2001 From: Drew Keller Date: Sat, 6 Feb 2021 10:10:01 -0600 Subject: [PATCH 1/7] Group scripts with npm-run-all --- package.json | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 774c89a..fb900ff 100644 --- a/package.json +++ b/package.json @@ -25,15 +25,17 @@ "node": ">=10" }, "scripts": { - "build": "npm run clean && babel src -d lib --extensions '.js,.ts' --ignore '**/*.spec.js','**/*.spec.ts' && npm run build-types", - "build-demo": "npm run clean-demo && webpack --config demo/webpack.config.js", - "build-types": "tsc -p ./tsconfig.release-types.json", - "clean": "rimraf lib/*", - "clean-demo": "rimraf demo/lib/*", + "build": "run-s clean:* build:*", + "build:src": "babel src -d lib --extensions '.js,.ts' --ignore '**/*.spec.js','**/*.spec.ts'", + "build:demo": "webpack --config demo/webpack.config.js", + "build:types": "tsc -p ./tsconfig.release-types.json", + "clean:src": "rimraf lib/*", + "clean:demo": "rimraf demo/lib/*", "format": "prettier --write '{src,demo/src}/**'", - "lint": "tsc -p ./tsconfig.release.json && eslint . --ext .js,.ts --report-unused-disable-directives --parser-options=project:./tsconfig.release.json", - "lint-demo": "tsc -p ./demo/tsconfig.json && eslint . --ext .js,.ts --report-unused-disable-directives --parser-options=project:./demo/tsconfig.json", - "lint-tests": "tsc -p ./tsconfig.test.json && eslint . --ext .js,.ts --report-unused-disable-directives --parser-options=project:./tsconfig.test.json", + "lint": "run-s lint:*", + "lint:src": "tsc -p ./tsconfig.release.json && eslint . --ext .js,.ts --report-unused-disable-directives --parser-options=project:./tsconfig.release.json", + "lint:demo": "tsc -p ./demo/tsconfig.json && eslint . --ext .js,.ts --report-unused-disable-directives --parser-options=project:./demo/tsconfig.json", + "lint:tests": "tsc -p ./tsconfig.test.json && eslint . --ext .js,.ts --report-unused-disable-directives --parser-options=project:./tsconfig.test.json", "precommit": "pretty-quick --staged", "prepublish": "npx publish-please guard", "publish-please": "npx publish-please", @@ -66,6 +68,7 @@ "jest": "^26.4.2", "jest-when": "^2.7.0", "node-sass": "^4.12.0", + "npm-run-all": "^4.1.5", "prettier": "1.18.2", "pretty-quick": "1.7.0", "rimraf": "^2.7.1", From 67093f893423630e9199d54530dce7639cc95e6f Mon Sep 17 00:00:00 2001 From: Drew Keller Date: Sat, 6 Feb 2021 11:57:17 -0600 Subject: [PATCH 2/7] Begin GitHub Actions workflow to run tests --- .github/workflows/tests.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..5d40114 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,37 @@ +name: Tests + +on: + push: + branches: [main, develop] + pull_request: + branches: [main, develop] + schedule: + # 00:00 on Saturdays + - cron: '0 0 * * SAT' + workflow_dispatch: + +jobs: + test: + name: Test + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + node-version: [10.x, 14.x] + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: '2' + + - name: Test on Node ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - run: npm install + - run: npm run lint + - run: npm run build + - run: npm run test From 40ad0354f7bbf98f9da274817dfb577fe563957b Mon Sep 17 00:00:00 2001 From: Drew Keller Date: Sat, 6 Feb 2021 11:57:43 -0600 Subject: [PATCH 3/7] Upload test report to Codecov --- .github/workflows/tests.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5d40114..0f9ad2d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -35,3 +35,8 @@ jobs: - run: npm run lint - run: npm run build - run: npm run test + + - name: Upload test coverage report to Codecov + uses: codecov/codecov-action@v1 + with: + fail_ci_if_error: true From f6e0a12dd6add5bbe791f8dbea09000d88fd7928 Mon Sep 17 00:00:00 2001 From: Drew Keller Date: Sat, 6 Feb 2021 13:19:50 -0600 Subject: [PATCH 4/7] Add Snyk security test to test workflow --- .github/workflows/tests.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0f9ad2d..dfc6c1d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -40,3 +40,8 @@ jobs: uses: codecov/codecov-action@v1 with: fail_ci_if_error: true + + - name: Run Snyk to check for vulnerabilities + uses: snyk/actions/node@master + env: + SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} From 4f5766027173b1df86af2d11db923f02772ef0f4 Mon Sep 17 00:00:00 2001 From: Drew Keller Date: Sat, 6 Feb 2021 13:24:13 -0600 Subject: [PATCH 5/7] Scan code for vulnerabilities with CodeQL --- .github/workflows/security-scan.yml | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/security-scan.yml diff --git a/.github/workflows/security-scan.yml b/.github/workflows/security-scan.yml new file mode 100644 index 0000000..b5efb06 --- /dev/null +++ b/.github/workflows/security-scan.yml @@ -0,0 +1,36 @@ +name: Security Scan + +on: + push: + branches: [main, develop] + pull_request: + branches: [main, develop] + schedule: + # 10:17 on Fridays + - cron: '17 10 * * 5' + workflow_dispatch: + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + language: ['javascript'] + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 From 7e90659a5b72e7db3969f6462eaac6c02820a5d4 Mon Sep 17 00:00:00 2001 From: Drew Keller Date: Sat, 6 Feb 2021 13:26:34 -0600 Subject: [PATCH 6/7] Delete TravisCI integration --- .travis.yml | 9 --------- README.md | 1 - package.json | 3 +-- 3 files changed, 1 insertion(+), 12 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3f43eb2..0000000 --- a/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -language: node_js -node_js: - - 'node' - - '10' -script: - - npm run travisci -cache: - directories: - - node_modules diff --git a/README.md b/README.md index 0afcf7f..11cc5e3 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ [![npm package](https://badge.fury.io/js/regex-to-strings.svg)](https://badge.fury.io/js/regex-to-strings) ![node version](https://img.shields.io/node/v/regex-to-strings.svg) ![npm type definitions](https://img.shields.io/npm/types/regex-to-strings) -[![Build Status](https://travis-ci.org/wimpyprogrammer/regex-to-strings.svg?branch=main)](https://travis-ci.org/wimpyprogrammer/regex-to-strings) [![codecov](https://codecov.io/gh/wimpyprogrammer/regex-to-strings/branch/main/graph/badge.svg)](https://codecov.io/gh/wimpyprogrammer/regex-to-strings) [![Known Vulnerabilities](https://snyk.io/test/github/wimpyprogrammer/regex-to-strings/badge.svg)](https://snyk.io/test/github/wimpyprogrammer/regex-to-strings) diff --git a/package.json b/package.json index fb900ff..4658c88 100644 --- a/package.json +++ b/package.json @@ -40,8 +40,7 @@ "prepublish": "npx publish-please guard", "publish-please": "npx publish-please", "publish-please-prereqs": "npm run lint && npm run test && npm run build", - "test": "jest --coverage", - "travisci": "npm run lint && npm run test && codecov && npx snyk test" + "test": "jest --coverage" }, "devDependencies": { "@babel/cli": "^7.5.5", From c8b30f1bdf4d73390cb619c2071eac4be4789a31 Mon Sep 17 00:00:00 2001 From: Drew Keller Date: Sat, 6 Feb 2021 13:39:14 -0600 Subject: [PATCH 7/7] Add Tests workflow badge to README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 11cc5e3..46c65f4 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![npm package](https://badge.fury.io/js/regex-to-strings.svg)](https://badge.fury.io/js/regex-to-strings) ![node version](https://img.shields.io/node/v/regex-to-strings.svg) ![npm type definitions](https://img.shields.io/npm/types/regex-to-strings) +![Tests](https://github.com/wimpyprogrammer/regex-to-strings/workflows/Tests/badge.svg) [![codecov](https://codecov.io/gh/wimpyprogrammer/regex-to-strings/branch/main/graph/badge.svg)](https://codecov.io/gh/wimpyprogrammer/regex-to-strings) [![Known Vulnerabilities](https://snyk.io/test/github/wimpyprogrammer/regex-to-strings/badge.svg)](https://snyk.io/test/github/wimpyprogrammer/regex-to-strings)