From 0ba18138dda710d1e1b7804b6cda5b430821b640 Mon Sep 17 00:00:00 2001 From: raimondb Date: Sun, 25 Jun 2023 16:09:56 +0200 Subject: [PATCH] feat(ci): :rocket: Migrate CI and Deployment to Github actions --- .github/workflows/automerge.yml | 4 ++-- .github/workflows/npm-ci.yml | 30 ++++++++++++++++++++++++++++++ .github/workflows/npm-publish.yml | 28 ++++++++++++++++++++++++++++ .github/workflows/test-report.yml | 16 ++++++++++++++++ 4 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/npm-ci.yml create mode 100644 .github/workflows/npm-publish.yml create mode 100644 .github/workflows/test-report.yml diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index 0fc943b..9efdf69 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -19,13 +19,13 @@ on: check_suite: types: - completed - status: {} + status: jobs: automerge: runs-on: ubuntu-latest steps: - name: automerge - uses: "pascalgn/automerge-action@f81beb99aef41bb55ad072857d43073fba833a98" + uses: "pascalgn/automerge-action@v0.15.6" env: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" MERGE_LABELS: "dependencies,!work in progress" diff --git a/.github/workflows/npm-ci.yml b/.github/workflows/npm-ci.yml new file mode 100644 index 0000000..ba7804b --- /dev/null +++ b/.github/workflows/npm-ci.yml @@ -0,0 +1,30 @@ +# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created +# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages + +name: NPM-CI + +on: + push: + branches-ignore: + - master + +jobs: + build: + strategy: + matrix: + node-version: [14.x, 16.x, 18.x, 20.x] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + - run: npm ci + - run: npm test -- --reporter json --reporter-option output=test-results.json + - name: Archive test results + uses: actions/upload-artifact@v3 + if: success() || failure() + with: + name: test-results-report + path: test-results.json diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 0000000..b9c92f0 --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,28 @@ +name: NPM-Publish + +on: + workflow_dispatch: + inputs: {} + push: + branches: + - 'master' + +jobs: + publish-npm: +# if: ${{github.GITHUB_REF == 'refs/heads/master'}} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: +# See below for current versions supported by Node-red +# https://nodered.org/docs/faq/node-versions#installing-nodejs + node-version: 18 + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm test + - run: npx semantic-release + env: +# NODE_AUTH_TOKEN: ${{secrets.npm_token}} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/test-report.yml b/.github/workflows/test-report.yml new file mode 100644 index 0000000..f5813dd --- /dev/null +++ b/.github/workflows/test-report.yml @@ -0,0 +1,16 @@ +name: 'Test Report' +on: + workflow_run: + workflows: ['NPM-CI'] # runs after CI workflow + types: + - completed +jobs: + report: + runs-on: ubuntu-latest + steps: + - uses: dorny/test-reporter@v1 + with: + artifact: test-results-report # artifact name + name: Mocha Tests # Name of the check run which will be created + path: '*.json' # Path to test results (inside artifact .zip) + reporter: mocha-json # Format of test results