diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 62ce81871c96..db1a00b74b63 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -81,6 +81,7 @@ jobs: - uses: actions/checkout@v4 - name: Setup Rust toolchain run: ./ci/install-rust.sh + - name: Run natively if: "!matrix.docker" run: ./ci/run.sh ${{ matrix.target }} @@ -88,6 +89,15 @@ jobs: if: "matrix.docker" run: ./ci/run-docker.sh ${{ matrix.target }} + - name: Create CI artifacts + if: always() + run: ./ci/create-artifacts.sh + - uses: actions/upload-artifact@v4 + with: + name: ${{ env.ARCHIVE_NAME }} + path: ${{ env.ARCHIVE_PATH }} + retention-days: 5 + test_tier2: name: Test tier2 needs: [test_tier1, style_check] @@ -132,9 +142,19 @@ jobs: - uses: actions/checkout@v4 - name: Setup Rust toolchain run: ./ci/install-rust.sh + - name: Execute run-docker.sh run: ./ci/run-docker.sh ${{ matrix.target }} + - name: Create CI artifacts + if: always() + run: ./ci/create-artifacts.sh + - uses: actions/upload-artifact@v4 + with: + name: ${{ env.ARCHIVE_NAME }} + path: ${{ env.ARCHIVE_PATH }} + retention-days: 5 + test_tier2_vm: name: Test tier2 VM needs: [test_tier1, style_check] diff --git a/ci/create-artifacts.sh b/ci/create-artifacts.sh new file mode 100755 index 000000000000..0ae0d5542084 --- /dev/null +++ b/ci/create-artifacts.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +set -eux + +# Create a tarball of intermediate output for inspection if tests fail. + +# Find the most recently touched file named "main.c" in the target directory. +# This will be libc-tests's `OUT_DIR` +out_dir="$( + find target -name 'main.c' -exec ls -t {} + | + head -n1 | + xargs dirname +)" + +out_name="archive-$(date -u -Iseconds | sed 's/://g')" +(cd "$out_dir" && find -E . -regex '.*\.(rs|c)')") > file_list.txt + +tar -czvf "${out_name}.tar.gz" -C "$out_dir" -T file_list.txt + +if [ -n "$CI" ]; then + echo "ARCHIVE_NAME=${out_name}" >> "$GITHUB_ENV" + echo "ARCHIVE_PATH=${out_name}.tar.gz" >> "$GITHUB_ENV" +fi