Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Run whitespace check on GitHub Actions and annotate source code #55281

Merged
merged 3 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: {}
DilumAluthge marked this conversation as resolved.
Show resolved Hide resolved

on:
push:
branches:
- master
pull_request:

jobs:
typos-check:
giordano marked this conversation as resolved.
Show resolved Hide resolved
name: Check whitespace
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- name: Checkout the JuliaLang/julia repository
uses: actions/checkout@v4
giordano marked this conversation as resolved.
Show resolved Hide resolved
giordano marked this conversation as resolved.
Show resolved Hide resolved
with:
persist-credentials: false
- name: Check whitespace
run: |
contrib/check-whitespace.jl
DilumAluthge marked this conversation as resolved.
Show resolved Hide resolved
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