Skip to content

Commit 4bb0810

Browse files
committed
major: postprocess
1 parent ed8fed9 commit 4bb0810

File tree

5 files changed

+60
-24
lines changed

5 files changed

+60
-24
lines changed

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ version = "1.7.2"
66
[deps]
77
FilePathsBase = "48062228-2e41-5def-b9a4-89aafe57970f"
88
GitHubActions = "6b79fd1a-b13a-48ab-b6b0-aaee1fee41df"
9+
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
910
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
1011
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
1112
SnoopCompile = "aa65fe97-06da-5843-b5b1-d5d13cad87d2"
@@ -20,9 +21,9 @@ YAML = "0.4"
2021
julia = "1"
2122

2223
[extras]
24+
Example = "7876af07-990d-54b4-ab0e-23690620f79a"
2325
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
2426
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
25-
Example = "7876af07-990d-54b4-ab0e-23690620f79a"
2627

2728
[targets]
2829
test = ["Pkg", "Test", "Example"]

docs/src/index.md

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -162,17 +162,8 @@ jobs:
162162
- uses: actions/checkout@v2
163163
- name: Download all
164164
uses: actions/download-artifact@v2
165-
- name: Move the content of the directory to the root
166-
run: |
167-
rsync -a artifact/* ./
168-
rm -d -r artifact
169-
- name: Discard unrelated changes
170-
run: |
171-
test -f 'Project.toml' && git checkout -- 'Project.toml'
172-
git ls-files 'Manifest.toml' | grep . && git checkout -- 'Manifest.toml'
173-
(git diff -w --no-color || git apply --cached --ignore-whitespace && git checkout -- . && git reset && git add -p) || echo done
174-
- name: Format precompile_includer.jl
175-
run: julia -e 'using Pkg; Pkg.add("JuliaFormatter"); using JuliaFormatter; format_file("src/precompile_includer.jl")'
165+
- name: SnoopCompileBot postprocess
166+
run: julia -e 'using Pkg; Pkg.add("SnoopCompileBot"); using SnoopCompileBot; SnoopCompileBot.postprocess();'
176167
- name: Create Pull Request
177168
# https://github.com/marketplace/actions/create-pull-request
178169
uses: peter-evans/create-pull-request@v2

src/SnoopCompileBot.jl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,25 @@ function BotConfig(
140140
append!(exclusions, blacklist)
141141
end
142142

143+
package_root_path = dirname(dirname(package_path))
144+
145+
# Error for workflow file
146+
yml_path_error = "SnoopCompile.yml"
147+
try
148+
yml_path_error = searchdirsboth([ pwd(), package_root_path, "$package_root_path/.github/workflows/"], yml_path_error)
149+
catch
150+
# file not found
151+
finally
152+
if isfile(yml_path_error) && !occursin("SnoopCompileBot.postprocess()", Base.read(yml_path_error, String))
153+
error("""Please update the `SnoopCompile.yml` based on the new API:
154+
https://aminya.github.io/SnoopCompileBot.jl/dev/#Configure-the-bot-to-run-with-a-GitHub-Action-file-1
155+
""")
156+
end
157+
end
158+
159+
143160
# Parse os and version from the yaml file
144161
if !isnothing(yml_path)
145-
package_root_path = dirname(dirname(package_path))
146162
yml_path = searchdirsboth([ pwd(), package_root_path, "$package_root_path/.github/workflows/"], yml_path)
147163
if !isfile(yml_path)
148164
error("$yml_path not found")
@@ -177,6 +193,7 @@ include("precompile_activation.jl")
177193
include("snoop_bot.jl")
178194
include("snoop_bench.jl")
179195
include("deprecations.jl")
196+
include("postprocess.jl")
180197

181198

182199
# Using GitHubActions logger in CI

src/postprocess.jl

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using JuliaFormatter
2+
function postprocess()
3+
4+
if ENV["CI"] || ENV["CI"] !== "" || !isempty(ENV["CI"]) || !isnothing(ENV["CI"])
5+
6+
# TODO rewrite using Julia functions
7+
8+
# Move the content of the directory to the root
9+
run(`rsync -a artifact/\* ./`)
10+
run(`rm -d -r artifact`)
11+
12+
# Discard unrelated changes
13+
run(`test -f 'Project.toml' \&\& git checkout -- 'Project.toml'`)
14+
run(`git ls-files 'Manifest.toml' \| grep . \&\& git checkout -- 'Manifest.toml'`)
15+
16+
# BUG causes issues
17+
# run(`(git diff -w --no-color || git apply --cached --ignore-whitespace && git checkout -- . && git reset && git add -p) || echo done`)
18+
19+
# Format precompile_includer.jl
20+
format_file("./src/precompile_includer.jl")
21+
22+
# TODO
23+
# - name: Create Pull Request
24+
# # https://github.com/marketplace/actions/create-pull-request
25+
# uses: peter-evans/create-pull-request@v2
26+
# with:
27+
# token: ${{ secrets.GITHUB_TOKEN }}
28+
# commit-message: Update precompile_*.jl file
29+
# committer: YOUR NAME <yourEmail@something.com> # NOTE: change `committer` to your name and your email.
30+
# title: "[AUTO] Update precompiles"
31+
# labels: SnoopCompile
32+
# branch: "SnoopCompile_AutoPR"
33+
34+
end
35+
36+
end

test/TestPackage5.jl/.github/workflows/SnoopCompile.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,8 @@ jobs:
5151
- uses: actions/checkout@v2
5252
- name: Download all
5353
uses: actions/download-artifact@v2
54-
- name: Move the content of the directory to the root
55-
run: |
56-
rsync -a artifact/* ./
57-
rm -d -r artifact
58-
- name: Discard unrelated changes
59-
run: |
60-
test -f 'Project.toml' && git checkout -- 'Project.toml'
61-
git ls-files 'Manifest.toml' | grep . && git checkout -- 'Manifest.toml'
62-
(git diff -w --no-color || git apply --cached --ignore-whitespace && git checkout -- . && git reset && git add -p) || echo done
63-
- name: Format precompile_includer.jl
64-
run: julia -e 'using Pkg; Pkg.add("JuliaFormatter"); using JuliaFormatter; format_file("src/precompile_includer.jl")'
54+
- name: SnoopCompileBot postprocess
55+
run: julia -e 'using Pkg; Pkg.add("SnoopCompileBot"); using SnoopCompileBot; SnoopCompileBot.postprocess();'
6556
- name: Create Pull Request
6657
# https://github.com/marketplace/actions/create-pull-request
6758
uses: peter-evans/create-pull-request@v2

0 commit comments

Comments
 (0)