diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 00000000..0c09fa27 --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,22 @@ +# 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://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages + +name: upload-npm + +on: + release: + types: [created] + +jobs: + publish-npm: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 14 + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..3d5e3b8b --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,98 @@ +# Useful GitHub Actions docs: +# +# - https://help.github.com/en/actions +# - https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions +# - https://help.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow +# - https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions + +name: test + +on: + - push + - pull_request + +jobs: + # Job to run linter / autoformat + + lint: + runs-on: ubuntu-20.04 + steps: + # Action Repo: https://github.com/actions/checkout + - name: "Checkout repo" + uses: actions/checkout@v2 + + # Action Repo: https://github.com/actions/setup-node + - name: "Setup Node" + uses: actions/setup-node@v1 + with: + node-version: "14" + + # Action Repo: https://github.com/actions/cache + - name: "Cache node_modules" + uses: actions/cache@v2 + with: + path: node_modules + key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.os }}-npm- + + - name: "Install" + run: | + npm ci + + - name: "`npm run fmt` and check for changes" + run: | + # If this fails, run `npm run fmt` and push the result + # amend if you feel so inclined. + npm run fmt + git diff --exit-code + + - name: npm audit + run: | + # If this fails, run `npm audit fix` + npm audit --production --audit-level=moderate + + test: + # no need to wait for lint + # needs: lint + runs-on: ubuntu-20.04 + # - https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstrategy + strategy: + fail-fast: false # Do not cancel all jobs if one fails + matrix: + node_version: + - "10" + - "12" + - "14" + - "15" + + steps: + - name: "Checkout repo" + uses: actions/checkout@v2 + + # Action Repo: https://github.com/actions/setup-node + - name: "Setup Node" + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node_version }} + + # Action Repo: https://github.com/actions/cache + - name: "Cache node_modules" + uses: actions/cache@v2 + with: + path: node_modules + key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.os }}-npm- + + - name: "Install dependencies" + run: | + npm ci + + - name: "Run tests" + run: | + npm test + + # Action Repo: https://github.com/codecov/codecov-action + - name: "Upload coverage to codecov" + uses: codecov/codecov-action@v1 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e43d58a0..00000000 --- a/.travis.yml +++ /dev/null @@ -1,45 +0,0 @@ -# .travis.yml development advice: check your changes at -# https://config.travis-ci.com/explore -os: linux -dist: bionic -language: node_js -branches: - except: - - /^greenkeeper.*/ - -stages: - - name: test - if: type IN (push, pull_request, api) - - name: cron - if: type IN (cron, api) - -# Test against Long Term Support (LTS) releases in a "current", "active", and -# "maintenance" status: https://nodejs.org/en/about/releases/ -node_js: - - 14 - - 12 - - 10 -install: - - npm ci # install from package-lock.json -script: - - npm run lint - - travis_retry npm test -after_success: - - npm install -g codecov - - npm run codecov - -jobs: - include: - - name: deps:npm-audit - stage: cron - install: - - npm ci --production - script: - # This audit will fail for moderate/high/critical and exclude low - - npm audit --production --audit-level=moderate - after_success: - - echo "package-lock.json is considered at least moderately secure according to a npm audit." - after_failure: - - echo "package-lock.json contain a package with a moderate or worse vulnerability!" - - echo "Running 'npm audit fix --production' could fix the vulnerability. Let's try..." - - npm audit fix --production