Skip to content

Commit 85ccf13

Browse files
askalt0x501D
authored andcommitted
ci: do not run twice on push and pull request
We want to run on external PRs, but not on our own internal PRs as they'll be run by the push to the branch. The main trick is described here: Dart-Code/Dart-Code#2375 Also we want to run it always for manually triggered workflows.
1 parent f068b6f commit 85ccf13

File tree

1 file changed

+90
-10
lines changed

1 file changed

+90
-10
lines changed

.github/workflows/rust.yml

+90-10
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ jobs:
4242
# Check crate compiles
4343
linux-build-lib:
4444
name: cargo check
45+
if: (github.event_name == 'push') ||
46+
(github.event_name == 'pull_request' &&
47+
github.event.pull_request.head.repo.full_name != github.repository) ||
48+
(github.event_name == 'workflow_dispatch')
4549
runs-on: ubuntu-latest
4650
container:
4751
image: amd64/rust
@@ -133,6 +137,10 @@ jobs:
133137
# Run tests
134138
linux-test:
135139
name: cargo test (amd64)
140+
if: (github.event_name == 'push') ||
141+
(github.event_name == 'pull_request' &&
142+
github.event.pull_request.head.repo.full_name != github.repository) ||
143+
(github.event_name == 'workflow_dispatch')
136144
needs: [ linux-build-lib ]
137145
runs-on: ubuntu-latest
138146
container:
@@ -144,14 +152,18 @@ jobs:
144152
- name: Setup Rust toolchain
145153
uses: ./.github/actions/setup-builder
146154
with:
147-
rust-version: stable
155+
rust-version: stable
148156
- name: Run tests (excluding doctests)
149157
run: cargo test --lib --tests --bins --features avro,json,backtrace
150158
- name: Verify Working Directory Clean
151159
run: git diff --exit-code
152160

153161
linux-test-datafusion-cli:
154162
name: cargo test datafusion-cli (amd64)
163+
if: (github.event_name == 'push') ||
164+
(github.event_name == 'pull_request' &&
165+
github.event.pull_request.head.repo.full_name != github.repository) ||
166+
(github.event_name == 'workflow_dispatch')
155167
needs: [ linux-build-lib ]
156168
runs-on: ubuntu-latest
157169
container:
@@ -173,6 +185,10 @@ jobs:
173185

174186
linux-test-example:
175187
name: cargo examples (amd64)
188+
if: (github.event_name == 'push') ||
189+
(github.event_name == 'pull_request' &&
190+
github.event.pull_request.head.repo.full_name != github.repository) ||
191+
(github.event_name == 'workflow_dispatch')
176192
needs: [ linux-build-lib ]
177193
runs-on: ubuntu-latest
178194
container:
@@ -199,6 +215,10 @@ jobs:
199215
# Run `cargo test doc` (test documentation examples)
200216
linux-test-doc:
201217
name: cargo test doc (amd64)
218+
if: (github.event_name == 'push') ||
219+
(github.event_name == 'pull_request' &&
220+
github.event.pull_request.head.repo.full_name != github.repository) ||
221+
(github.event_name == 'workflow_dispatch')
202222
needs: [ linux-build-lib ]
203223
runs-on: ubuntu-latest
204224
container:
@@ -222,6 +242,10 @@ jobs:
222242
# Run `cargo doc` to ensure the rustdoc is clean
223243
linux-rustdoc:
224244
name: cargo doc
245+
if: (github.event_name == 'push') ||
246+
(github.event_name == 'pull_request' &&
247+
github.event.pull_request.head.repo.full_name != github.repository) ||
248+
(github.event_name == 'workflow_dispatch')
225249
needs: [ linux-build-lib ]
226250
runs-on: ubuntu-latest
227251
container:
@@ -237,6 +261,10 @@ jobs:
237261

