From ee106c274cc4c589584f8b749cee3db26e08930c Mon Sep 17 00:00:00 2001 From: grmeyer-hw-dev <107439697+grmeyer-hw-dev@users.noreply.github.com> Date: Wed, 24 Aug 2022 16:34:09 -0700 Subject: [PATCH] Introduce GitHubAction (#126) Run the test over all stable (its) NodeJS versions 8, 10, 12 14 and 16 Report test coverage to coveralls.io Update documentation when code is pushed to master. --- .github/workflows/ci.yml | 61 +++++++++++++++++++++++++++++ .github/workflows/documentation.yml | 53 +++++++++++++++++++++++++ package-lock.json | 3 +- package.json | 2 +- 4 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/documentation.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..77a1194 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,61 @@ +name: NodeJS SDK CI + +on: + workflow_dispatch: + push: + branches: + - master + - support/SDK-V3 + - feature/** + - bugfix/** + pull_request: + branches: + - master + - support/SDK-V3 + - feature/** + - bugfix/** +jobs: + test: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + node-version: [8.x ,10.x, 12.x ,14.x ,16.x] + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + + - run: npm install + - run: npm run build --if-present + - run: npm run test + + code-coverage: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + node-version: [ 8.x ] + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + + - run: npm install + - run: npm run build --if-present + - run: npm run test-coverage + + - name: Coveralls + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml new file mode 100644 index 0000000..1964bee --- /dev/null +++ b/.github/workflows/documentation.yml @@ -0,0 +1,53 @@ +name: Update Documentation + +on: + workflow_dispatch: + push: + branches: + - master + pull_request: + branches: + - master +jobs: + documentation: + # Generate documentation and push to gh-pages branch using the predefined JDK versions in the strategy section + name: Documentation + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + node-version: [ 8.x ] + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + + - run: npm install + - run: npm run docs + + - name: Copy to documentation Website Location + run: | + mkdir ../gh-pages + cp -r docs/* ../gh-pages/ + cd ../gh-pages + + - name: Commit documentation changes + run: | + if [[ `git status --porcelain` ]]; then + echo "Commit documentation" + # Set identity + git config --global user.email "dev-git-action@paypal.com" + git config --global user.name "Git Action Doc" + + # Add branch + git checkout -B gh-pages + + # Push generated files + git add -A + git commit -m "Documentation updated" + git push origin gh-pages -fq > /dev/null + fi diff --git a/package-lock.json b/package-lock.json index f1c0d2e..acb0b12 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8991,7 +8991,8 @@ "dependencies": { "ansi-regex": { "version": "5.0.0", - "resolved": "", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", "dev": true }, "find-up": { diff --git a/package.json b/package.json index 02ac125..48faf31 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "docs": "esdoc -c ./.esdoc.json", "deploy-docs": "npm run docs && gh-pages -d docs", "test": "npm run lint && npm run test-unit", - "test-unit": "mocha --compilers js:babel-register test/**/*.js test/*.js", + "test-unit": "nyc --reporter lcov mocha --require babel-core/register test/**/*.js test/*.js", "test-coverage": "nyc npm run test", "coveralls": "npm run test-coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js", "prepublish-prod": "npm test && npm run prod",