Skip to content

Commit

Permalink
chore: two step build and publish with base image
Browse files Browse the repository at this point in the history
  • Loading branch information
henrylee97 committed Nov 28, 2023
1 parent 2739e48 commit 75e6ae0
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 2 deletions.
67 changes: 66 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,64 @@ env:
REGISTRY: ghcr.io

jobs:
find-updated-bases:
runs-on: ubuntu-latest

permissions:
contents: read

steps:
- uses: actions/checkout@v5
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@v5
- name: Make build info
id: make-build-info
run: |
echo "language=$(echo ${{ matrix.target }} | cut -d '/' -f 1 | tr '[:upper:]' '[:lower:]')" >> ${GITHUB_OUTPUT}
echo "project=$(echo ${{ matrix.target }} | cut -d '/' -f 2 )"
- uses: docker/setup-buildx-action@v3
- 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:
Expand All @@ -21,7 +78,14 @@ jobs:
fetch-depth: 2
- id: find-targets
run: |
projects=$(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 | xargs -I{prj} echo \"{prj}\" | tr '\n' ',' | sed 's/,*$//')
{
for base in $(echo ${{ needs.find-updated-bases.outputs.targets }} | jq -r '.[]'); do
base=$(echo $base | sed 's/-base//')
ls $base-*
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:
Expand All @@ -36,6 +100,7 @@ jobs:
packages: write

needs:
- build-base-images
- find-targets

if: always() && needs.find-targets.outputs.targets != '[]'
Expand Down
2 changes: 1 addition & 1 deletion C/snort-38/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM c-base/snort:cached
FROM ghcr.io/kupl/starlab-benchmarks/c-base:snort

RUN mkdir -p /workspace
WORKDIR /workspace
Expand Down

0 comments on commit 75e6ae0

Please sign in to comment.