-
Notifications
You must be signed in to change notification settings - Fork 2
151 lines (128 loc) · 4.97 KB
/
check.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: Check on PR
on:
pull_request:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
find-updated-benchmarks:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- run: |
git fetch origin
- id: find-base-updates
run: |
bases=$(git diff --name-only --diff-filter=ACMR origin/${{ github.base_ref }} origin/${{ github.head_ref }} | grep -e "^OCaml-base/" -e "^Java-base/" -e "^C-base/" -e "^Solidity-base/" | cut -d '/' -f 1-2 | sort | uniq)
{
for base in $bases; do
base=$(echo $base | sed 's/-base//')
find $base-* -maxdepth 0 -type d
done
} > /tmp/updated.txt
cat /tmp/updated.txt
- id: find-benchmark-updates
run: |
git diff --name-only --diff-filter=ACMR origin/${{ github.base_ref }} origin/${{ github.head_ref }} | grep -e "^OCaml/" -e "^Java/" -e "^C/" -e "^Solidity/" | cut -d '/' -f 1-2 | sort | uniq >> /tmp/updated.txt
cat /tmp/updated.txt
- id: find-targets
run: |
targets=$(cat /tmp/updated.txt | xargs -I{prj} echo \"{prj}\" | tr '\n' ',' | sed 's/,*$//')
echo $targets
echo "targets=[$targets]" >> ${GITHUB_OUTPUT}
outputs:
targets: ${{ steps.find-targets.outputs.targets }}
benchmarks-build-test:
runs-on: ubuntu-latest
permissions:
contents: read
needs:
- find-updated-benchmarks
if: always() && needs.find-updated-benchmarks.outputs.targets != '[]'
strategy:
matrix:
target: ${{ fromJSON(needs.find-updated-benchmarks.outputs.targets) }}
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host
- name: Check if base image exists
id: check-if-base-image-exists
run: |
lang=$(echo ${{ matrix.target }} | cut -d'/' -f1)
proj=$(echo ${{ matrix.target }} | cut -d'/' -f2 | rev | cut -d'-' -f2- | rev)
echo "base_dir=${lang}-base/${proj}"
if [ -d ${lang}-base/${proj} ]; then
echo "base=${lang}-base/${proj}" >> ${GITHUB_OUTPUT}
echo "image=${lang}-base:${proj}" | tr '[:upper:]' '[:lower:]' >> ${GITHUB_OUTPUT}
fi
- name: Build base image
id: build-base-image
if: steps.check-if-base-image-exists.outputs.base != ''
uses: docker/build-push-action@v5
with:
context: ${{ steps.check-if-base-image-exists.outputs.base }}
file: ${{ steps.check-if-base-image-exists.outputs.base }}/Dockerfile
platforms: linux/amd64
push: true
tags: localhost:5000/base:latest
- name: Build benchmark image without base image
uses: docker/build-push-action@v5
if: steps.check-if-base-image-exists.outputs.base == ''
with:
context: ${{ matrix.target }}
file: ${{ matrix.target }}/Dockerfile
platforms: linux/amd64
push: true
tags: localhost:5000/benchmark:latest
- name: Build benchmark image with base image
uses: docker/build-push-action@v5
if: steps.check-if-base-image-exists.outputs.base != ''
with:
context: ${{ matrix.target }}
file: ${{ matrix.target }}/Dockerfile
platforms: linux/amd64
push: true
tags: localhost:5000/benchmark:latest
build-contexts: |
ghcr.io/kupl/starlab-benchmarks/${{ steps.check-if-base-image-exists.outputs.image }}=docker-image://localhost:5000/base:latest
- name: Read metadata
id: read-metadata
run: |
content=$(cat ${{ matrix.target }}/metadata.json)
content="${content//$'\n'/''}"
echo "location=$(echo $content | jq -r .buggyPath)" >> ${GITHUB_OUTPUT}
echo "buildCommand=$(echo $content | jq -r .buildCommand)" >> ${GITHUB_OUTPUT}
- name: Smoke test
run: |
docker run --rm localhost:5000/benchmark:latest /bin/bash -c "cd ${{ steps.read-metadata.outputs.location }}; ${{ steps.read-metadata.outputs.buildCommand }}"
check-all-test-pass-on-pr:
runs-on: ubuntu-latest
permissions:
pull-requests: write
needs:
- benchmarks-build-test
if: always()
steps:
- run: exit 1
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
- uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: ':mega: All tests passed!'
})