-
Notifications
You must be signed in to change notification settings - Fork 9
/
action.yml
86 lines (78 loc) · 2.94 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Invalidations
description: 'Evaluate number of invalidations'
inputs:
test_script:
description: 'Script to test for invalidations. Defaults to `import Package`'
required: false
default: ''
package_name:
description: 'Name of the package. By default, tries to auto-detect from the repo name.'
required: false
default: ''
type: string
max_invalidations:
description: 'Maximum number of invalidations to report. Defaults to `0` (no limit)'
required: false
default: '0'
type: number
outputs:
total:
description: "Total number of invalidations"
value: ${{ steps.invs.outputs.total }}
deps:
description: "Number of invalidations caused by deps"
value: ${{ steps.invs.outputs.deps }}
runs:
using: "composite"
steps:
- name: Get package name
id: info
run: |
REPONAME="${{ github.event.repository.name }}"
if [[ '${{ inputs.package_name }}' == '' ]]; then
PACKAGENAME=${REPONAME%.jl}
else
PACKAGENAME="${{ inputs.package_name }}"
fi
echo "packagename=$PACKAGENAME" >> $GITHUB_OUTPUT
if [[ '${{ inputs.test_script }}' == '' ]]; then
TESTSCRIPT="import ${PACKAGENAME}"
else
TESTSCRIPT="${{ inputs.test_script }}"
fi
echo "testscript=$TESTSCRIPT" >> $GITHUB_OUTPUT
shell: bash
- name: Install SnoopCompile tools
run: |
import Pkg;
pkgs = [
Pkg.PackageSpec(name = "SnoopCompile", version = "3", uuid = "aa65fe97-06da-5843-b5b1-d5d13cad87d2"),
Pkg.PackageSpec(name = "SnoopCompileCore", uuid = "e2b509da-e806-4183-be48-004708413034"),
Pkg.PackageSpec(name = "PrettyTables", uuid = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"),
]
Pkg.add(pkgs)
shell: julia --project {0}
- name: Load package on branch
id: invs
run: |
using SnoopCompileCore: @snoop_invalidations
invalidations = @snoop_invalidations begin ${{ steps.info.outputs.testscript }} end
using SnoopCompile: SnoopCompile, filtermod, invalidation_trees, uinvalidated
inv_owned = length(filtermod(${{ steps.info.outputs.packagename }}, invalidation_trees(invalidations)))
inv_total = length(uinvalidated(invalidations))
inv_deps = inv_total - inv_owned
@show inv_total, inv_deps
# Report invalidations summary:
import PrettyTables # needed for `report_invalidations` to be defined
SnoopCompile.report_invalidations(;
invalidations,
process_filename = x -> last(split(x, ".julia/packages/")),
n_rows = ${{ inputs.max_invalidations }},
)
# Set outputs
using Printf
open(ENV["GITHUB_OUTPUT"], "a") do io
println(io, @sprintf("total=%09d", inv_total))
println(io, @sprintf("deps=%09d", inv_deps))
end
shell: julia --color=yes --project=. {0}