Skip to content

Commit 8be3322

Browse files
authored
chore: Added support for running jobs on label (#3082)
1 parent 48ed8cb commit 8be3322

File tree

3 files changed

+120
-102
lines changed

3 files changed

+120
-102
lines changed

.github/workflows/ci-workflow.yml

Lines changed: 108 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: Node Agent CI
33
on:
44
push:
55
pull_request:
6+
types:
7+
- labeled
68
workflow_dispatch:
79

810
env:
@@ -44,6 +46,7 @@ jobs:
4446
needs:
4547
- should_run
4648
if: github.event_name == 'workflow_dispatch' ||
49+
github.event.label.name == 'force-lint' ||
4750
(needs.should_run.outputs.javascript_changed == 'true' ||
4851
needs.should_run.outputs.deps_changed == 'true')
4952
runs-on: ubuntu-latest
@@ -53,15 +56,15 @@ jobs:
5356
node-version: [lts/*]
5457

5558
steps:
56-
- uses: actions/checkout@v4
57-
- name: Use Node.js ${{ matrix.node-version }}
58-
uses: actions/setup-node@v4
59-
with:
60-
node-version: ${{ matrix.node-version }}
61-
- name: Install Dependencies
62-
run: npm install
63-
- name: Run Linting
64-
run: npm run lint
59+
- uses: actions/checkout@v4
60+
- name: Use Node.js ${{ matrix.node-version }}
61+
uses: actions/setup-node@v4
62+
with:
63+
node-version: ${{ matrix.node-version }}
64+
- name: Install Dependencies
65+
run: npm install
66+
- name: Run Linting
67+
run: npm run lint
6568

6669
ci:
6770
needs:
@@ -77,20 +80,21 @@ jobs:
7780
node-version: [lts/*]
7881

7982
steps:
80-
- uses: actions/checkout@v4
81-
- name: Use Node.js ${{ matrix.node-version }}
82-
uses: actions/setup-node@v4
83-
with:
84-
node-version: ${{ matrix.node-version }}
85-
- name: Install Dependencies
86-
run: npm install
87-
- name: Run CI Script Unit Tests
88-
run: npm run unit:scripts
83+
- uses: actions/checkout@v4
84+
- name: Use Node.js ${{ matrix.node-version }}
85+
uses: actions/setup-node@v4
86+
with:
87+
node-version: ${{ matrix.node-version }}
88+
- name: Install Dependencies
89+
run: npm install
90+
- name: Run CI Script Unit Tests
91+
run: npm run unit:scripts
8992

9093
unit:
9194
needs:
9295
- should_run
9396
if: github.event_name == 'workflow_dispatch' ||
97+
github.event.label.name == 'force-unit' ||
9498
(needs.should_run.outputs.javascript_changed == 'true' ||
9599
needs.should_run.outputs.deps_changed == 'true')
96100
runs-on: ubuntu-latest
@@ -101,25 +105,26 @@ jobs:
101105
node-version: [18.x, 20.x, 22.x]
102106

103107
steps:
104-
- uses: actions/checkout@v4
105-
- name: Use Node.js ${{ matrix.node-version }}
106-
uses: actions/setup-node@v4
107-
with:
108-
node-version: ${{ matrix.node-version }}
109-
- name: Install Dependencies
110-
run: npm install
111-
- name: Run Unit Tests
112-
run: npm run unit
113-
- name: Archive Unit Test Coverage
114-
uses: actions/upload-artifact@v4
115-
with:
116-
name: unit-tests-${{ matrix.node-version }}
117-
path: ./coverage/unit/lcov.info
108+
- uses: actions/checkout@v4
109+
- name: Use Node.js ${{ matrix.node-version }}
110+
uses: actions/setup-node@v4
111+
with:
112+
node-version: ${{ matrix.node-version }}
113+
- name: Install Dependencies
114+
run: npm install
115+
- name: Run Unit Tests
116+
run: npm run unit
117+
- name: Archive Unit Test Coverage
118+
uses: actions/upload-artifact@v4
119+
with:
120+
name: unit-tests-${{ matrix.node-version }}
121+
path: ./coverage/unit/lcov.info
118122

119123
integration:
120124
needs:
121125
- should_run
122126
if: github.event_name == 'workflow_dispatch' ||
127+
github.event.label.name == 'force-integration' ||
123128
(needs.should_run.outputs.javascript_changed == 'true' ||
124129
needs.should_run.outputs.deps_changed == 'true')
125130
runs-on: ubuntu-latest
@@ -133,32 +138,33 @@ jobs:
133138
node-version: [18.x, 20.x, 22.x]
134139

135140
steps:
136-
- uses: actions/checkout@v4
137-
- name: Use Node.js ${{ matrix.node-version }}
138-
uses: actions/setup-node@v4
139-
with:
140-
node-version: ${{ matrix.node-version }}
141-
- name: Install Dependencies
142-
run: npm install
143-
- name: Run Integration Tests
144-
run: npm run integration
145-
- name: Run ESM Integration Tests
146-
run: npm run integration:esm
147-
- name: Archive Integration Test Coverage
148-
uses: actions/upload-artifact@v4
149-
with:
150-
name: integration-tests-cjs-${{ matrix.node-version }}
151-
path: ./coverage/integration/lcov.info
152-
- name: Archive Integration (ESM) Test Coverage
153-
uses: actions/upload-artifact@v4
154-
with:
155-
name: integration-tests-esm-${{ matrix.node-version }}
156-
path: ./coverage/integration-esm/lcov.info
141+
- uses: actions/checkout@v4
142+
- name: Use Node.js ${{ matrix.node-version }}
143+
uses: actions/setup-node@v4
144+
with:
145+
node-version: ${{ matrix.node-version }}
146+
- name: Install Dependencies
147+
run: npm install
148+
- name: Run Integration Tests
149+
run: npm run integration
150+
- name: Run ESM Integration Tests
151+
run: npm run integration:esm
152+
- name: Archive Integration Test Coverage
153+
uses: actions/upload-artifact@v4
154+
with:
155+
name: integration-tests-cjs-${{ matrix.node-version }}
156+
path: ./coverage/integration/lcov.info
157+
- name: Archive Integration (ESM) Test Coverage
158+
uses: actions/upload-artifact@v4
159+
with:
160+
name: integration-tests-esm-${{ matrix.node-version }}
161+
path: ./coverage/integration-esm/lcov.info
157162

158163
versioned-internal:
159164
needs:
160165
- should_run
161166
if: github.event_name == 'workflow_dispatch' ||
167+
github.event.label.name == 'force-versioned' ||
162168
(needs.should_run.outputs.javascript_changed == 'true' ||
163169
needs.should_run.outputs.deps_changed == 'true')
164170
runs-on: ${{ github.ref == 'refs/heads/main' && vars.NR_RUNNER || 'ubuntu-latest' }}
@@ -169,47 +175,48 @@ jobs:
169175
node-version: [18.x, 20.x, 22.x]
170176

171177
steps:
172-
- uses: actions/checkout@v4
173-
- name: Use Node.js ${{ matrix.node-version }}
174-
uses: actions/setup-node@v4
175-
with:
176-
node-version: ${{ matrix.node-version }}
177-
- name: Install Dependencies
178-
run: npm install
179-
- name: Run Docker Services
180-
run: npm run services
181-
- name: Run Versioned Tests
182-
run: TEST_CHILD_TIMEOUT=600000 npm run versioned:internal
183-
env:
184-
VERSIONED_MODE: ${{ github.ref == 'refs/heads/main' && '--minor' || '--major' }}
185-
# Run more jobs when using larger runner, otherwise 2 per CPU seems to be the sweet spot in GHA default runners(July 2022)
186-
JOBS: ${{ github.ref == 'refs/heads/main' && vars.NR_RUNNER && 16 || 4 }}
187-
C8_REPORTER: lcovonly
188-
- name: Archive Versioned Test Coverage
189-
uses: actions/upload-artifact@v4
190-
with:
191-
name: versioned-tests-${{ matrix.node-version }}
192-
path: ./coverage/versioned/lcov.info
193-
- name: Collect docker logs on failure
194-
if: failure()
195-
uses: jwalton/gh-docker-logs@2741064ab9d7af54b0b1ffb6076cf64c16f0220e
196-
with:
197-
dest: ./logs-${{ matrix.node-version }}
198-
- name: Tar logs
199-
if: failure()
200-
run: tar cvzf ./logs-${{ matrix.node-version }}.tgz ./logs-${{ matrix.node-version }}
201-
- name: Upload logs to GitHub
202-
if: failure()
203-
uses: actions/upload-artifact@v4
204-
with:
205-
name: logs-${{ matrix.node-version }}.tgz
206-
path: ./logs-${{ matrix.node-version }}.tgz
178+
- uses: actions/checkout@v4
179+
- name: Use Node.js ${{ matrix.node-version }}
180+
uses: actions/setup-node@v4
181+
with:
182+
node-version: ${{ matrix.node-version }}
183+
- name: Install Dependencies
184+
run: npm install
185+
- name: Run Docker Services
186+
run: npm run services
187+
- name: Run Versioned Tests
188+
run: TEST_CHILD_TIMEOUT=600000 npm run versioned:internal
189+
env:
190+
VERSIONED_MODE: ${{ github.ref == 'refs/heads/main' && '--minor' || '--major' }}
191+
# Run more jobs when using larger runner, otherwise 2 per CPU seems to be the sweet spot in GHA default runners(July 2022)
192+
JOBS: ${{ github.ref == 'refs/heads/main' && vars.NR_RUNNER && 16 || 4 }}
193+
C8_REPORTER: lcovonly
194+
- name: Archive Versioned Test Coverage
195+
uses: actions/upload-artifact@v4
196+
with:
197+
name: versioned-tests-${{ matrix.node-version }}
198+
path: ./coverage/versioned/lcov.info
199+
- name: Collect docker logs on failure
200+
if: failure()
201+
uses: jwalton/gh-docker-logs@2741064ab9d7af54b0b1ffb6076cf64c16f0220e
202+
with:
203+
dest: ./logs-${{ matrix.node-version }}
204+
- name: Tar logs
205+
if: failure()
206+
run: tar cvzf ./logs-${{ matrix.node-version }}.tgz ./logs-${{ matrix.node-version }}
207+
- name: Upload logs to GitHub
208+
if: failure()
209+
uses: actions/upload-artifact@v4
210+
with:
211+
name: logs-${{ matrix.node-version }}.tgz
212+
path: ./logs-${{ matrix.node-version }}.tgz
207213

208214
# There is no coverage for external as that's tracked in their respective repos
209215
versioned-external:
210216
needs:
211217
- should_run
212218
if: github.event_name == 'workflow_dispatch' ||
219+
github.event.label.name == 'force-versioned' ||
213220
(needs.should_run.outputs.javascript_changed == 'true' ||
214221
needs.should_run.outputs.deps_changed == 'true')
215222
runs-on: ${{ github.ref == 'refs/heads/main' && vars.NR_RUNNER || 'ubuntu-latest' }}
@@ -220,19 +227,19 @@ jobs:
220227
node-version: [18.x, 20.x, 22.x]
221228

222229
steps:
223-
- uses: actions/checkout@v4
224-
- name: Use Node.js ${{ matrix.node-version }}
225-
uses: actions/setup-node@v4
226-
with:
227-
node-version: ${{ matrix.node-version }}
228-
- name: Install Dependencies
229-
run: npm install
230-
- name: Run Versioned Tests
231-
run: TEST_CHILD_TIMEOUT=600000 npm run versioned:external
232-
env:
233-
VERSIONED_MODE: ${{ github.ref == 'refs/heads/main' && '--minor' || '--major' }}
234-
# Run more jobs when using larger runner, otherwise 2 per CPU seems to be the sweet spot in GHA default runners(July 2022)
235-
JOBS: ${{ github.ref == 'refs/heads/main' && vars.NR_RUNNER && 16 || 4 }}
230+
- uses: actions/checkout@v4
231+
- name: Use Node.js ${{ matrix.node-version }}
232+
uses: actions/setup-node@v4
233+
with:
234+
node-version: ${{ matrix.node-version }}
235+
- name: Install Dependencies
236+
run: npm install
237+
- name: Run Versioned Tests
238+
run: TEST_CHILD_TIMEOUT=600000 npm run versioned:external
239+
env:
240+
VERSIONED_MODE: ${{ github.ref == 'refs/heads/main' && '--minor' || '--major' }}
241+
# Run more jobs when using larger runner, otherwise 2 per CPU seems to be the sweet spot in GHA default runners(July 2022)
242+
JOBS: ${{ github.ref == 'refs/heads/main' && vars.NR_RUNNER && 16 || 4 }}
236243

237244
codecov:
238245
needs: [unit, integration, versioned-internal]

.github/workflows/smoke-test-workflow.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
name: Server Smoke Tests
22

33
on:
4-
# Run on pushes to any branch. Not triggered for forked repo PRs.
4+
pull_request_target:
5+
types:
6+
- labeled
7+
# Run on pushes to any branch. Not triggered for forked repo PRs.
58
push:
69
schedule:
710
# Run once a day at 9AM PDT (16 UTC) on week days (1-5).
@@ -12,6 +15,11 @@ on:
1215

1316
jobs:
1417
smoke:
18+
if: github.event_name == 'workflow_dispatch' ||
19+
github.event_name == 'push' ||
20+
github.event_name == 'schedule' ||
21+
github.event.label.name == 'force-smoke'
22+
permissions: read-all
1523
runs-on: ubuntu-latest
1624

1725
strategy:

.github/workflows/versioned-security-agent.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ on:
2424
pull_request:
2525
branches:
2626
- main
27+
types:
28+
- labeled
2729

2830
env:
2931
# Enable versioned runner quiet mode to make CI output easier to read:
@@ -56,6 +58,7 @@ jobs:
5658
needs: [should_run]
5759
if: github.event_name == 'workflow_dispatch' ||
5860
github.event_name == 'schedule' ||
61+
github.event.label.name == 'force-security' ||
5962
needs.should_run.outputs.sec_agent_did_change == 'true'
6063

6164
runs-on: ${{ vars.NR_RUNNER || 'ubuntu-latest' }}

0 commit comments

Comments
 (0)