From 6642e304901d4f7c5adcdc441194e5f960ceec7e Mon Sep 17 00:00:00 2001 From: David Worms Date: Tue, 17 Oct 2023 17:20:16 +0200 Subject: [PATCH] ci: improve publish and pr workflows --- .github/workflows/publish.yml | 22 ++++++++++++---------- .github/workflows/pull-request.yml | 18 ++++++++++++++++++ .github/workflows/test.yml | 23 ----------------------- 3 files changed, 30 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/pull-request.yml delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 46f4966..233669e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,32 +1,34 @@ -# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions - -name: Publish +name: Test and Publish on: push: - tags: [ 'v*' ] + branches: [ master ] + pull_request: + branches: [ master ] jobs: test: runs-on: ubuntu-latest strategy: matrix: - node-version: [16.x, 18.x] + node-version: [16.x, 18.x, 20.x] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - run: yarn --frozen-lockfile - run: yarn run test publish: needs: [test] + if: startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v3 with: node-version: '16.x' registry-url: 'https://registry.npmjs.org' diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000..1d3526b --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,18 @@ +name: Test +on: pull_request +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [16.x, 18.x, 20.x] + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + - run: yarn --frozen-lockfile + - run: yarn run test diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index d36503f..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,23 +0,0 @@ -# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions - -name: Test -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] -jobs: - test: - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [16.x, 18.x] - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2 - with: - node-version: ${{ matrix.node-version }} - - run: yarn --frozen-lockfile - - run: yarn run test