Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(cicd): make base image build step #62

Merged
merged 25 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3bf00cd
chore(cicd): make base image build step
henrylee97 Nov 28, 2023
d0c243a
Merge branch 'main' into base-constructor-image
henrylee97 Nov 28, 2023
4a5b1d1
feat: snort base image
henrylee97 Nov 28, 2023
56b0e50
chore: test image loading
henrylee97 Nov 28, 2023
c554c8d
Merge branch 'main' into base-constructor-image
henrylee97 Nov 28, 2023
25ac5db
feat: use base image
henrylee97 Nov 28, 2023
c0456b9
chore: debug updated
henrylee97 Nov 28, 2023
b0da892
refactor: restore always
henrylee97 Nov 28, 2023
d013c89
Update conditional statement in check.yml
henrylee97 Nov 28, 2023
a9c194f
fix: typo
henrylee97 Nov 28, 2023
812158a
fix: lang and proj parsing
henrylee97 Nov 28, 2023
0881648
fix: snort link
henrylee97 Nov 28, 2023
e76674b
fix: update docker cached image name
henrylee97 Nov 28, 2023
bbeb934
feat: load base before build
henrylee97 Nov 28, 2023
188ada0
feat: share cache with registry service
henrylee97 Nov 28, 2023
ebc564d
fix: correct output variable
henrylee97 Nov 28, 2023
e3a78f3
style: remove temporal comments
henrylee97 Nov 28, 2023
2739e48
fix: fix copy directory
henrylee97 Nov 28, 2023
75e6ae0
chore: two step build and publish with base image
henrylee97 Nov 28, 2023
10759e5
fix: updated base image usage
henrylee97 Nov 28, 2023
cf30a6d
refactor: make flex to use base image
henrylee97 Nov 29, 2023
38ad89c
perf: stream download and unzip
henrylee97 Nov 29, 2023
3158f76
fix: copy metadata only in snort
henrylee97 Nov 29, 2023
1cfef93
style: mark step name for visibility
henrylee97 Nov 29, 2023
8a16b14
fix: actions/checkout version
henrylee97 Nov 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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@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 '/' -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
96 changes: 76 additions & 20 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,61 +6,117 @@ on:
- main

jobs:
find-targets:
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 $base; do
base=$(echo $base | sed 's/-base//')
ls $base-*
done
} > 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 >> updated.txt
- id: find-targets
run: |
git fetch origin
projects=$(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 | xargs -I{prj} echo \"{prj}\" | tr '\n' ',' | sed 's/,*$//')
echo "targets=[$projects]" >> ${GITHUB_OUTPUT}
targets=$(cat 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 }}


build-test:
benchmarks-build-test:
runs-on: ubuntu-latest

permissions:
contents: read

needs:
- find-targets
- find-updated-benchmarks

if: always() && needs.find-targets.outputs.targets != '[]'
if: always() && needs.find-updated-benchmarks.outputs.targets != '[]'

strategy:
matrix:
target: ${{ fromJSON(needs.find-targets.outputs.targets) }}
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 '/' -f 1)
proj=$(echo ${{ matrix.target }} | cut -d '/' -f 2 | cut -d '-' -f 1)
ls ${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}
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v5
with:
context: ${{ matrix.target }}
file: ${{ matrix.target }}/Dockerfile
platforms: linux/amd64
push: false
tags: benchmark:latest
outputs: type=docker,dest=./image.tar
- name: Smoke test
run: |
docker load --input ./image.tar
docker run --rm benchmark:latest /bin/bash -c "cd ${{ steps.read-metadata.outputs.location }}; ${{ steps.read-metadata.outputs.buildCommand }}"
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
Expand All @@ -69,7 +125,7 @@ jobs:
pull-requests: write

needs:
- build-test
- benchmarks-build-test

if: always()

Expand Down
25 changes: 25 additions & 0 deletions C-base/flex/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM ubuntu:20.04

RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
autoconf \
automake \
autopoint \
bison \
build-essential \
ca-certificates \
flex \
git \
jq \
libtool \
texinfo \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /workspace
RUN git clone https://github.com/westes/flex.git buggy \
&& cd buggy \
&& git checkout d3de49f84224b18c5287653f20525291b24cc26e \
&& ./autogen.sh \
&& ./configure
35 changes: 35 additions & 0 deletions C-base/snort/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM ubuntu:20.04

RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
autopoint \
autoconf \
automake \
bison \
build-essential \
ca-certificates \
flex \
jq \
libdaq-dev \
libdumbnet-dev \
libluajit-5.1-dev \
libnghttp2-dev \
libpcap-dev \
libpcre3-dev \
libssl-dev \
libtasn1-dev \
libtool \
pkg-config \
wget \
zlib1g-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

COPY ./src /tmp/src
WORKDIR /workspace
RUN mkdir -p buggy \
&& wget -q "https://www.snort.org/downloads/archive/snort/snort-2.9.13.tar.gz" -O - | tar -zxvf - -C ./buggy --strip-components=1 \
&& mv /tmp/src/util.h /workspace/buggy/src/util.h \
&& cd buggy \
&& ./configure
2 changes: 1 addition & 1 deletion C/snort-38/util.h → C-base/snort/src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,4 +385,4 @@ static inline pid_t gettid(void)
}
#endif

#endif /*__UTIL_H__*/
#endif /*__UTIL_H__*/
30 changes: 2 additions & 28 deletions C/flex-1/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,4 @@
FROM ubuntu:20.04
FROM ghcr.io/kupl/starlab-benchmarks/c-base:flex

RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
autoconf \
automake \
autopoint \
bison \
build-essential \
ca-certificates \
flex \
git \
jq \
libtool \
texinfo \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN mkdir -p /workspace
COPY . /workspace
WORKDIR /workspace

RUN export BUGGY_PATH=$(cat metadata.json | jq -r ".buggyPath") \
&& git clone https://github.com/westes/flex.git $BUGGY_PATH \
&& cd $BUGGY_PATH \
&& git checkout d3de49f84224b18c5287653f20525291b24cc26e \
&& ./autogen.sh \
&& ./configure

COPY . /workspace
30 changes: 2 additions & 28 deletions C/flex-2/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,4 @@
FROM ubuntu:20.04
FROM ghcr.io/kupl/starlab-benchmarks/c-base:flex

RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
autoconf \
automake \
autopoint \
bison \
build-essential \
ca-certificates \
flex \
git \
jq \
libtool \
texinfo \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN mkdir -p /workspace
COPY . /workspace
WORKDIR /workspace

RUN export BUGGY_PATH=$(cat metadata.json | jq -r ".buggyPath") \
&& git clone https://github.com/westes/flex.git $BUGGY_PATH \
&& cd $BUGGY_PATH \
&& git checkout d3de49f84224b18c5287653f20525291b24cc26e \
&& ./autogen.sh \
&& ./configure

COPY . /workspace
Loading