-
Notifications
You must be signed in to change notification settings - Fork 2
138 lines (113 loc) · 4.31 KB
/
build.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
name: Build benchmark images
on:
push:
branches:
- main
env:
REGISTRY: ghcr.io
jobs:
find-updated-bases:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- id: find-targets
run: |
git diff --name-only --diff-filter=ACMR HEAD^ HEAD | grep -e "^OCaml-base/" -e "^Java-base/" -e "^C-base/" -e "^Solidity-base/" | cut -d '/' -f 1-2 | sort | uniq > /tmp/updated-bases.txt
bases=$(cat /tmp/updated-bases.txt | xargs -I{base} echo \"{base}\" | tr '\n' ',' | sed 's/,*$//')
echo "targets=[$bases]" >> ${GITHUB_OUTPUT}
outputs:
targets: ${{ steps.find-targets.outputs.targets }}
build-base-images:
needs:
- find-updated-bases
runs-on: ubuntu-latest
if: needs.find-updated-bases.outputs.targets != '[]'
permissions:
contents: read
packages: write
strategy:
matrix:
target: ${{ fromJSON(needs.find-updated-bases.outputs.targets) }}
steps:
- uses: actions/checkout@v4
- name: Make build info
id: make-build-info
run: |
echo "language=$(echo ${{ matrix.target }} | cut -d'/' -f1 | tr '[:upper:]' '[:lower:]')" >> ${GITHUB_OUTPUT}
echo "project=$(echo ${{ matrix.target }} | cut -d'/' -f2 | tr '[:upper:]' '[:lower:]')" >> ${GITHUB_OUTPUT}
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v5
with:
context: ${{ matrix.target }}
file: ${{ matrix.target }}/Dockerfile
platforms: linux/amd64
push: true
tags: ${{ env.REGISTRY }}/kupl/starlab-benchmarks/${{ steps.make-build-info.outputs.language }}:${{ steps.make-build-info.outputs.project }}
labels: |
org.opencontainers.image.source="https://github.com/kupl/starlab-benchmarks"
find-targets:
needs:
- find-updated-bases
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- id: find-targets
run: |
{
for base in $(echo '${{ needs.find-updated-bases.outputs.targets }}' | jq -r '.[]'); do
base=$(echo $base | sed 's/-base//')
find $base-* -maxdepth 0 -type d
done
} > /tmp/updated-benchmarks.txt
git diff --name-only --diff-filter=ACMR HEAD^ HEAD | grep -e "^OCaml/" -e "^Java/" -e "^C/" -e "^Solidity/" | cut -d '/' -f 1-2 | sort | uniq >> /tmp/updated-benchmarks.txt
projects=$(cat /tmp/updated-benchmarks.txt | xargs -I{prj} echo \"{prj}\" | tr '\n' ',' | sed 's/,*$//')
echo "targets=[$projects]" >> ${GITHUB_OUTPUT}
outputs:
targets: ${{ steps.find-targets.outputs.targets }}
build-and-deploy:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs:
- build-base-images
- find-targets
if: always() && needs.find-targets.outputs.targets != '[]'
strategy:
matrix:
target: ${{ fromJSON(needs.find-targets.outputs.targets) }}
steps:
- uses: actions/checkout@v3
- name: Make build info
id: make-build-info
run: |
echo "language=$(echo ${{ matrix.target }} | cut -d'/' -f1 | tr '[:upper:]' '[:lower:]')" >> ${GITHUB_OUTPUT}
echo "benchmark=$(echo ${{ matrix.target }} | cut -d'/' -f2 | tr '[:upper:]' '[:lower:]')" >> ${GITHUB_OUTPUT}
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v5
with:
context: ${{ matrix.target }}
file: ${{ matrix.target }}/Dockerfile
platforms: linux/amd64
push: true
tags: ${{ env.REGISTRY }}/kupl/starlab-benchmarks/${{ steps.make-build-info.outputs.language }}:${{ steps.make-build-info.outputs.benchmark }}
labels: |
org.opencontainers.image.source="https://github.com/kupl/starlab-benchmarks"