Skip to content

Commit

Permalink
fix: disable running CI for releases
Browse files Browse the repository at this point in the history
There are a few parts to this:

1) First, disable running on pushes. This is because pushes don't have
context when they come from a pull request. In particular, pushes
don't have the branch name the pull request came from.

2) Then, disable running if the branch name starts with release.

3) In the same condition check, enable runs only for branches that are
closed via a merge. We don't want to trigger CI for a PR that is
closed because we decided to abandon the idea.
  • Loading branch information
Jordi Gutiérrez Hermoso committed Jun 12, 2023
1 parent 3e926e5 commit 0ac9131
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
name: Node Agent CI

on: [push, pull_request, workflow_dispatch]
on:
workflow_dispatch: {}
pull_request:
types:
# Created PR
- opened
# Added commits to the PR
- synchronize
# Sometimes we need to do this to trigger a run
- reopened
# Merged the PR (check below ensures non-merge closing events don't trigger)
- closed

jobs:
lint:
if: ${{ !startsWith(github.head_ref, 'release/v') && (github.event.pull_request.merged == true || github.event.action != 'closed') }}
runs-on: ubuntu-latest

strategy:
Expand All @@ -24,6 +36,7 @@ jobs:
run: npm run lint:lockfile

ci:
if: ${{ !startsWith(github.head_ref, 'release/v') && (github.event.pull_request.merged == true || github.event.action != 'closed') }}
runs-on: ubuntu-latest

strategy:
Expand All @@ -42,6 +55,7 @@ jobs:
run: npm run unit:scripts

unit:
if: ${{ !startsWith(github.head_ref, 'release/v') && (github.event.pull_request.merged == true || github.event.action != 'closed') }}
runs-on: ubuntu-latest

strategy:
Expand Down Expand Up @@ -72,6 +86,7 @@ jobs:
path: ./coverage/esm-unit/lcov.info

integration:
if: ${{ !startsWith(github.head_ref, 'release/v') && (github.event.pull_request.merged == true || github.event.action != 'closed') }}
runs-on: ubuntu-latest

strategy:
Expand All @@ -97,6 +112,7 @@ jobs:
path: ./coverage/integration/lcov.info

versioned:
if: ${{ !startsWith(github.head_ref, 'release/v') && (github.event.pull_request.merged == true || github.event.action != 'closed') }}
runs-on: ubuntu-latest

strategy:
Expand All @@ -117,14 +133,14 @@ jobs:
if: ${{ matrix.node-version == '14.x' }}
run: TEST_CHILD_TIMEOUT=600000 npm run versioned:npm6
env:
VERSIONED_MODE: ${{ github.ref == 'refs/heads/main' && '--minor' || '--major' }}
VERSIONED_MODE: ${{ github.event.pull_request.merged == true && '--minor' || '--major' }}
JOBS: 4 # 2 per CPU seems to be the sweet spot in GHA (July 2022)
C8_REPORTER: lcovonly
- name: Run Versioned Tests (npm v7 / Node 16+)
if: ${{ matrix.node-version != '14.x' }}
run: TEST_CHILD_TIMEOUT=600000 npm run versioned:npm7
env:
VERSIONED_MODE: ${{ github.ref == 'refs/heads/main' && '--minor' || '--major' }}
VERSIONED_MODE: ${{ github.event.pull_request.merged == true && '--minor' || '--major' }}
JOBS: 4 # 2 per CPU seems to be the sweet spot in GHA (July 2022)
C8_REPORTER: lcovonly
- name: Archive Versioned Test Coverage
Expand All @@ -134,6 +150,7 @@ jobs:
path: ./coverage/versioned/lcov.info

codecov:
if: ${{ !startsWith(github.head_ref, 'release/v') && (github.event.pull_request.merged == true || github.event.action != 'closed') }}
needs: [unit, integration, versioned]
runs-on: ubuntu-latest

Expand Down

0 comments on commit 0ac9131

Please sign in to comment.