Skip to content

Commit f90cc83

Browse files
authored
Add breakage tests (#83)
1 parent 43d7bbe commit f90cc83

File tree

1 file changed

+125
-0
lines changed

1 file changed

+125
-0
lines changed

.github/workflows/breakage.yml

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

0 commit comments

Comments
 (0)