Skip to content

Commit

Permalink
Cache bounty example builds (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
guidanoli authored Aug 22, 2024
1 parent 8da662d commit 1cbf456
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ jobs:
id: setup_buildx
uses: docker/setup-buildx-action@v3

- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3

- name: Build bounty examples
run: make bounties
env:
BUILDX_BUILDER: ${{ steps.setup_buildx.outputs.name }}

- name: Extract metadata from Git refs and GitHub events
id: extract_metadata
Expand Down
12 changes: 11 additions & 1 deletion tests/bounties/busybox-bounty/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ BOUNTY_RISCV64_TAR=busybox-$(VERSION)-bounty_riscv64.tar.xz
HARDEN_CFLAGS=-Os -D_FORTIFY_SOURCE=2 -fPIE -fstack-clash-protection -fstack-protector-strong -ffunction-sections -fdata-sections -Wno-unused-result
HARDEN_LDFLAGS=-pie -Wl,-z,now,-z,relro,--gc-sections -s

# Use GitHub Actions cache when available
ifdef ACTIONS_RUNTIME_TOKEN
ifdef ACTIONS_RUNTIME_URL
ifdef BUILDX_BUILDER
SCOPE=busybox-$(VERSION)-bounty
DOCKEROPTIONS=--cache-from type=gha,scope=$(SCOPE) --cache-to type=gha,mode=max,scope=$(SCOPE) --load
endif
endif
endif

all: $(BOUNTY_TAR)

riscv64: $(BOUNTY_RISCV64_TAR)
Expand All @@ -33,7 +43,7 @@ $(SOURCE_TAR):

ifneq ($(ARCH), riscv64)
$(BOUNTY_RISCV64_TAR): Dockerfile start.sh
docker build --tag busybox-bounty-cp --file Dockerfile --progress plain --build-arg VERSION=$(VERSION) .
docker build --tag busybox-bounty-cp --file Dockerfile --progress plain --build-arg VERSION=$(VERSION) $(DOCKEROPTIONS) .
docker create --platform=linux/riscv64 --name busybox-bounty-cp busybox-bounty-cp
docker cp busybox-bounty-cp:/root/$@ $@
docker rm busybox-bounty-cp
Expand Down
12 changes: 11 additions & 1 deletion tests/bounties/lua-bounty/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ BOUNTY_RISCV64_TAR=lua-$(VERSION)-bounty_riscv64.tar.xz
HARDEN_CFLAGS=-Os -D_FORTIFY_SOURCE=2 -fexceptions -fPIE -fstack-clash-protection -fstack-protector-strong -ffunction-sections -fdata-sections
HARDEN_LDFLAGS=-pie -Wl,-z,now,-z,relro,--gc-sections -s

# Use GitHub Actions cache when available
ifdef ACTIONS_RUNTIME_TOKEN
ifdef ACTIONS_RUNTIME_URL
ifdef BUILDX_BUILDER
SCOPE=lua-$(VERSION)-bounty
DOCKEROPTIONS=--cache-from type=gha,scope=$(SCOPE) --cache-to type=gha,mode=max,scope=$(SCOPE) --load
endif
endif
endif

all: $(BOUNTY_TAR)

riscv64: $(BOUNTY_RISCV64_TAR)
Expand All @@ -31,7 +41,7 @@ $(SOURCE_TAR):

ifneq ($(ARCH), riscv64)
$(BOUNTY_RISCV64_TAR): Dockerfile start.sh bounty.lua
docker build --tag lua-bounty-cp --file Dockerfile --progress plain --build-arg VERSION=$(VERSION) .
docker build --tag lua-bounty-cp --file Dockerfile --progress plain --build-arg VERSION=$(VERSION) $(DOCKEROPTIONS) .
docker create --platform=linux/riscv64 --name lua-bounty-cp lua-bounty-cp
docker cp lua-bounty-cp:/root/$@ $@
docker rm lua-bounty-cp
Expand Down
12 changes: 11 additions & 1 deletion tests/bounties/solidity-bounty/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@ ARCH=$(shell uname -m)
VERSION=0.8.26
BOUNTY_RISCV64_TAR=solidity-$(VERSION)-bounty_riscv64.tar.xz

# Use GitHub Actions cache when available
ifdef ACTIONS_RUNTIME_TOKEN
ifdef ACTIONS_RUNTIME_URL
ifdef BUILDX_BUILDER
SCOPE=solidity-$(VERSION)-bounty
DOCKEROPTIONS=--cache-from type=gha,scope=$(SCOPE) --cache-to type=gha,mode=max,scope=$(SCOPE) --load
endif
endif
endif

riscv64: $(BOUNTY_RISCV64_TAR)

$(BOUNTY_RISCV64_TAR): Dockerfile start.sh
docker build --tag solidity-bounty-cp --file Dockerfile --progress plain --build-arg VERSION=$(VERSION) .
docker build --tag solidity-bounty-cp --file Dockerfile --progress plain --build-arg VERSION=$(VERSION) $(DOCKEROPTIONS) .
docker create --name solidity-bounty-cp solidity-bounty-cp
docker cp solidity-bounty-cp:/root/$@ $@
docker rm solidity-bounty-cp
Expand Down
12 changes: 11 additions & 1 deletion tests/bounties/sqlite-bounty/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ HARDEN_LDFLAGS=-pie -Wl,-z,now,-z,relro,--gc-sections
SQLITE_CFLAGS=-DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION
SQLITE_LDFLAGS=-lm -s

# Use GitHub Actions cache when available
ifdef ACTIONS_RUNTIME_TOKEN
ifdef ACTIONS_RUNTIME_URL
ifdef BUILDX_BUILDER
SCOPE=sqlite-$(VERSION)-bounty
DOCKEROPTIONS=--cache-from type=gha,scope=$(SCOPE) --cache-to type=gha,mode=max,scope=$(SCOPE) --load
endif
endif
endif

all: $(BOUNTY_TAR)

riscv64: $(BOUNTY_RISCV64_TAR)
Expand All @@ -37,7 +47,7 @@ $(SOURCE_TAR):

ifneq ($(ARCH), riscv64)
$(BOUNTY_RISCV64_TAR): Dockerfile start.sh
docker build --tag sqlite-bounty-cp --file Dockerfile --progress plain --build-arg VERSION=$(VERSION) .
docker build --tag sqlite-bounty-cp --file Dockerfile --progress plain --build-arg VERSION=$(VERSION) $(DOCKEROPTIONS) .
docker create --platform=linux/riscv64 --name sqlite-bounty-cp sqlite-bounty-cp
docker cp sqlite-bounty-cp:/root/$@ $@
docker rm sqlite-bounty-cp
Expand Down

0 comments on commit 1cbf456

Please sign in to comment.