diff --git a/.github/workflows/_test.yml b/.github/workflows/_test.yml new file mode 100644 index 0000000..668608d --- /dev/null +++ b/.github/workflows/_test.yml @@ -0,0 +1,23 @@ +name: Unit Tests +on: workflow_call +jobs: + unit-tests: + runs-on: '${{ matrix.os }}' + strategy: + matrix: + os: + - ubuntu-20.04 + node-version: + - 12.x + - 14.x + - 16.x + steps: + - uses: actions/checkout@v2 + - name: 'Install node.js ${{ matrix.node-version }}' + uses: actions/setup-node@v2-beta + with: + node-version: '${{ matrix.node-version }}' + - name: Run unit tests + run: | + npm install + npm run ci diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 0000000..58ca30c --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,6 @@ +name: Continuous Integration +on: pull_request +jobs: + unit-tests: + if: github.event.repository.name != 'pelias' + uses: ./.github/workflows/_test.yml diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 1b941bf..fc5664f 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -2,28 +2,10 @@ name: Continuous Integration on: push jobs: unit-tests: - runs-on: '${{ matrix.os }}' - strategy: - matrix: - os: - - ubuntu-20.04 - node-version: - - 12.x - - 14.x - - 16.x - steps: - - uses: actions/checkout@v2 - - name: 'Install node.js ${{ matrix.node-version }}' - uses: actions/setup-node@v2-beta - with: - node-version: '${{ matrix.node-version }}' - - name: Run unit tests - run: | - npm install - npm run ci + uses: ./.github/workflows/_test.yml npm-publish: needs: unit-tests - if: github.ref == 'refs/heads/master' && github.event_name == 'push' + if: github.ref == 'refs/heads/master' && needs.unit-tests.result == 'success' runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2