238262
linux-wasm-pack:
239263
name: build with wasm-pack
264+
if: (github.event_name == 'push') ||
265+
(github.event_name == 'pull_request' &&
266+
github.event.pull_request.head.repo.full_name != github.repository) ||
267+
(github.event_name == 'workflow_dispatch')
240268
runs-on: ubuntu-latest
241269
container:
242270
image: amd64/rust
@@ -255,6 +283,10 @@ jobs:
255283
# verify that the benchmark queries return the correct results
256284
verify-benchmark-results:
257285
name: verify benchmark results (amd64)
286+
if: (github.event_name == 'push') ||
287+
(github.event_name == 'pull_request' &&
288+
github.event.pull_request.head.repo.full_name != github.repository) ||
289+
(github.event_name == 'workflow_dispatch')
258290
needs: [ linux-build-lib ]
259291
runs-on: ubuntu-latest
260292
container:
@@ -286,6 +318,10 @@ jobs:
286318

287319
sqllogictest-postgres:
288320
name: "Run sqllogictest with Postgres runner"
321+
if: (github.event_name == 'push') ||
322+
(github.event_name == 'pull_request' &&
323+
github.event.pull_request.head.repo.full_name != github.repository) ||
324+
(github.event_name == 'workflow_dispatch')
289325
needs: [ linux-build-lib ]
290326
runs-on: ubuntu-latest
291327
services:
@@ -317,6 +353,10 @@ jobs:
317353

318354
windows:
319355
name: cargo test (win64)
356+
if: (github.event_name == 'push') ||
357+
(github.event_name == 'pull_request' &&
358+
github.event.pull_request.head.repo.full_name != github.repository) ||
359+
(github.event_name == 'workflow_dispatch')
320360
runs-on: windows-latest
321361
steps:
322362
- uses: actions/checkout@v4
@@ -334,22 +374,30 @@ jobs:
334374
335375
macos:
336376
name: cargo test (macos)
377+
if: (github.event_name == 'push') ||
378+
(github.event_name == 'pull_request' &&
379+
github.event.pull_request.head.repo.full_name != github.repository) ||
380+
(github.event_name == 'workflow_dispatch')
337381
runs-on: macos-latest
338382
steps:
339383
- uses: actions/checkout@v4
340384
with:
341-
submodules: true
385+
submodules: true
342386
- name: Setup Rust toolchain
343-
uses: ./.github/actions/setup-macos-builder
387+
uses: ./.github/actions/setup-macos-builder
344388
- name: Run tests (excluding doctests)
345389
shell: bash
346390
run: |
347391
cargo test --lib --tests --bins --features avro,json,backtrace
348392
cd datafusion-cli
349-
cargo test --lib --tests --bins --all-features
393+
cargo test --lib --tests --bins --all-features
350394
351395
macos-aarch64:
352396
name: cargo test (macos-aarch64)
397+
if: (github.event_name == 'push') ||
398+
(github.event_name == 'pull_request' &&
399+
github.event.pull_request.head.repo.full_name != github.repository) ||
400+
(github.event_name == 'workflow_dispatch')
353401
runs-on: macos-14
354402
steps:
355403
- uses: actions/checkout@v4
@@ -366,6 +414,10 @@ jobs:
366414
367415
test-datafusion-pyarrow:
368416
name: cargo test pyarrow (amd64)
417+
if: (github.event_name == 'push') ||
418+
(github.event_name == 'pull_request' &&
419+
github.event.pull_request.head.repo.full_name != github.repository) ||
420+
(github.event_name == 'workflow_dispatch')
369421
needs: [ linux-build-lib ]
370422
runs-on: ubuntu-20.04
371423
container:
@@ -390,6 +442,10 @@ jobs:
390442

391443
vendor:
392444
name: Verify Vendored Code
445+
if: (github.event_name == 'push') ||
446+
(github.event_name == 'pull_request' &&
447+
github.event.pull_request.head.repo.full_name != github.repository) ||
448+
(github.event_name == 'workflow_dispatch')
393449
runs-on: ubuntu-latest
394450
container:
395451
image: amd64/rust
@@ -405,6 +461,10 @@ jobs:
405461

