Skip to content

Commit 0ec87f3

Browse files
committed
CI: Reduce HTTP requests
Check prebuilt tarballs are existing or not first. If so, skip the downloading of releases tags and tarballs. In the CI, we first call "make artifact" to prepare the tarballs, so the GitHub API for fetching releases tags would not be called and be skipped when "make" is called next time.
1 parent d1ed003 commit 0ec87f3

File tree

3 files changed

+54
-20
lines changed

3 files changed

+54
-20
lines changed

.github/workflows/main.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,20 @@ jobs:
5858
uses: rlalik/setup-cpp-compiler@master
5959
with:
6060
compiler: ${{ matrix.compiler }}
61+
- name: fetch artifact first to reduce HTTP requests
62+
env:
63+
CC: ${{ steps.install_cc.outputs.cc }}
64+
run: |
65+
make artifact
66+
make ENABLE_SYSTEM=1 artifact
67+
make ENABLE_ARCH_TEST=1 artifact
68+
if: ${{ always() }}
6169
- name: default build with -g
6270
env:
6371
CC: ${{ steps.install_cc.outputs.cc }}
64-
run: make OPT_LEVEL=-g -j$(nproc)
72+
run: |
73+
make distclean
74+
make OPT_LEVEL=-g -j$(nproc)
6575
if: ${{ always() }}
6676
- name: default build with -Og
6777
env:
@@ -268,6 +278,7 @@ jobs:
268278
./llvm.sh 18
269279
# Append custom commands here
270280
run: |
281+
make artifact
271282
make -j$(nproc)
272283
make check -j$(nproc)
273284
make ENABLE_JIT=1 clean && make ENABLE_JIT=1 check -j$(nproc)

Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,6 @@ endif
416416
clean:
417417
$(RM) $(BIN) $(OBJS) $(DEV_OBJS) $(BUILD_DTB) $(BUILD_DTB2C) $(HIST_BIN) $(HIST_OBJS) $(deps) $(WEB_FILES) $(CACHE_OUT) src/rv32_jit.c
418418
distclean: clean
419-
-$(RM) $(DOOM_DATA) $(QUAKE_DATA) $(BUILDROOT_DATA) $(LINUX_DATA)
420-
$(RM) -r $(OUT)/linux-image
421-
$(RM) -r $(TIMIDITY_DATA)
422419
$(RM) -r $(OUT)/id1
423420
$(RM) -r $(DEMO_DIR)
424421
$(RM) *.zip

mk/artifact.mk

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,27 @@ SCIMARK2_SHA1 := de278c5b8cef84ab6dda41855052c7bfef919e36
3737
SHELL_HACK := $(shell mkdir -p $(BIN_DIR)/linux-x86-softfp $(BIN_DIR)/riscv32 $(BIN_DIR)/linux-image)
3838

