Skip to content

Commit

Permalink
[CI] Run whitespace check on GitHub Actions and annotate source code (#…
Browse files Browse the repository at this point in the history
…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]>
  • Loading branch information
giordano and DilumAluthge authored Jul 28, 2024
1 parent 197295c commit 7de15ba
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/Whitespace.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Whitespace

permissions: {}

on:
push:
branches:
- master
pull_request:

jobs:
whitespace:
name: Check whitespace
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- name: Checkout the JuliaLang/julia repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
persist-credentials: false
- name: Check whitespace
run: |
contrib/check-whitespace.jl
8 changes: 8 additions & 0 deletions contrib/check-whitespace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const patterns = split("""
*Makefile
""")

const is_gha = something(tryparse(Bool, get(ENV, "GITHUB_ACTIONS", "false")), false)

# Note: `git ls-files` gives `/` as a path separator on Windows,
# so we just use `/` for all platforms.
allow_tabs(path) =
Expand Down Expand Up @@ -63,8 +65,14 @@ function check_whitespace()
for (path, lineno, msg) in sort!(collect(errors))
if lineno == 0
println(stderr, "$path -- $msg")
if is_gha
println(stdout, "::warning title=Whitespace check,file=", path, "::", msg)
end
else
println(stderr, "$path:$lineno -- $msg")
if is_gha
println(stdout, "::warning title=Whitespace check,file=", path, ",line=", lineno, "::", msg)
end
end
end
exit(1)
Expand Down

0 comments on commit 7de15ba

Please sign in to comment.