406462
check-fmt:
407463
name: Check cargo fmt
464+
if: (github.event_name == 'push') ||
465+
(github.event_name == 'pull_request' &&
466+
github.event.pull_request.head.repo.full_name != github.repository) ||
467+
(github.event_name == 'workflow_dispatch')
408468
runs-on: ubuntu-latest
409469
container:
410470
image: amd64/rust
@@ -463,6 +523,10 @@ jobs:
463523

464524
clippy:
465525
name: clippy
526+
if: (github.event_name == 'push') ||
527+
(github.event_name == 'pull_request' &&
528+
github.event.pull_request.head.repo.full_name != github.repository) ||
529+
(github.event_name == 'workflow_dispatch')
466530
needs: [ linux-build-lib ]
467531
runs-on: ubuntu-latest
468532
container:
@@ -483,6 +547,10 @@ jobs:
483547
# Check answers are correct when hash values collide
484548
hash-collisions:
485549
name: cargo test hash collisions (amd64)
550+
if: (github.event_name == 'push') ||
551+
(github.event_name == 'pull_request' &&
552+
github.event.pull_request.head.repo.full_name != github.repository) ||
553+
(github.event_name == 'workflow_dispatch')
486554
needs: [ linux-build-lib ]
487555
runs-on: ubuntu-latest
488556
container:
@@ -502,6 +570,10 @@ jobs:
502570
503571
cargo-toml-formatting-checks:
504572
name: check Cargo.toml formatting
573+
if: (github.event_name == 'push') ||
574+
(github.event_name == 'pull_request' &&
575+
github.event.pull_request.head.repo.full_name != github.repository) ||
576+
(github.event_name == 'workflow_dispatch')
505577
needs: [ linux-build-lib ]
506578
runs-on: ubuntu-latest
507579
container:
@@ -522,6 +594,10 @@ jobs:
522594

523595
config-docs-check:
524596
name: check configs.md is up-to-date
597+
if: (github.event_name == 'push') ||
598+
(github.event_name == 'pull_request' &&
599+
github.event.pull_request.head.repo.full_name != github.repository) ||
600+
(github.event_name == 'workflow_dispatch')
525601
needs: [ linux-build-lib ]
526602
runs-on: ubuntu-latest
527603
container:
@@ -550,6 +626,10 @@ jobs:
550626
# - datafusion-cli
551627
msrv:
552628
name: Verify MSRV (Min Supported Rust Version)
629+
if: (github.event_name == 'push') ||
630+
(github.event_name == 'pull_request' &&
631+
github.event.pull_request.head.repo.full_name != github.repository) ||
632+
(github.event_name == 'workflow_dispatch')
553633
runs-on: ubuntu-latest
554634
container:
555635
image: amd64/rust
@@ -567,19 +647,19 @@ jobs:
567647
# (Min Supported Rust Version) than the one specified in the
568648
# `rust-version` key of `Cargo.toml`.
569649
#
570-
# To reproduce:
571-
# 1. Install the version of Rust that is failing. Example:
650+
# To reproduce:
651+
# 1. Install the version of Rust that is failing. Example:
572652
# rustup install 1.76.0
573653
# 2. Run the command that failed with that version. Example:
574654
# cargo +1.76.0 check -p datafusion
575-
#
655+
#
576656
# To resolve, either:
577-
# 1. Change your code to use older Rust features,
657+
# 1. Change your code to use older Rust features,
578658
# 2. Revert dependency update
579659
# 3. Update the MSRV version in `Cargo.toml`
580660
#
581661
# Please see the DataFusion Rust Version Compatibility Policy before
582-
# updating Cargo.toml. You may have to update the code instead.
662+
# updating Cargo.toml. You may have to update the code instead.
583663
# https://github.com/apache/datafusion/blob/main/README.md#rust-version-compatibility-policy
584664
cargo msrv --output-format json --log-target stdout verify
585665
- name: Check datafusion-substrait
@@ -590,4 +670,4 @@ jobs:
590670
run: cargo msrv --output-format json --log-target stdout verify
591671
- name: Check datafusion-cli
592672
working-directory: datafusion-cli
593-
run: cargo msrv --output-format json --log-target stdout verify
673+
run: cargo msrv --output-format json --log-target stdout verify

0 commit comments

Comments
 (0)