3939
ifeq ($(call has, PREBUILT), 1)
40-
ifeq ($(call has, SYSTEM), 1)
41-
LATEST_RELEASE := $(shell wget -q https://api.github.com/repos/sysprog21/rv32emu-prebuilt/releases -O- | grep '"tag_name"' | grep "Linux-Image" | head -n 1 | sed -E 's/.*"tag_name": "([^"]+)".*/\1/')
42-
else ifeq ($(call has, ARCH_TEST), 1)
43-
LATEST_RELEASE := $(shell wget -q https://api.github.com/repos/sysprog21/rv32emu-prebuilt/releases -O- | grep '"tag_name"' | grep "sail" | head -n 1 | sed -E 's/.*"tag_name": "([^"]+)".*/\1/')
44-
else
45-
LATEST_RELEASE := $(shell wget -q https://api.github.com/repos/sysprog21/rv32emu-prebuilt/releases -O- | grep '"tag_name"' | grep "ELF" | head -n 1 | sed -E 's/.*"tag_name": "([^"]+)".*/\1/')
46-
endif
47-
PREBUILT_BLOB_URL = https://github.com/sysprog21/rv32emu-prebuilt/releases/download/$(LATEST_RELEASE)
40+
ifeq ($(call has, SYSTEM), 1)
41+
ifeq ($(wildcard $(BIN_DIR)/rv32emu-linux-image-prebuilt.tar.gz),)
42+
LATEST_RELEASE := $(shell wget -q https://api.github.com/repos/sysprog21/rv32emu-prebuilt/releases -O- | grep '"tag_name"' | grep "Linux-Image" | head -n 1 | sed -E 's/.*"tag_name": "([^"]+)".*/\1/')
43+
else
44+
$(info Linux Image is found. Skipping downloading.)
45+
endif
46+
else ifeq ($(call has, ARCH_TEST), 1)
47+
ifeq ($(wildcard $(BIN_DIR)/rv32emu-prebuilt-sail-$(HOST_PLATFORM)),)
48+
LATEST_RELEASE := $(shell wget -q https://api.github.com/repos/sysprog21/rv32emu-prebuilt/releases -O- | grep '"tag_name"' | grep "sail" | head -n 1 | sed -E 's/.*"tag_name": "([^"]+)".*/\1/')
49+
else
50+
$(info Sail model is found. Skipping downloading.)
51+
endif
52+
else
53+
ifeq ($(wildcard $(BIN_DIR)/rv32emu-prebuilt.tar.gz),)
54+
LATEST_RELEASE := $(shell wget -q https://api.github.com/repos/sysprog21/rv32emu-prebuilt/releases -O- | grep '"tag_name"' | grep "ELF" | head -n 1 | sed -E 's/.*"tag_name": "([^"]+)".*/\1/')
55+
else
56+
$(info Prebuilt benchmarks are found. Skipping downloading.)
57+
endif
58+
endif
59+
60+
PREBUILT_BLOB_URL = https://github.com/sysprog21/rv32emu-prebuilt/releases/download/$(LATEST_RELEASE)
4861
else
4962
# Since rv32emu only supports the dynamic binary translation of integer instruction in tiered compilation currently,
5063
# we disable the hardware floating-point and the related SIMD operation of x86.
@@ -95,14 +108,15 @@ endif
95108
ifeq ($(call has, ARCH_TEST), 1)
96109
$(Q)if [ "$(RES)" = "1" ]; then \
97110
$(PRINTF) "\n$(YELLOW)SHA-1 verification failed! Re-fetching prebuilt binaries from \"rv32emu-prebuilt\" ...\n$(NO_COLOR)"; \
98-
wget -q --show-progress $(PREBUILT_BLOB_URL)/$(RV32EMU_PREBUILT_TARBALL) -O build/$(RV32EMU_PREBUILT_TARBALL);\
111+
wget -q --show-progress $(PREBUILT_BLOB_URL)/$(RV32EMU_PREBUILT_TARBALL) -O build/$(RV32EMU_PREBUILT_TARBALL); \
99112
else \
100113
$(call notice, [OK]); \
101114
fi
102115
else
103116
$(Q)if [ "$(RES)" = "1" ]; then \
104117
$(PRINTF) "\n$(YELLOW)SHA-1 verification failed! Re-fetching prebuilt binaries from \"rv32emu-prebuilt\" ...\n$(NO_COLOR)"; \
105-
wget -q --show-progress $(PREBUILT_BLOB_URL)/$(RV32EMU_PREBUILT_TARBALL) -O- | tar -C build --strip-components=1 -xz; \
118+
wget -q --show-progress $(PREBUILT_BLOB_URL)/$(RV32EMU_PREBUILT_TARBALL) -O build/$(RV32EMU_PREBUILT_TARBALL); \
119+
tar --strip-components=1 -zxf build/$(RV32EMU_PREBUILT_TARBALL) -C build; \
106120
else \
107121
$(call notice, [OK]); \
108122
fi
@@ -149,14 +163,26 @@ fetch-checksum:
149163
ifeq ($(call has, PREBUILT), 1)
150164
$(Q)$(PRINTF) "Fetching SHA-1 of prebuilt binaries ...\n"
151165
ifeq ($(call has, SYSTEM), 1)
152-
$(Q)wget -q -O $(BIN_DIR)/sha1sum-linux-image $(PREBUILT_BLOB_URL)/sha1sum-linux-image
153-
$(Q)$(call notice, [OK])
166+
ifeq ($(wildcard $(BIN_DIR)/rv32emu-linux-image-prebuilt.tar.gz),)
167+
wget -q -O $(BIN_DIR)/sha1sum-linux-image $(PREBUILT_BLOB_URL)/sha1sum-linux-image
168+
$(Q)$(call notice, [OK])
169+
else
170+
$(info Downloading skipped.)
171+
endif
154172
else ifeq ($(call has, ARCH_TEST), 1)
155-
$(Q)wget -q -O $(BIN_DIR)/rv32emu-prebuilt-sail-$(HOST_PLATFORM).sha $(PREBUILT_BLOB_URL)/rv32emu-prebuilt-sail-$(HOST_PLATFORM).sha
173+
ifeq ($(wildcard $(BIN_DIR)/rv32emu-prebuilt-sail-$(HOST_PLATFORM)),)
174+
wget -q -O $(BIN_DIR)/rv32emu-prebuilt-sail-$(HOST_PLATFORM).sha $(PREBUILT_BLOB_URL)/rv32emu-prebuilt-sail-$(HOST_PLATFORM).sha
175+
else
176+
$(info Downloading skipped.)
177+
endif
156178
else
157-
$(Q)wget -q -O $(BIN_DIR)/sha1sum-linux-x86-softfp $(PREBUILT_BLOB_URL)/sha1sum-linux-x86-softfp
158-
$(Q)wget -q -O $(BIN_DIR)/sha1sum-riscv32 $(PREBUILT_BLOB_URL)/sha1sum-riscv32
159-
$(Q)$(call notice, [OK])
179+
ifeq ($(wildcard $(BIN_DIR)/rv32emu-prebuilt.tar.gz),)
180+
wget -q -O $(BIN_DIR)/sha1sum-linux-x86-softfp $(PREBUILT_BLOB_URL)/sha1sum-linux-x86-softfp
181+
wget -q -O $(BIN_DIR)/sha1sum-riscv32 $(PREBUILT_BLOB_URL)/sha1sum-riscv32
182+
$(Q)$(call notice, [OK])
183+
else
184+
$(info Downloading skipped.)
185+
endif
160186
endif
161187
endif
162188

0 commit comments

Comments
 (0)