From f8c0a865814246181c9b62080f8c7c928391ccb8 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 8 Apr 2021 11:21:37 -0700 Subject: [PATCH] [Tests] migrate tests to Github Actions --- .eslintignore | 1 + .github/workflows/node-4+.yml | 89 +++++++++++++++++++++++ .github/workflows/node-iojs.yml | 42 +++++++++++ .github/workflows/node-pretest.yml | 30 ++++++++ .github/workflows/node-zero.yml | 82 +++++++++++++++++++++ .github/workflows/rebase.yml | 15 ++++ .github/workflows/require-allow-edits.yml | 12 +++ .spelling | 4 + Makefile | 26 +++---- demos/google-sheet/README.md | 1 + docbits/25_manip.md | 2 +- docbits/73_sheetprops.md | 2 +- package.json | 15 +++- 13 files changed, 302 insertions(+), 19 deletions(-) create mode 100644 .eslintignore create mode 100644 .github/workflows/node-4+.yml create mode 100644 .github/workflows/node-iojs.yml create mode 100644 .github/workflows/node-pretest.yml create mode 100644 .github/workflows/node-zero.yml create mode 100644 .github/workflows/rebase.yml create mode 100644 .github/workflows/require-allow-edits.yml diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..ce7ed79 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +xlsx.js diff --git a/.github/workflows/node-4+.yml b/.github/workflows/node-4+.yml new file mode 100644 index 0000000..38d4da8 --- /dev/null +++ b/.github/workflows/node-4+.yml @@ -0,0 +1,89 @@ +name: 'Tests: node.js' + +on: [pull_request, push] + +jobs: + matrix: + runs-on: ubuntu-latest + outputs: + latest: ${{ steps.set-matrix.outputs.requireds }} + steps: + - uses: ljharb/actions/node/matrix@main + id: set-matrix + with: + versionsAsRoot: true + type: 'majors' + preset: '>=4' + + latest: + needs: [matrix] + name: 'latest majors' + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + node-version: ${{ fromJson(needs.matrix.outputs.latest) }} + include: + - node-version: '14.' + env: + TZ: America/New_York + - node-version: '13.' + env: + TZ: Europe/London + - node-version: '12.' + env: + TZ: Asia/Seoul + - node-version: '11.' + env: + TZ: America/Los_Angeles + FMTS: misc + - node-version: '10.' + env: + TZ: Europe/Berlin + FMTS: misc + - node-version: '9.' + env: + TZ: Asia/Kolkata + FMTS: misc + - node-version: '8.' + env: + TZ: Asia/Shanghai + FMTS: misc + - node-version: '7.' + env: + TZ: America/Cancun + FMTS: misc + - node-version: '6.' + env: + TZ: Asia/Seoul + FMTS: misc + - node-version: '5.' + env: + TZ: America/Anchorage + FMTS: misc + - node-version: '4.' + env: + TZ: America/Barbados + FMTS: misc + - node-version: '4.4.7' # see GH issue #1150 + env: + TZ: Asia/Tokyo + FMTS: misc + + steps: + - uses: actions/checkout@v2 + - uses: ljharb/actions/node/install@main + name: 'nvm install ${{ matrix.node-version }} && npm install' + with: + node-version: ${{ matrix.node-version }} + - run: make init + - run: 'cd test_files; make all; cd -' + - run: npm run tests-only + + node: + name: 'node 4+' + needs: [latest] + runs-on: ubuntu-latest + steps: + - run: 'echo tests completed' diff --git a/.github/workflows/node-iojs.yml b/.github/workflows/node-iojs.yml new file mode 100644 index 0000000..f85c166 --- /dev/null +++ b/.github/workflows/node-iojs.yml @@ -0,0 +1,42 @@ +name: 'Tests: node.js (io.js)' + +on: [pull_request, push] + +jobs: + matrix: + runs-on: ubuntu-latest + outputs: + latest: ${{ steps.set-matrix.outputs.requireds }} + steps: + - uses: ljharb/actions/node/matrix@main + id: set-matrix + with: + type: 'majors' + preset: 'iojs' + + latest: + needs: [matrix] + name: 'latest majors' + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: ${{ fromJson(needs.matrix.outputs.latest) }} + + steps: + - uses: actions/checkout@v2 + - uses: ljharb/actions/node/install@main + name: 'nvm install ${{ matrix.node-version }} && npm install' + with: + node-version: ${{ matrix.node-version }} + skip-ls-check: true + - run: make init + - run: 'cd test_files; make all; cd -' + - run: npm run tests-only + + node: + name: 'io.js' + needs: [latest] + runs-on: ubuntu-latest + steps: + - run: 'echo tests completed' diff --git a/.github/workflows/node-pretest.yml b/.github/workflows/node-pretest.yml new file mode 100644 index 0000000..cc9ef8a --- /dev/null +++ b/.github/workflows/node-pretest.yml @@ -0,0 +1,30 @@ +name: 'Tests: pretest/posttest' + +on: [pull_request, push] + +jobs: + pretest: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: ljharb/actions/node/install@main + name: 'nvm install lts/* && npm install' + with: + node-version: 'lts/*' + - run: make init + - run: 'cd test_files; make all; cd -' + - run: npm run pretest + + # posttest: + # runs-on: ubuntu-latest + + # steps: + # - uses: actions/checkout@v2 + # - uses: ljharb/actions/node/install@main + # name: 'nvm install lts/* && npm install' + # with: + # node-version: 'lts/*' + # - run: make init + # - run: 'cd test_files; make all; cd -' + # - run: npm run posttest diff --git a/.github/workflows/node-zero.yml b/.github/workflows/node-zero.yml new file mode 100644 index 0000000..67e7a26 --- /dev/null +++ b/.github/workflows/node-zero.yml @@ -0,0 +1,82 @@ +name: 'Tests: node.js (0.x)' + +on: [pull_request, push] + +jobs: + matrix: + runs-on: ubuntu-latest + outputs: + stable: ${{ steps.set-matrix.outputs.requireds }} + unstable: ${{ steps.set-matrix.outputs.optionals }} + steps: + - uses: ljharb/actions/node/matrix@main + id: set-matrix + with: + versionsAsRoot: true + preset: '0.x' + + stable: + needs: [matrix] + name: 'stable minors' + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + node-version: ${{ fromJson(needs.matrix.outputs.stable) }} + include: + - node-version: '0.12.' + env: + TZ: America/Cayman + FMTS: misc + - node-version: '0.10.' + env: + TZ: Pacific/Honolulu + FMTS: misc + - node-version: '0.8.' + env: + TZ: America/Mexico_City + FMTS: misc + + steps: + - uses: actions/checkout@v2 + - uses: ljharb/actions/node/install@main + name: 'nvm install ${{ matrix.node-version }} && npm install' + with: + node-version: ${{ matrix.node-version }} + cache-node-modules-key: node_modules-${{ github.workflow }}-${{ github.action }}-${{ github.run_id }} + skip-ls-check: true + - run: make init + - run: 'cd test_files; make all; cd -' + - run: npm run tests-only + + unstable: + needs: [matrix, stable] + name: 'unstable minors' + continue-on-error: true + if: ${{ !github.head_ref || !startsWith(github.head_ref, 'renovate') }} + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + node-version: ${{ fromJson(needs.matrix.outputs.unstable) }} + + steps: + - uses: actions/checkout@v2 + - uses: ljharb/actions/node/install@main + name: 'nvm install ${{ matrix.node-version }} && npm install' + with: + node-version: ${{ matrix.node-version }} + cache-node-modules-key: node_modules-${{ github.workflow }}-${{ github.action }}-${{ github.run_id }} + skip-ls-check: true + - run: make init + - run: 'cd test_files; make all; cd -' + - run: npm run tests-only + + node: + name: 'node 0.x' + needs: [stable, unstable] + runs-on: ubuntu-latest + steps: + - run: 'echo tests completed' diff --git a/.github/workflows/rebase.yml b/.github/workflows/rebase.yml new file mode 100644 index 0000000..027aed0 --- /dev/null +++ b/.github/workflows/rebase.yml @@ -0,0 +1,15 @@ +name: Automatic Rebase + +on: [pull_request_target] + +jobs: + _: + name: "Automatic Rebase" + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: ljharb/rebase@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/require-allow-edits.yml b/.github/workflows/require-allow-edits.yml new file mode 100644 index 0000000..549d7b4 --- /dev/null +++ b/.github/workflows/require-allow-edits.yml @@ -0,0 +1,12 @@ +name: Require “Allow Edits” + +on: [pull_request_target] + +jobs: + _: + name: "Require “Allow Edits”" + + runs-on: ubuntu-latest + + steps: + - uses: ljharb/require-allow-edits@main diff --git a/.spelling b/.spelling index 5ff22b6..03930ef 100644 --- a/.spelling +++ b/.spelling @@ -93,6 +93,10 @@ runtime serverless submodule transpiled +node.js +commonjs +async +uncheck - demos/altjs/README.md ChakraCore diff --git a/Makefile b/Makefile index b13b402..d57e6d2 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ FLOWAUX=$(patsubst %.js,%.flow.js,$(AUXTARGETS)) AUXSCPTS=xlsxworker.js FLOWTGTS=$(TARGET) $(AUXTARGETS) $(AUXSCPTS) $(MINITGT) UGLIFYOPTS=--support-ie8 -m -CLOSURE=/usr/local/lib/node_modules/google-closure-compiler/compiler.jar +# CLOSURE=/usr/local/lib/node_modules/google-closure-compiler/compiler.jar ## Main Targets @@ -177,31 +177,31 @@ demo-systemjs: ## Run systemjs demo build ## Code Checking .PHONY: fullint -fullint: lint old-lint tslint flow mdlint ## Run all checks +fullint: lint mdlint ## Run all checks (removed: old-lint, tslint, flow) .PHONY: lint lint: $(TARGET) $(AUXTARGETS) ## Run eslint checks - @eslint --ext .js,.njs,.json,.html,.htm $(TARGET) $(AUXTARGETS) $(CMDS) $(HTMLLINT) package.json bower.json - if [ -e $(CLOSURE) ]; then java -jar $(CLOSURE) $(REQS) $(FLOWTARGET) --jscomp_warning=reportUnknownTypes >/dev/null; fi + @./node_modules/.bin/eslint --ext .js,.njs,.json,.html,.htm $(TARGET) $(AUXTARGETS) $(CMDS) $(HTMLLINT) package.json bower.json + if [ -n "$(CLOSURE-)" ] && [ -e "${CLOSURE}" ]; then java -jar $(CLOSURE) $(REQS) $(FLOWTARGET) --jscomp_warning=reportUnknownTypes >/dev/null; fi .PHONY: old-lint old-lint: $(TARGET) $(AUXTARGETS) ## Run jshint and jscs checks - @jshint --show-non-errors $(TARGET) $(AUXTARGETS) - @jshint --show-non-errors $(CMDS) - @jshint --show-non-errors package.json bower.json test.js - @jshint --show-non-errors --extract=always $(HTMLLINT) - @jscs $(TARGET) $(AUXTARGETS) test.js + @./node_modules/.bin/jshint --show-non-errors $(TARGET) $(AUXTARGETS) + @./node_modules/.bin/jshint --show-non-errors $(CMDS) + @./node_modules/.bin/jshint --show-non-errors package.json bower.json test.js + @./node_modules/.bin/jshint --show-non-errors --extract=always $(HTMLLINT) + @./node_modules/.bin/jscs $(TARGET) $(AUXTARGETS) test.js if [ -e $(CLOSURE) ]; then java -jar $(CLOSURE) $(REQS) $(FLOWTARGET) --jscomp_warning=reportUnknownTypes >/dev/null; fi .PHONY: tslint tslint: $(TARGET) ## Run typescript checks #@npm install dtslint typescript #@npm run-script dtslint - dtslint types + ./node_modules/.bin/dtslint types .PHONY: flow flow: lint ## Run flow checker - @flow check --all --show-all-errors --include-warnings + @./node_modules/.bin/flow check --all --show-all-errors --include-warnings .PHONY: cov cov: misc/coverage.html ## Run coverage test @@ -237,8 +237,8 @@ DEMOMDS=$(sort $(wildcard demos/*/README.md)) MDLINT=$(DEMOMDS) $(READEPS) demos/README.md .PHONY: mdlint mdlint: $(MDLINT) ## Check markdown documents - alex $^ - mdspell -a -n -x -r --en-us $^ + ./node_modules/.bin/alex $^ + ./node_modules/.bin/mdspell -a -n -x -r --en-us $^ .PHONY: help help: diff --git a/demos/google-sheet/README.md b/demos/google-sheet/README.md index 0da6d72..b865029 100644 --- a/demos/google-sheet/README.md +++ b/demos/google-sheet/README.md @@ -41,6 +41,7 @@ This imports both `xlsx` and `drive-db` libraries. While these are written in co })(); ``` + This is what is called an [Immediately Invoked Function Expression](https://flaviocopes.com/javascript-iife/). These are normally used to either create a new execution context, or in this case to allow to run async code easier. ```js diff --git a/docbits/25_manip.md b/docbits/25_manip.md index f563e9c..8d89a87 100644 --- a/docbits/25_manip.md +++ b/docbits/25_manip.md @@ -67,7 +67,7 @@ error if the workbook is empty. - read + modify + write files -- node +- node The node version installs a command line tool `xlsx` which can read spreadsheet files and output the contents in various formats. The source is available at diff --git a/docbits/73_sheetprops.md b/docbits/73_sheetprops.md index 1b30e10..f8d8107 100644 --- a/docbits/73_sheetprops.md +++ b/docbits/73_sheetprops.md @@ -16,7 +16,7 @@ The visibility setting is stored in the `Hidden` property of sheet props array. | 1 | Hidden | | 2 | Very Hidden | -With : +With : ```js > wb.Workbook.Sheets.map(function(x) { return [x.name, x.Hidden] }) diff --git a/package.json b/package.json index 0ec3feb..9ebb2a7 100644 --- a/package.json +++ b/package.json @@ -40,15 +40,20 @@ "exit-on-epipe": "~1.0.1", "fflate": "^0.3.8", "ssf": "~0.11.2", - "word": "~0.3.0", - "wmf": "~1.0.1" + "wmf": "~1.0.1", + "word": "~0.3.0" }, "devDependencies": { "@sheetjs/uglify-js": "~2.7.3", "@types/node": "^8.5.9", + "alex": "^9.1.0", "blanket": "~1.2.3", "dtslint": "^0.1.2", + "eslint": "^7.23.0", + "eslint-plugin-html": "^6.1.2", + "eslint-plugin-json": "^2.1.2", "jsdom": "~11.1.0", + "markdown-spellcheck": "^1.3.1", "mocha": "~2.5.3", "typescript": "2.2.0" }, @@ -57,8 +62,10 @@ "url": "git://github.com/SheetJS/sheetjs.git" }, "scripts": { - "pretest": "git submodule init && git submodule update", - "test": "make travis", + "pretest": "npm run lint", + "test": "npm run tests-only", + "pretest-only": "git submodule init && git submodule update", + "tests-only": "make travis", "build": "make", "lint": "make fullint", "dtslint": "dtslint types"