Skip to content

Commit

Permalink
Tweak artifact CI and Makefile
Browse files Browse the repository at this point in the history
With the Linux image and ELF executable already separated, it is
also necessary to decouple the tags. Add the suffix 'Linux-Image'
for the Linux image release artifact and 'ELF' for the test bench
ELF executable.

Additionally, include the Buildroot and Linux kernel version files
in .ci/. Updating either of these files will trigger a rebuild of
the Linux image artifact.
  • Loading branch information
ChinYikMing committed Nov 11, 2024
1 parent fcf5848 commit 3432824
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 3 deletions.
1 change: 1 addition & 0 deletions .ci/buildroot_version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2024.05.2
1 change: 1 addition & 0 deletions .ci/linux_version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v6.1.y
54 changes: 53 additions & 1 deletion .github/workflows/build-artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ jobs:
tests/quake/**
tests/scimark2/**
tests/*.c
- name: Test file change of Linux image
id: test-linux-image-change
uses: tj-actions/changed-files@v45
with:
files: |
.ci/buildroot_version.txt
.ci/linux_version.txt
- name: Set alias
id: has_changed_files
run: |
Expand All @@ -35,8 +42,53 @@ jobs:
else
echo "has_changed_files=false" >> $GITHUB_OUTPUT
fi
if [[ ${{ steps.test-linux-image-change.outputs.any_modified }} == true ]]; then
echo "has_changed_linux_image=true" >> $GITHUB_OUTPUT
else
echo "has_changed_linux_image=false" >> $GITHUB_OUTPUT
fi
outputs:
has_changed_files: ${{ steps.has_changed_files.outputs.has_changed_files }}
has_changed_linux_image: ${{ steps.has_changed_files.outputs.has_changed_linux_image }}

build-linux-image-artifact:
needs: [detect-file-change]
if: ${{ needs.detect-file-change.outputs.has_changed_linux_image == 'true' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Install dependencies
run: |
sudo apt-get update -q -y
sudo apt-get upgrade -q -y
sudo apt-get install -q -y build-essential git
- name: Build Linux image
run: |
make artifact ENABLE_PREBUILT=0 ENABLE_SYSTEM=1
mkdir -p /tmp/rv32emu-linux-image-prebuilt
mv build/Image /tmp/rv32emu-linux-image-prebuilt
mv build/rootfs.cpio /tmp/rv32emu-linux-image-prebuilt
mv build/sha1sum-linux-image /tmp/rv32emu-linux-image-prebuilt
- name: Create tarball
run: |
cd /tmp
tar -zcvf rv32emu-linux-image-prebuilt.tar.gz rv32emu-linux-image-prebuilt
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.RV32EMU_PREBUILT_TOKEN }}
run: |
RELEASE_TAG=$(date +'%Y.%m.%d'-Linux-Image)
cd /tmp
gh release create $RELEASE_TAG \
--repo sysprog21/rv32emu-prebuilt \
--title "$RELEASE_TAG""-nightly"
gh release upload $RELEASE_TAG \
rv32emu-linux-image-prebuilt.tar.gz \
sha1sum-linux-image \
--repo sysprog21/rv32emu-prebuilt
build-artifact:
needs: [detect-file-change]
Expand Down Expand Up @@ -83,7 +135,7 @@ jobs:
env:
GH_TOKEN: ${{ secrets.RV32EMU_PREBUILT_TOKEN }}
run: |
RELEASE_TAG=$(date +'%Y.%m.%d')
RELEASE_TAG=$(date +'%Y.%m.%d'-ELF)
cd /tmp
gh release create $RELEASE_TAG \
--repo sysprog21/rv32emu-prebuilt \
Expand Down
27 changes: 25 additions & 2 deletions mk/artifact.mk
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ SCIMARK2_SHA1 := de278c5b8cef84ab6dda41855052c7bfef919e36
SHELL_HACK := $(shell mkdir -p $(BIN_DIR)/linux-x86-softfp $(BIN_DIR)/riscv32)

ifeq ($(call has, PREBUILT), 1)
LATEST_RELEASE := $(shell wget -q https://api.github.com/repos/sysprog21/rv32emu-prebuilt/releases/latest -O- | grep '"tag_name"' | sed -E 's/.*"tag_name": "([^"]+)".*/\1/')
ifeq ($(call has, SYSTEM), 1)
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/')
else
LATEST_RELEASE := $(shell wget -q https://api.github.com/repos/sysprog21/rv32emu-prebuilt/releases/latest -O- | grep '"tag_name"' | grep "ELF" | head -n 1 | sed -E 's/.*"tag_name": "([^"]+)".*/\1/')
endif
else
# Since rv32emu only supports the dynamic binary translation of integer instruction in tiered compilation currently,
# we disable the hardware floating-point and the related SIMD operation of x86.
Expand All @@ -53,24 +57,37 @@ endif
artifact: fetch-checksum ieeelib scimark2
ifeq ($(call has, PREBUILT), 1)
$(Q)$(PRINTF) "Checking SHA-1 of prebuilt binaries ... "
$(Q)$(eval RES := 0)

ifeq ($(call has, SYSTEM), 1)
$(Q)$(eval PREBUILT_LINUX_IMAGE_FILENAME := $(shell cat $(BIN_DIR)/sha1sum-linux-image | awk '{ print $$2 };'))

$(Q)$(eval $(foreach FILE,$(PREBUILT_LINUX_IMAGE_FILENAME), \
$(call verify,$(shell grep -w $(FILE) $(BIN_DIR)/sha1sum-linux-image | awk '{ print $$1 };'),$(BIN_DIR)/linux-image/$(FILE),RES) \
))
else
$(Q)$(eval PREBUILT_X86_FILENAME := $(shell cat $(BIN_DIR)/sha1sum-linux-x86-softfp | awk '{ print $$2 };'))
$(Q)$(eval PREBUILT_RV32_FILENAME := $(shell cat $(BIN_DIR)/sha1sum-riscv32 | awk '{ print $$2 };'))

$(Q)$(eval RES := 0)
$(Q)$(eval $(foreach FILE,$(PREBUILT_X86_FILENAME), \
$(call verify,$(shell grep -w $(FILE) $(BIN_DIR)/sha1sum-linux-x86-softfp | awk '{ print $$1 };'),$(BIN_DIR)/linux-x86-softfp/$(FILE),RES) \
))
$(Q)$(eval $(foreach FILE,$(PREBUILT_RV32_FILENAME), \
$(call verify,$(shell grep -w $(FILE) $(BIN_DIR)/sha1sum-riscv32 | awk '{ print $$1 };'),$(BIN_DIR)/riscv32/$(FILE),RES) \
))
endif

$(Q)if [ "$(RES)" = "1" ]; then \
$(PRINTF) "\n$(YELLOW)SHA-1 verification fails! Re-fetching prebuilt binaries from \"rv32emu-prebuilt\" ...\n$(NO_COLOR)"; \
wget -q --show-progress https://github.com/sysprog21/rv32emu-prebuilt/releases/download/$(LATEST_RELEASE)/rv32emu-prebuilt.tar.gz -O- | tar -C build --strip-components=1 -xz; \
else \
$(call notice, [OK]); \
fi
else
ifeq ($(call has, SYSTEM), 1)
$(Q)./tools/build-linux-image.sh
$(Q)($(SHA1SUM) $(BIN_DIR)/Image) >> $(BIN_DIR)/sha1sum-linux-image
$(Q)($(SHA1SUM) $(BIN_DIR)/rootfs.cpio) >> $(BIN_DIR)/sha1sum-linux-image
else
git submodule update --init $(addprefix ./tests/,$(foreach tb,$(TEST_SUITES),$(tb)))
$(Q)for tb in $(TEST_SUITES); do \
Expand Down Expand Up @@ -103,14 +120,20 @@ else
$(Q)(cd $(BIN_DIR)/linux-x86-softfp; for fd in *; do $(SHA1SUM) "$$fd"; done) >> $(BIN_DIR)/sha1sum-linux-x86-softfp
$(Q)(cd $(BIN_DIR)/riscv32; for fd in *; do $(SHA1SUM) "$$fd"; done) >> $(BIN_DIR)/sha1sum-riscv32
endif
endif

fetch-checksum:
ifeq ($(call has, PREBUILT), 1)
$(Q)$(PRINTF) "Fetching SHA-1 of prebuilt binaries ... "
ifeq ($(call has, SYSTEM), 1)
$(Q)wget -q -O $(BIN_DIR)/sha1sum-linux-image https://github.com/sysprog21/rv32emu-prebuilt/releases/download/$(LATEST_RELEASE)/sha1sum-linux-image
$(Q)$(call notice, [OK])
else
$(Q)wget -q -O $(BIN_DIR)/sha1sum-linux-x86-softfp https://github.com/sysprog21/rv32emu-prebuilt/releases/download/$(LATEST_RELEASE)/sha1sum-linux-x86-softfp
$(Q)wget -q -O $(BIN_DIR)/sha1sum-riscv32 https://github.com/sysprog21/rv32emu-prebuilt/releases/download/$(LATEST_RELEASE)/sha1sum-riscv32
$(Q)$(call notice, [OK])
endif
endif

scimark2:
ifeq ($(call has, PREBUILT), 0)
Expand Down

0 comments on commit 3432824

Please sign in to comment.