-
Notifications
You must be signed in to change notification settings - Fork 1.3k
restructure actions to reusable build flow with parameters #1779
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,174 @@ | ||
| name: Build | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| artifact-name: | ||
| description: "Named identifier for the artifact" | ||
| required: true | ||
| type: string | ||
| os: | ||
| description: "OS list" | ||
| type: string | ||
| default: '["ubuntu-22.04","ubuntu-24.04"]' | ||
| mode: | ||
| description: "Mode list" | ||
| type: string | ||
| default: '["newlib","linux","musl","uclibc"]' | ||
| target: | ||
| description: "Target list" | ||
| type: string | ||
| default: '["rv32gc-ilp32d","rv64gc-lp64d"]' | ||
| compiler: | ||
| description: "Compiler list" | ||
| type: string | ||
| default: '["gcc","llvm"]' | ||
| sim: | ||
| description: "Simulator" | ||
| type: string | ||
| default: '[""]' | ||
|
|
||
| env: | ||
| submodule_paths: | | ||
| binutils | ||
| dejagnu | ||
| gcc | ||
| gdb | ||
| glibc | ||
| llvm | ||
| musl | ||
| newlib | ||
| pk | ||
| qemu | ||
| spike | ||
| uclibc-ng | ||
| .git/modules | ||
|
|
||
| jobs: | ||
| report: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Report inputs | ||
| run: | | ||
| echo "Artifact name: ${{ inputs.artifact-name }}" | ||
| echo "OS list: ${{ inputs.os }}" | ||
| echo "Mode list: ${{ inputs.mode }}" | ||
| echo "Target list: ${{ inputs.target }}" | ||
| echo "Compiler list: ${{ inputs.compiler }}" | ||
| echo "Simulator: ${{ inputs.sim }}" | ||
|
|
||
| submodule_cache: | ||
| name: Initialize submodule cache | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| key: ${{ steps.keygen.outputs.smcache_key }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Remove unneeded frameworks to recover disk space | ||
| run: sudo ./.github/cleanup-rootfs.sh | ||
|
|
||
| - name: Generate submodule cache key | ||
| id: keygen | ||
| run: echo "smcache_key=smcache-$(printf $(git submodule | sha1sum))" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Setup submodule cache | ||
| id: smcache | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ${{ env.submodule_paths }} | ||
| key: ${{ steps.keygen.outputs.smcache_key }} | ||
|
|
||
| - name: Checkout required submodules | ||
| if: steps.smcache.outputs.cache-hit != 'true' | ||
| run: git submodule update --init -j $(nproc) --depth 1 $(echo ${submodule_paths} | sed '$d' | tr '\n' ' ') | ||
|
|
||
| - name: Storage size optimization | ||
| if: steps.smcache.outputs.cache-hit != 'true' | ||
| run: | | ||
| git submodule foreach 'git maintenance run' | ||
|
|
||
| build: | ||
| runs-on: ${{ matrix.os }} | ||
| needs: [submodule_cache] | ||
| env: | ||
| smcache_key: ${{ needs.submodule_cache.outputs.key }} | ||
| strategy: | ||
| matrix: | ||
| os: ${{ fromJSON(inputs.os) }} | ||
| mode: ${{ fromJSON(inputs.mode) }} | ||
| target: ${{ fromJSON(inputs.target) }} | ||
| compiler: ${{ fromJSON(inputs.compiler) }} | ||
| sim: ${{ fromJSON(inputs.sim) }} | ||
kito-cheng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| exclude: | ||
| - mode: musl | ||
| compiler: llvm | ||
| - mode: uclibc | ||
| compiler: llvm | ||
| outputs: | ||
| toolchain-name: ${{ steps.toolchain-name-generator.outputs.TOOLCHAIN_NAME }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Remove unneeded frameworks to recover disk space | ||
| run: sudo ./.github/cleanup-rootfs.sh | ||
|
|
||
| - name: install dependencies | ||
| run: sudo ./.github/setup-apt.sh | ||
|
|
||
| - name: Load submodule cache | ||
| uses: actions/cache/restore@v4 | ||
| with: | ||
| path: ${{ env.submodule_paths }} | ||
| key: ${{ env.smcache_key }} | ||
|
|
||
| - name: build toolchain | ||
| run: | | ||
| TARGET_TUPLE=($(echo ${{ matrix.target }} | tr "-" "\n")) | ||
| BUILD_TOOLCHAIN="./configure --prefix=/mnt/riscv --with-arch=${TARGET_TUPLE[0]} --with-abi=${TARGET_TUPLE[1]}" | ||
| ARGS="" | ||
| if [ "${{ matrix.compiler }}" == "llvm" ]; then # build toolchain with llvm | ||
| ARGS="$ARGS --enable-llvm" | ||
| fi | ||
| if [ -n "${{ matrix.sim }}" ]; then | ||
| ARGS="$ARGS --with-sim=${{ matrix.sim }}" | ||
| fi | ||
kito-cheng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| $BUILD_TOOLCHAIN $ARGS | ||
| sudo mkdir /mnt/riscv | ||
| sudo chown runner:runner /mnt/riscv | ||
| make -j $(nproc) ${{ matrix.mode }} | ||
|
|
||
| - name: tarball build | ||
| run: | | ||
| du -s -h /mnt/riscv | ||
| ./.github/dedup-dir.sh /mnt/riscv/ | ||
| XZ_OPT="-e -T0" tar cJvf riscv.tar.xz -C /mnt/ riscv/ | ||
|
|
||
| - name: make report | ||
| if: | | ||
| matrix.os == 'ubuntu-24.04' | ||
| && (matrix.mode == 'linux' || matrix.mode == 'newlib') | ||
| && matrix.compiler == 'gcc' | ||
| run: | | ||
| make report-${{ matrix.mode }} -j $(nproc) | ||
|
|
||
| - name: generate prebuilt toolchain name | ||
| id: toolchain-name-generator | ||
| run: | | ||
| if [[ "${{ matrix.target }}" == *"32"* ]]; then BITS=32; else BITS=64; fi | ||
| case "${{ matrix.mode }}" in | ||
| "linux") | ||
| MODE="glibc";; | ||
| "musl") | ||
| MODE="musl";; | ||
| "uclibc") | ||
| MODE="uclibc-ng";; | ||
| *) | ||
| MODE="elf";; | ||
| esac | ||
| echo "TOOLCHAIN_NAME=riscv$BITS-$MODE-${{ matrix.os }}-${{ matrix.compiler }}-${{ inputs.artifact-name }}" >> $GITHUB_OUTPUT | ||
|
|
||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ steps.toolchain-name-generator.outputs.TOOLCHAIN_NAME }} | ||
| path: riscv.tar.xz | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.