From 1cbf456e6cb39ac4faacdcdf5ddd200f8a2ea473 Mon Sep 17 00:00:00 2001 From: Guilherme Dantas Date: Thu, 22 Aug 2024 16:51:39 -0300 Subject: [PATCH] Cache bounty example builds (#140) --- .github/workflows/build.yml | 5 +++++ tests/bounties/busybox-bounty/Makefile | 12 +++++++++++- tests/bounties/lua-bounty/Makefile | 12 +++++++++++- tests/bounties/solidity-bounty/Makefile | 12 +++++++++++- tests/bounties/sqlite-bounty/Makefile | 12 +++++++++++- 5 files changed, 49 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eb8c517..89bd3a8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/tests/bounties/busybox-bounty/Makefile b/tests/bounties/busybox-bounty/Makefile index 277925a..790ee66 100644 --- a/tests/bounties/busybox-bounty/Makefile +++ b/tests/bounties/busybox-bounty/Makefile @@ -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) @@ -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 diff --git a/tests/bounties/lua-bounty/Makefile b/tests/bounties/lua-bounty/Makefile index 5862556..49708a5 100644 --- a/tests/bounties/lua-bounty/Makefile +++ b/tests/bounties/lua-bounty/Makefile @@ -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) @@ -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 diff --git a/tests/bounties/solidity-bounty/Makefile b/tests/bounties/solidity-bounty/Makefile index 7354c0d..bf3ca9c 100644 --- a/tests/bounties/solidity-bounty/Makefile +++ b/tests/bounties/solidity-bounty/Makefile @@ -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 diff --git a/tests/bounties/sqlite-bounty/Makefile b/tests/bounties/sqlite-bounty/Makefile index 14609c3..3e44e1b 100644 --- a/tests/bounties/sqlite-bounty/Makefile +++ b/tests/bounties/sqlite-bounty/Makefile @@ -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) @@ -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