Skip to content

Commit 46e1110

Browse files
committed
Apply JSOBestieTemplate update
1 parent 01253d3 commit 46e1110

File tree

4 files changed

+194
-136
lines changed

4 files changed

+194
-136
lines changed

.breakage/Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[deps]
2+
GitHub = "bc5e4493-9b4d-5f90-b8aa-2b2bcaad7a26"
3+
PkgDeps = "839e9fc8-855b-5b3c-a3b7-2833d3dd1f59"

.breakage/get_jso_users.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import GitHub, PkgDeps # both export users()
2+
3+
length(ARGS) >= 1 || error("specify at least one JSO package as argument")
4+
5+
jso_repos, _ = GitHub.repos("JuliaSmoothOptimizers")
6+
jso_names = [splitext(x.name)[1] for x jso_repos]
7+
8+
name = splitext(ARGS[1])[1]
9+
name jso_names || error("argument should be one of ", jso_names)
10+
11+
dependents = String[]
12+
try
13+
global dependents = filter(x -> x jso_names, PkgDeps.users(name))
14+
catch e
15+
# package not registered; don't insert into dependents
16+
end
17+
18+
println(dependents)

.github/workflows/Breakage.yml

Lines changed: 165 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -1,136 +1,165 @@
1-
# Ref: https://securitylab.github.com/research/github-actions-preventing-pwn-requests
2-
name: Breakage
3-
4-
# read-only repo token
5-
# no access to secrets
6-
on:
7-
pull_request:
8-
9-
jobs:
10-
break:
11-
runs-on: ubuntu-latest
12-
strategy:
13-
fail-fast: false
14-
matrix:
15-
pkg: [
16-
"JuliaSmoothOptimizers/CaNNOLeS.jl",
17-
"JuliaSmoothOptimizers/DCISolver.jl",
18-
"JuliaSmoothOptimizers/DerivativeFreeSolvers.jl",
19-
"JuliaSmoothOptimizers/FletcherPenaltySolver.jl",
20-
"JuliaSmoothOptimizers/JSOSolvers.jl",
21-
"JuliaSmoothOptimizers/NLPModelsIpopt.jl",
22-
"JuliaSmoothOptimizers/Percival.jl",
23-
"JuliaSmoothOptimizers/RipQP.jl",
24-
"JuliaSmoothOptimizers/SolverBenchmark.jl",
25-
"JuliaSmoothOptimizers/SolverTest.jl"
26-
]
27-
pkgversion: [latest, stable]
28-
29-
steps:
30-
- uses: actions/checkout@v2
31-
32-
# Install Julia
33-
- uses: julia-actions/setup-julia@v1
34-
with:
35-
version: 1
36-
arch: x64
37-
- uses: actions/cache@v1
38-
env:
39-
cache-name: cache-artifacts
40-
with:
41-
path: ~/.julia/artifacts
42-
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
43-
restore-keys: |
44-
${{ runner.os }}-test-${{ env.cache-name }}-
45-
${{ runner.os }}-test-
46-
${{ runner.os }}-
47-
- uses: julia-actions/julia-buildpkg@v1
48-
49-
# Breakage test
50-
- name: 'Breakage of ${{ matrix.pkg }}, ${{ matrix.pkgversion }} version'
51-
env:
52-
URL: ${{ matrix.pkg }}
53-
VERSION: ${{ matrix.pkgversion }}
54-
run: |
55-
set -v
56-
mkdir -p ./pr
57-
echo "${{ github.event.number }}" > ./pr/NR
58-
git clone https://github.com/$URL
59-
export PKG=$(echo $URL | cut -f2 -d/)
60-
cd $PKG
61-
if [ $VERSION == "stable" ]; then
62-
TAG=$(git tag -l "v*" --sort=-creatordate | head -n1)
63-
if [ -z "$TAG" ]; then
64-
TAG="no_tag"
65-
else
66-
git checkout $TAG
67-
fi
68-
else
69-
TAG=$VERSION
70-
fi
71-
export TAG
72-
julia -e 'using Pkg;
73-
PKG, TAG, VERSION = ENV["PKG"], ENV["TAG"], ENV["VERSION"]
74-
joburl = joinpath(ENV["GITHUB_SERVER_URL"], ENV["GITHUB_REPOSITORY"], "actions/runs", ENV["GITHUB_RUN_ID"])
75-
open("../pr/$PKG-$VERSION", "w") do io
76-
try
77-
TAG == "no_tag" && error("Not tag for $VERSION")
78-
pkg"activate .";
79-
pkg"instantiate";
80-
pkg"dev ../";
81-
pkg"build";
82-
pkg"test";
83-
84-
print(io, "[![](https://img.shields.io/badge/$TAG-Pass-green)]($joburl)");
85-
catch e
86-
@error e;
87-
print(io, "[![](https://img.shields.io/badge/$TAG-Fail-red)]($joburl)");
88-
end;
89-
end'
90-
91-
- uses: actions/upload-artifact@v2
92-
with:
93-
name: pr
94-
path: pr/
95-
96-
upload:
97-
needs: break
98-
runs-on: ubuntu-latest
99-
steps:
100-
- uses: actions/checkout@v2
101-
102-
- uses: actions/download-artifact@v2
103-
with:
104-
name: pr
105-
path: pr/
106-
107-
- run: ls
108-
- run: |
109-
cd pr
110-
echo "| Package name | latest | stable |" > MSG
111-
echo "|--|--|--|" >> MSG
112-
count=0
113-
for file in *
114-
do
115-
[ "$file" == "NR" ] && continue
116-
[ "$file" == "MSG" ] && continue
117-
if [ $count == "0" ]; then
118-
name=$(echo $file | cut -f1 -d-)
119-
echo -n "| $name | "
120-
else
121-
echo -n "| "
122-
fi
123-
cat $file
124-
if [ $count == "0" ]; then
125-
echo -n " "
126-
count=1
127-
else
128-
echo " |"
129-
count=0
130-
fi
131-
done >> MSG
132-
133-
- uses: actions/upload-artifact@v2
134-
with:
135-
name: pr
136-
path: pr/
1+
# Ref: https://securitylab.github.com/research/github-actions-preventing-pwn-requests
2+
name: Breakage
3+
4+
# read-only repo token
5+
# no access to secrets
6+
on:
7+
pull_request:
8+
9+
jobs:
10+
# Build dynamically the matrix on which the "break" job will run.
11+
# The matrix contains the packages that depend on ${{ env.pkg }}.
12+
# Job "setup_matrix" outputs variable "matrix", which is in turn
13+
# the output of the "getmatrix" step.
14+
# The contents of "matrix" is a JSON description of a matrix used
15+
# in the next step. It has the form
16+
# {
17+
# "pkg": [
18+
# "PROPACK",
19+
# "LLSModels",
20+
# "FletcherPenaltySolver"
21+
# ]
22+
# }
23+
setup_matrix:
24+
runs-on: ubuntu-latest
25+
outputs:
26+
matrix: ${{ steps.getmatrix.outputs.matrix }}
27+
env:
28+
pkg: ${{ github.event.repository.name }}
29+
steps:
30+
- uses: actions/checkout@v4
31+
- uses: julia-actions/setup-julia@v2
32+
with:
33+
version: 1
34+
arch: x64
35+
- id: getmatrix
36+
run: |
37+
julia -e 'using Pkg; Pkg.Registry.add(RegistrySpec(url = "https://github.com/JuliaRegistries/General.git"))'
38+
julia --project=.breakage -e 'using Pkg; Pkg.update(); Pkg.instantiate()'
39+
pkgs=$(julia --project=.breakage .breakage/get_jso_users.jl ${{ env.pkg }})
40+
vs='["latest", "stable"]'
41+
# Check if pkgs is empty, and set it to a JSON array if necessary
42+
if [[ -z "$pkgs" || "$pkgs" == "String[]" ]]; then
43+
echo "No packages found; exiting successfully."
44+
exit 0
45+
fi
46+
vs='["latest", "stable"]'
47+
matrix=$(jq -cn --argjson deps "$pkgs" --argjson vers "$vs" '{pkg: $deps, pkgversion: $vers}') # don't escape quotes like many posts suggest
48+
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
49+
50+
break:
51+
needs: setup_matrix
52+
if: needs.setup_matrix.result == 'success' && needs.setup_matrix.outputs.matrix != ''
53+
runs-on: ubuntu-latest
54+
strategy:
55+
fail-fast: false
56+
matrix: ${{ fromJSON(needs.setup_matrix.outputs.matrix) }}
57+
58+
steps:
59+
- uses: actions/checkout@v4
60+
61+
# Install Julia
62+
- uses: julia-actions/setup-julia@v2
63+
with:
64+
version: 1
65+
arch: x64
66+
- uses: actions/cache@v4
67+
env:
68+
cache-name: cache-artifacts
69+
with:
70+
path: ~/.julia/artifacts
71+
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
72+
restore-keys: |
73+
${{ runner.os }}-test-${{ env.cache-name }}-
74+
${{ runner.os }}-test-
75+
${{ runner.os }}-
76+
- uses: julia-actions/julia-buildpkg@v1
77+
78+
# Breakage test
79+
- name: 'Breakage of ${{ matrix.pkg }}, ${{ matrix.pkgversion }} version'
80+
env:
81+
PKG: ${{ matrix.pkg }}
82+
VERSION: ${{ matrix.pkgversion }}
83+
run: |
84+
set -v
85+
mkdir -p ./breakage
86+
git clone https://github.com/JuliaSmoothOptimizers/$PKG.jl.git
87+
cd $PKG.jl
88+
if [ $VERSION == "stable" ]; then
89+
TAG=$(git tag -l "v*" --sort=-creatordate | head -n1)
90+
if [ -z "$TAG" ]; then
91+
TAG="no_tag"
92+
else
93+
git checkout $TAG
94+
fi
95+
else
96+
TAG=$VERSION
97+
fi
98+
export TAG
99+
julia -e 'using Pkg;
100+
PKG, TAG, VERSION = ENV["PKG"], ENV["TAG"], ENV["VERSION"]
101+
joburl = joinpath(ENV["GITHUB_SERVER_URL"], ENV["GITHUB_REPOSITORY"], "actions/runs", ENV["GITHUB_RUN_ID"])
102+
open("../breakage/breakage-$PKG-$VERSION", "w") do io
103+
try
104+
TAG == "no_tag" && error("No tag for $VERSION")
105+
pkg"activate .";
106+
pkg"instantiate";
107+
pkg"dev ../";
108+
if TAG == "latest"
109+
global TAG = chomp(read(`git rev-parse --short HEAD`, String))
110+
end
111+
pkg"build";
112+
pkg"test";
113+
114+
print(io, "[![](https://img.shields.io/badge/$TAG-Pass-green)]($joburl)");
115+
catch e
116+
@error e;
117+
print(io, "[![](https://img.shields.io/badge/$TAG-Fail-red)]($joburl)");
118+
end;
119+
end'
120+
121+
- uses: actions/upload-artifact@v4
122+
with:
123+
name: breakage-${{ matrix.pkg }}-${{ matrix.pkgversion }}
124+
path: breakage/breakage-*
125+
126+
upload:
127+
needs: break
128+
runs-on: ubuntu-latest
129+
steps:
130+
- uses: actions/checkout@v4
131+
132+
- uses: actions/download-artifact@v4
133+
with:
134+
path: breakage
135+
pattern: breakage-*
136+
merge-multiple: true
137+
138+
- run: ls -R
139+
- run: |
140+
cd breakage
141+
echo "| Package name | latest | stable |" > summary.md
142+
echo "|--|--|--|" >> summary.md
143+
count=0
144+
for file in breakage-*
145+
do
146+
if [ $count == "0" ]; then
147+
name=$(echo $file | cut -f2 -d-)
148+
echo -n "| $name | "
149+
else
150+
echo -n "| "
151+
fi
152+
cat $file
153+
if [ $count == "0" ]; then
154+
echo -n " "
155+
count=1
156+
else
157+
echo " |"
158+
count=0
159+
fi
160+
done >> summary.md
161+
162+
- name: PR comment with file
163+
uses: thollander/actions-comment-pull-request@v2
164+
with:
165+
filePath: breakage/summary.md

copier-answers.jso.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
PackageName: "SolverCore"
2+
PackageOwner: "JuliaSmoothOptimizers"
3+
PackageUUID: "ff4d7338-4cf1-434d-91df-b86cb86fb843"
4+
_src_path: "https://github.com/JuliaSmoothOptimizers/JSOBestieTemplate.jl"
5+
_commit: "v0.13.0"
6+
AddBreakage: true
7+
AddBenchmark: false
8+
AddBenchmarkCI: true

0 commit comments

Comments
 (0)