Skip to content

Commit 16fc349

Browse files
committed
Add breakage tests
1 parent 770acc9 commit 16fc349

File tree

1 file changed

+134
-0
lines changed

1 file changed

+134
-0
lines changed

.github/workflows/Breakage.yml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
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/DCI.jl",
18+
"JuliaSmoothOptimizers/DerivativeFreeSolvers.jl",
19+
"JuliaSmoothOptimizers/JSOSolvers.jl",
20+
"JuliaSmoothOptimizers/NLPModelsIpopt.jl",
21+
"JuliaSmoothOptimizers/Percival.jl",
22+
"JuliaSmoothOptimizers/RipQP.jl",
23+
"JuliaSmoothOptimizers/SolverTest.jl"
24+
]
25+
pkgversion: [latest, stable]
26+
27+
steps:
28+
- uses: actions/checkout@v2
29+
30+
# Install Julia
31+
- uses: julia-actions/setup-julia@v1
32+
with:
33+
version: 1
34+
arch: x64
35+
- uses: actions/cache@v1
36+
env:
37+
cache-name: cache-artifacts
38+
with:
39+
path: ~/.julia/artifacts
40+
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
41+
restore-keys: |
42+
${{ runner.os }}-test-${{ env.cache-name }}-
43+
${{ runner.os }}-test-
44+
${{ runner.os }}-
45+
- uses: julia-actions/julia-buildpkg@v1
46+
47+
# Breakage test
48+
- name: 'Breakage of ${{ matrix.pkg }}, ${{ matrix.pkgversion }} version'
49+
env:
50+
URL: ${{ matrix.pkg }}
51+
VERSION: ${{ matrix.pkgversion }}
52+
run: |
53+
set -v
54+
mkdir -p ./pr
55+
echo "${{ github.event.number }}" > ./pr/NR
56+
git clone https://github.com/$URL
57+
export PKG=$(echo $URL | cut -f2 -d/)
58+
cd $PKG
59+
if [ $VERSION == "stable" ]; then
60+
TAG=$(git tag -l "v*" --sort=-creatordate | head -n1)
61+
if [ -z "$TAG" ]; then
62+
TAG="no_tag"
63+
else
64+
git checkout $TAG
65+
fi
66+
else
67+
TAG=$VERSION
68+
fi
69+
export TAG
70+
julia -e 'using Pkg;
71+
PKG, TAG, VERSION = ENV["PKG"], ENV["TAG"], ENV["VERSION"]
72+
joburl = joinpath(ENV["GITHUB_SERVER_URL"], ENV["GITHUB_REPOSITORY"], "actions/runs", ENV["GITHUB_RUN_ID"])
73+
open("../pr/$PKG-$VERSION", "w") do io
74+
try
75+
TAG == "no_tag" && error("Not tag for $VERSION")
76+
pkg"activate .";
77+
pkg"instantiate";
78+
pkg"dev ../";
79+
pkg"build";
80+
pkg"test";
81+
82+
print(io, "[![](https://img.shields.io/badge/$TAG-Pass-green)]($joburl)");
83+
catch e
84+
@error e;
85+
print(io, "[![](https://img.shields.io/badge/$TAG-Fail-red)]($joburl)");
86+
end;
87+
end'
88+
89+
- uses: actions/upload-artifact@v2
90+
with:
91+
name: pr
92+
path: pr/
93+
94+
upload:
95+
needs: break
96+
runs-on: ubuntu-latest
97+
steps:
98+
- uses: actions/checkout@v2
99+
100+
- uses: actions/download-artifact@v2
101+
with:
102+
name: pr
103+
path: pr/
104+
105+
- run: ls
106+
- run: |
107+
cd pr
108+
echo "| Package name | latest | stable |" > MSG
109+
echo "|--|--|--|" >> MSG
110+
count=0
111+
for file in *
112+
do
113+
[ "$file" == "NR" ] && continue
114+
[ "$file" == "MSG" ] && continue
115+
if [ $count == "0" ]; then
116+
name=$(echo $file | cut -f1 -d-)
117+
echo -n "| $name | "
118+
else
119+
echo -n "| "
120+
fi
121+
cat $file
122+
if [ $count == "0" ]; then
123+
echo -n " "
124+
count=1
125+
else
126+
echo " |"
127+
count=0
128+
fi
129+
done >> MSG
130+
131+
- uses: actions/upload-artifact@v2
132+
with:
133+
name: pr
134+
path: pr/

0 commit comments

Comments
 (0)