-
Notifications
You must be signed in to change notification settings - Fork 5
165 lines (153 loc) · 5.4 KB
/
Breakage.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# Ref: https://securitylab.github.com/research/github-actions-preventing-pwn-requests
name: Breakage
# read-only repo token
# no access to secrets
on:
pull_request:
jobs:
# Build dynamically the matrix on which the "break" job will run.
# The matrix contains the packages that depend on ${{ env.pkg }}.
# Job "setup_matrix" outputs variable "matrix", which is in turn
# the output of the "getmatrix" step.
# The contents of "matrix" is a JSON description of a matrix used
# in the next step. It has the form
# {
# "pkg": [
# "PROPACK",
# "LLSModels",
# "FletcherPenaltySolver"
# ]
# }
setup_matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.getmatrix.outputs.matrix }}
env:
pkg: ${{ github.event.repository.name }}
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: 1
arch: x64
- id: getmatrix
run: |
julia -e 'using Pkg; Pkg.Registry.add(RegistrySpec(url = "https://github.com/JuliaRegistries/General.git"))'
julia --project=.breakage -e 'using Pkg; Pkg.update(); Pkg.instantiate()'
pkgs=$(julia --project=.breakage .breakage/get_jso_users.jl ${{ env.pkg }})
vs='["latest", "stable"]'
# Check if pkgs is empty, and set it to a JSON array if necessary
if [[ -z "$pkgs" || "$pkgs" == "String[]" ]]; then
echo "No packages found; exiting successfully."
exit 0
fi
vs='["latest", "stable"]'
matrix=$(jq -cn --argjson deps "$pkgs" --argjson vers "$vs" '{pkg: $deps, pkgversion: $vers}') # don't escape quotes like many posts suggest
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
break:
needs: setup_matrix
if: needs.setup_matrix.result == 'success' && needs.setup_matrix.outputs.matrix != ''
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.setup_matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
# Install Julia
- uses: julia-actions/setup-julia@v2
with:
version: 1
arch: x64
- uses: actions/cache@v4
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
# Breakage test
- name: 'Breakage of ${{ matrix.pkg }}, ${{ matrix.pkgversion }} version'
env:
PKG: ${{ matrix.pkg }}
VERSION: ${{ matrix.pkgversion }}
run: |
set -v
mkdir -p ./breakage
git clone https://github.com/JuliaSmoothOptimizers/$PKG.jl.git
cd $PKG.jl
if [ $VERSION == "stable" ]; then
TAG=$(git tag -l "v*" --sort=-creatordate | head -n1)
if [ -z "$TAG" ]; then
TAG="no_tag"
else
git checkout $TAG
fi
else
TAG=$VERSION
fi
export TAG
julia -e 'using Pkg;
PKG, TAG, VERSION = ENV["PKG"], ENV["TAG"], ENV["VERSION"]
joburl = joinpath(ENV["GITHUB_SERVER_URL"], ENV["GITHUB_REPOSITORY"], "actions/runs", ENV["GITHUB_RUN_ID"])
open("../breakage/breakage-$PKG-$VERSION", "w") do io
try
TAG == "no_tag" && error("No tag for $VERSION")
pkg"activate .";
pkg"instantiate";
pkg"dev ../";
if TAG == "latest"
global TAG = chomp(read(`git rev-parse --short HEAD`, String))
end
pkg"build";
pkg"test";
print(io, "[![](https://img.shields.io/badge/$TAG-Pass-green)]($joburl)");
catch e
@error e;
print(io, "[![](https://img.shields.io/badge/$TAG-Fail-red)]($joburl)");
end;
end'
- uses: actions/upload-artifact@v4
with:
name: breakage-${{ matrix.pkg }}-${{ matrix.pkgversion }}
path: breakage/breakage-*
upload:
needs: break
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: breakage
pattern: breakage-*
merge-multiple: true
- run: ls -R
- run: |
cd breakage
echo "| Package name | latest | stable |" > summary.md
echo "|--|--|--|" >> summary.md
count=0
for file in breakage-*
do
if [ $count == "0" ]; then
name=$(echo $file | cut -f2 -d-)
echo -n "| $name | "
else
echo -n "| "
fi
cat $file
if [ $count == "0" ]; then
echo -n " "
count=1
else
echo " |"
count=0
fi
done >> summary.md
- name: PR comment with file
uses: thollander/actions-comment-pull-request@v2
with:
filePath: breakage/summary.md