Skip to content

Commit e9ac746

Browse files
Update breakage: use organization-wide workflow (#238)
* update breakage: use organization-wide workflow * Update .github/workflows/CommentBreakage.yml --------- Co-authored-by: Tangi Migot <tangi.migot@gmail.com>
1 parent df5124b commit e9ac746

4 files changed

Lines changed: 14 additions & 216 deletions

File tree

.breakage/Project.toml

Lines changed: 0 additions & 3 deletions
This file was deleted.

.breakage/get_jso_users.jl

Lines changed: 0 additions & 19 deletions
This file was deleted.

.github/workflows/Breakage.yml

Lines changed: 3 additions & 194 deletions
Original file line numberDiff line numberDiff line change
@@ -1,200 +1,9 @@
1-
# Ref: https://securitylab.github.com/research/github-actions-preventing-pwn-requests
21
name: Breakage
32

4-
# read-only repo token
5-
# no access to secrets
63
on:
74
pull_request:
5+
types: [opened, synchronize, reopened]
86

97
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@v6
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@v6
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-
# Breakage test
78-
- name: "Breakage of ${{ matrix.pkg }}, ${{ matrix.pkgversion }} version"
79-
env:
80-
PKG: ${{ matrix.pkg }}
81-
VERSION: ${{ matrix.pkgversion }}
82-
run: |
83-
set -v
84-
mkdir -p ./breakage
85-
git clone https://github.com/JuliaSmoothOptimizers/$PKG.jl.git
86-
cd $PKG.jl
87-
if [ $VERSION == "stable" ]; then
88-
TAG=$(git tag -l "v*" --sort=-creatordate | head -n1)
89-
if [ -z "$TAG" ]; then
90-
TAG="no_tag"
91-
else
92-
git checkout $TAG
93-
fi
94-
else
95-
TAG=$VERSION
96-
fi
97-
export TAG
98-
julia -e 'using Pkg;
99-
PKG, TAG, VERSION = ENV["PKG"], ENV["TAG"], ENV["VERSION"]
100-
joburl = joinpath(ENV["GITHUB_SERVER_URL"], ENV["GITHUB_REPOSITORY"], "actions/runs", ENV["GITHUB_RUN_ID"])
101-
open("../breakage/breakage-$PKG-$VERSION", "w") do io
102-
try
103-
TAG == "no_tag" && error("No tag for $VERSION")
104-
pkg"activate .";
105-
pkg"instantiate";
106-
pkg"dev ../";
107-
if TAG == "latest"
108-
global TAG = chomp(read(`git rev-parse --short HEAD`, String))
109-
end
110-
pkg"build";
111-
pkg"test";
112-
113-
print(io, "[![](https://img.shields.io/badge/$TAG-Pass-green)]($joburl)");
114-
catch e
115-
@error e;
116-
print(io, "[![](https://img.shields.io/badge/$TAG-Fail-red)]($joburl)");
117-
end;
118-
end'
119-
120-
- uses: actions/upload-artifact@v4
121-
with:
122-
name: breakage-${{ matrix.pkg }}-${{ matrix.pkgversion }}
123-
path: breakage/breakage-*
124-
125-
upload:
126-
needs: break
127-
runs-on: ubuntu-latest
128-
steps:
129-
- uses: actions/checkout@v6
130-
131-
- uses: actions/download-artifact@v5
132-
with:
133-
path: breakage
134-
pattern: breakage-*
135-
merge-multiple: true
136-
137-
- run: ls -R
138-
- run: |
139-
cd breakage
140-
echo "| Package name | latest | stable |" > summary.md
141-
echo "|--|--|--|" >> summary.md
142-
count=0
143-
for file in breakage-*
144-
do
145-
if [ $count == "0" ]; then
146-
name=$(echo $file | cut -f2 -d-)
147-
echo -n "| $name | "
148-
else
149-
echo -n "| "
150-
fi
151-
cat $file
152-
if [ $count == "0" ]; then
153-
echo -n " "
154-
count=1
155-
else
156-
echo " |"
157-
count=0
158-
fi
159-
done >> summary.md
160-
161-
- name: PR comment with file
162-
uses: actions/github-script@v7
163-
with:
164-
github-token: ${{ secrets.GITHUB_TOKEN }}
165-
script: |
166-
// Import file content from summary.md
167-
const fs = require('fs')
168-
const filePath = 'breakage/summary.md'
169-
const msg = fs.readFileSync(filePath, 'utf8')
170-
171-
// Get the current PR number from context
172-
const prNumber = context.payload.pull_request.number
173-
174-
// Fetch existing comments on the PR
175-
const { data: comments } = await github.rest.issues.listComments({
176-
owner: context.repo.owner,
177-
repo: context.repo.repo,
178-
issue_number: prNumber
179-
})
180-
181-
// Find a previous comment by the bot to update
182-
const botComment = comments.find(comment => comment.user.id === 41898282)
183-
184-
if (botComment) {
185-
// Update the existing comment
186-
await github.rest.issues.updateComment({
187-
owner: context.repo.owner,
188-
repo: context.repo.repo,
189-
comment_id: botComment.id,
190-
body: msg
191-
})
192-
} else {
193-
// Create a new comment
194-
await github.rest.issues.createComment({
195-
owner: context.repo.owner,
196-
repo: context.repo.repo,
197-
issue_number: prNumber,
198-
body: msg
199-
})
200-
}
8+
breakage:
9+
uses: JuliaSmoothOptimizers/.github/.github/workflows/Breakage.yml@main
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Comment Breakage
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Breakage"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
comment_pr:
11+
uses: JuliaSmoothOptimizers/.github/.github/workflows/CommentBreakage.yml@main

0 commit comments

Comments
 (0)