Skip to content

Commit 7de15ba

Browse files
[CI] Run whitespace check on GitHub Actions and annotate source code (#55281)
There some advantages in running this on GitHub Actions (GHA) rather than Buildkite (BK): * on GHA this task takes ~10 seconds, on BK it takes ~1 minute (job setup on BK takes way too long) * since for this task we can use GitHub-hosted runners (which come with Julia preinstalled), we can spare BK runners from running this job. Admittedly it's very marginal saving, but better than nothing when the queue gets long * using GHA allows us to easily add source code annotations in PR overviews, which make it easier to quickly spot the line to fix from the GitHub web interface. This would be doable also on BK, but slightly more annoying. As [an example](giordano@a7725e4): ![image](https://github.com/user-attachments/assets/8a459a61-8953-4590-980e-ff156a62701f) If this PR is accepted, I'll remove the corresponding job from BK. --------- Co-authored-by: Dilum Aluthge <[email protected]>
1 parent 197295c commit 7de15ba

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

.github/workflows/Whitespace.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Whitespace
2+
3+
permissions: {}
4+
5+
on:
6+
push:
7+
branches:
8+
- master
9+
pull_request:
10+
11+
jobs:
12+
whitespace:
13+
name: Check whitespace
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 2
16+
steps:
17+
- name: Checkout the JuliaLang/julia repository
18+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
19+
with:
20+
persist-credentials: false
21+
- name: Check whitespace
22+
run: |
23+
contrib/check-whitespace.jl

contrib/check-whitespace.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ const patterns = split("""
1818
*Makefile
1919
""")
2020

21+
const is_gha = something(tryparse(Bool, get(ENV, "GITHUB_ACTIONS", "false")), false)
22+
2123
# Note: `git ls-files` gives `/` as a path separator on Windows,
2224
# so we just use `/` for all platforms.
2325
allow_tabs(path) =
@@ -63,8 +65,14 @@ function check_whitespace()
6365
for (path, lineno, msg) in sort!(collect(errors))
6466
if lineno == 0
6567
println(stderr, "$path -- $msg")
68+
if is_gha
69+
println(stdout, "::warning title=Whitespace check,file=", path, "::", msg)
70+
end
6671
else
6772
println(stderr, "$path:$lineno -- $msg")
73+
if is_gha
74+
println(stdout, "::warning title=Whitespace check,file=", path, ",line=", lineno, "::", msg)
75+
end
6876
end
6977
end
7078
exit(1)

0 commit comments

Comments
 (0)