77 pull_request :
88
99jobs :
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+
1050 break :
51+ needs : setup_matrix
52+ if : needs.setup_matrix.result == 'success' && needs.setup_matrix.outputs.matrix != ''
1153 runs-on : ubuntu-latest
1254 strategy :
1355 fail-fast : false
14- matrix :
15- pkg : [
16- " control-toolbox/OptimalControl.jl" ,
17- " JuliaSmoothOptimizers/CaNNOLeS.jl" ,
18- " JuliaSmoothOptimizers/DCISolver.jl" ,
19- " JuliaSmoothOptimizers/DerivativeFreeSolvers.jl" ,
20- " JuliaSmoothOptimizers/JSOSolvers.jl" ,
21- " JuliaSmoothOptimizers/NLPModelsIpopt.jl" ,
22- " JuliaSmoothOptimizers/OptimizationProblems.jl" ,
23- " JuliaSmoothOptimizers/Percival.jl" ,
24- " JuliaSmoothOptimizers/QuadraticModels.jl" ,
25- " JuliaSmoothOptimizers/SolverBenchmark.jl" ,
26- " JuliaSmoothOptimizers/SolverTools.jl"
27- ]
28- pkgversion : [latest, stable]
56+ matrix : ${{ fromJSON(needs.setup_matrix.outputs.matrix) }}
2957
3058 steps :
3159 - uses : actions/checkout@v4
@@ -50,15 +78,13 @@ jobs:
5078 # Breakage test
5179 - name : ' Breakage of ${{ matrix.pkg }}, ${{ matrix.pkgversion }} version'
5280 env :
53- URL : ${{ matrix.pkg }}
81+ PKG : ${{ matrix.pkg }}
5482 VERSION : ${{ matrix.pkgversion }}
5583 run : |
5684 set -v
57- mkdir -p ./pr
58- echo "${{ github.event.number }}" > ./pr/NR
59- git clone https://github.com/$URL
60- export PKG=$(echo $URL | cut -f2 -d/)
61- cd $PKG
85+ mkdir -p ./breakage
86+ git clone https://github.com/JuliaSmoothOptimizers/$PKG.jl.git
87+ cd $PKG.jl
6288 if [ $VERSION == "stable" ]; then
6389 TAG=$(git tag -l "v*" --sort=-creatordate | head -n1)
6490 if [ -z "$TAG" ]; then
@@ -73,12 +99,15 @@ jobs:
7399 julia -e 'using Pkg;
74100 PKG, TAG, VERSION = ENV["PKG"], ENV["TAG"], ENV["VERSION"]
75101 joburl = joinpath(ENV["GITHUB_SERVER_URL"], ENV["GITHUB_REPOSITORY"], "actions/runs", ENV["GITHUB_RUN_ID"])
76- open("../pr/ $PKG-$VERSION", "w") do io
102+ open("../breakage/breakage- $PKG-$VERSION", "w") do io
77103 try
78- TAG == "no_tag" && error("Not tag for $VERSION")
104+ TAG == "no_tag" && error("No tag for $VERSION")
79105 pkg"activate .";
80106 pkg"instantiate";
81107 pkg"dev ../";
108+ if TAG == "latest"
109+ global TAG = chomp(read(`git rev-parse --short HEAD`, String))
110+ end
82111 pkg"build";
83112 pkg"test";
84113
@@ -89,34 +118,33 @@ jobs:
89118 end;
90119 end'
91120
92- - uses : actions/upload-artifact@v3
121+ - uses : actions/upload-artifact@v4
93122 with :
94- name : pr
95- path : pr/
123+ name : breakage-${{ matrix.pkg }}-${{ matrix.pkgversion }}
124+ path : breakage/breakage-*
96125
97126 upload :
98127 needs : break
99128 runs-on : ubuntu-latest
100129 steps :
101130 - uses : actions/checkout@v4
102131
103- - uses : actions/download-artifact@v3
132+ - uses : actions/download-artifact@v4
104133 with :
105- name : pr
106- path : pr/
134+ path : breakage
135+ pattern : breakage-*
136+ merge-multiple : true
107137
108- - run : ls
138+ - run : ls -R
109139 - run : |
110- cd pr
111- echo "| Package name | latest | stable |" > MSG
112- echo "|--|--|--|" >> MSG
140+ cd breakage
141+ echo "| Package name | latest | stable |" > summary.md
142+ echo "|--|--|--|" >> summary.md
113143 count=0
114- for file in *
144+ for file in breakage- *
115145 do
116- [ "$file" == "NR" ] && continue
117- [ "$file" == "MSG" ] && continue
118146 if [ $count == "0" ]; then
119- name=$(echo $file | cut -f1 -d-)
147+ name=$(echo $file | cut -f2 -d-)
120148 echo -n "| $name | "
121149 else
122150 echo -n "| "
@@ -129,9 +157,45 @@ jobs:
129157 echo " |"
130158 count=0
131159 fi
132- done >> MSG
160+ done >> summary.md
133161
134- - uses : actions/upload-artifact@v4
162+ - name : PR comment with file
163+ uses : actions/github-script@v6
135164 with :
136- name : pr
137- path : pr/
165+ github-token : ${{ secrets.GITHUB_TOKEN }}
166+ script : |
167+ // Import file content from summary.md
168+ const fs = require('fs')
169+ const filePath = 'breakage/summary.md'
170+ const msg = fs.readFileSync(filePath, 'utf8')
171+
172+ // Get the current PR number from context
173+ const prNumber = context.payload.pull_request.number
174+
175+ // Fetch existing comments on the PR
176+ const { data: comments } = await github.rest.issues.listComments({
177+ owner: context.repo.owner,
178+ repo: context.repo.repo,
179+ issue_number: prNumber
180+ })
181+
182+ // Find a previous comment by the bot to update
183+ const botComment = comments.find(comment => comment.user.id === 41898282)
184+
185+ if (botComment) {
186+ // Update the existing comment
187+ await github.rest.issues.updateComment({
188+ owner: context.repo.owner,
189+ repo: context.repo.repo,
190+ comment_id: botComment.id,
191+ body: msg
192+ })
193+ } else {
194+ // Create a new comment
195+ await github.rest.issues.createComment({
196+ owner: context.repo.owner,
197+ repo: context.repo.repo,
198+ issue_number: prNumber,
199+ body: msg
200+ })
201+ }
0 commit comments