Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
ocots committed Aug 25, 2024
1 parent 3741864 commit 9a7532a
Show file tree
Hide file tree
Showing 52 changed files with 8,890 additions and 6,515 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/Formatter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Formatter

# Modified from https://github.com/julia-actions/julia-format
on:
schedule:
- cron: '0 0 * * *'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/cache@v2
- name: Install JuliaFormatter and format
run: |
julia -e 'import Pkg; Pkg.add("JuliaFormatter")'
julia -e 'using JuliaFormatter; format(".")'
# https://github.com/marketplace/actions/create-pull-request
# https://github.com/peter-evans/create-pull-request#reference-example
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: ":robot: Format .jl files"
title: '[AUTO] JuliaFormatter.jl run'
branch: auto-juliaformatter-pr
delete-branch: true
labels: formatting, automated pr, no changelog
- name: Check outputs
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
28 changes: 17 additions & 11 deletions bench/Bench.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ function doBenchMarking(expr, f)

expr = MacroTools.striplines(expr)
println("Benchmarking $expr")
write(f, string(expr)*"\n")
write(f, string(expr) * "\n")
write(f, "```\n\n")
write(f, "```bash\n")
show(f, "text/plain", eval(quote $expr end))
show(f, "text/plain", eval(quote
$expr
end))
write(f, "\n```\n\n")

end
Expand All @@ -19,7 +21,7 @@ function bench(file::String)
println("Benching $file_name.jl\n")

file_name_output = joinpath("bench", file_name * ".md")
open(file_name_output, write=true, append=false) do f
open(file_name_output, write = true, append = false) do f
write(f, "# Benchmarks for $file_name.jl\n\n")
write(f, "```julia\n")
end
Expand All @@ -36,14 +38,16 @@ function bench(file::String)
println("Expr : ", expr)
#dump(expr)

open(file_name_output, write=true, append=true) do f
open(file_name_output, write = true, append = true) do f

if has_displayed
if has_displayed
write(f, "```julia\n")
has_displayed = false
end

if hasproperty(expr, :head) && expr.head == :macrocall && expr.args[1] == Symbol("@benchmark")

if hasproperty(expr, :head) &&
expr.head == :macrocall &&
expr.args[1] == Symbol("@benchmark")

has_displayed = true
doBenchMarking(expr, f)
Expand All @@ -52,21 +56,23 @@ function bench(file::String)
else

MLStyle.@match expr begin
:( display($benchname) ) => begin
:(display($benchname)) => begin
has_displayed = true
doBenchMarking(quote $benchname end, f)
doBenchMarking(quote
$benchname
end, f)
expr = :()
end
_ => begin
write(f, string(expr)*"\n")
write(f, string(expr) * "\n")
end
end

end

end

return expr
return expr

end

Expand Down
Loading

0 comments on commit 9a7532a

Please sign in to comment.