# Syntax reference: # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions name: Shadow Tests permissions: read-all defaults: run: shell: bash on: pull_request: types: [opened, synchronize] env: CARGO_TERM_COLOR: always jobs: shadow: strategy: matrix: container: # End of standard support: April 2027 https://wiki.ubuntu.com/Releases - 'ubuntu:22.04' # End of standard support: June 2029 https://wiki.ubuntu.com/Releases - 'ubuntu:24.04' # EOL ~June 2026 https://wiki.debian.org/LTS - 'debian:11-slim' # EOL June 2028 https://wiki.debian.org/LTS - 'debian:12-slim' # EOL June 2030 https://wiki.debian.org/LTS - 'debian:13-slim' # EOL May 2026 https://endoflife.date/fedora - 'fedora:42' cc: ['gcc'] buildtype: ['release'] include: # Run some tests on the newest-available clang. Testing clang on # *every* platform is a bit overkill, but testing on at least one # gives decent "bang for the buck" of testing compatibility with # clang's most recent diagnostics and optimizations. - container: 'ubuntu:22.04' cc: 'clang' buildtype: 'release' # Test a debug build for each compiler. - container: 'ubuntu:22.04' cc: 'gcc' buildtype: 'debug' - container: 'ubuntu:22.04' cc: 'clang' buildtype: 'debug' # Tests are all run in containers; just use the latest base image. runs-on: ubuntu-latest container: image: ${{ matrix.container }} # the default shm-size for ubuntu:18.04, but with the size increased from # 65536k. github's default docker seccomp policy seems to disallow # process_vm_readv and process_vm_writev; disable it altogether. See # https://docs.docker.com/engine/security/seccomp/ options: '--shm-size=1024g --security-opt seccomp=unconfined' env: CC: ${{ matrix.cc }} CONTAINER: ${{ matrix.container }} BUILDTYPE: ${{ matrix.buildtype }} # for sccache: ## Invoke cargo via sccache RUSTC_WRAPPER: sccache ## Set max cache size SCCACHE_CACHE_SIZE: 2G ## Set cache path SCCACHE_DIR: /home/runner/.cache/sccache ## sccache doesn't work on incrmentally compiled crates, and incremental ## compilation doesn't help us here anyway. CARGO_INCREMENTAL: false ## Increment to force eviction of previous caches, e.g. if the sccache configuration ## or usage has changed in a way to make the previous cache not useful. ## Keep in sync with same variable in `extra_tests.yml`. SCCACHE_CACHE_VERSION: 1 steps: - name: Checkout uses: actions/checkout@v5 with: persist-credentials: false # Run on PR head instead of merge result. Running on the merge # result can give confusing results, and we require PR to be up to # date with target branch before merging, anyway. # See https://github.com/shadow/shadow/issues/2166 ref: ${{ github.event.pull_request.head.sha }} - name: Get month id: get-month run: | echo "month=$(/bin/date -u "+%Y%m")" >> $GITHUB_OUTPUT - name: Install dependencies run: | . ci/container_scripts/install_deps.sh . ci/container_scripts/install_extra_deps.sh echo "$HOME/.cargo/bin" >> $GITHUB_PATH - name: Restore cargo registry cache uses: actions/cache@v4 with: path: | ~/.cargo/registry ~/.cargo/git # key *and* restore-keys include the month to force a monthly reset instead # of unbounded growth. key: cargo-registry-${{ steps.get-month.outputs.month }}-${{ hashFiles('src/Cargo.lock') }} restore-keys: | cargo-registry-${{ steps.get-month.outputs.month }} - name: Get rust version id: get-rustv run: | echo rustv=\"$(rustc --version)\" >> $GITHUB_OUTPUT - name: Restore sccache cache uses: actions/cache@v4 continue-on-error: false with: path: ${{ env.SCCACHE_DIR }} # TODO: Consider whether we can safely drop e.g. CC, CONTAINER, and/or BUILDTYPE, # merging those caches. # # sccache won't cache crates that "invoke the system linker". If that means it # won't cache crates that link with platform libraries, then I think we can merge # the caches. I'm not sure whether or not it does, though. # https://github.com/mozilla/sccache#rust key: sccache-${{ steps.get-month.outputs.month }}-${{ steps.get-rustv.outputs.rustv }}-${{ env.CONTAINER }}-${{ env.CC }}-${{ env.BUILDTYPE }}-${{ env.SCCACHE_CACHE_VERSION}}-${{ hashFiles('src/Cargo.lock') }} restore-keys: | sccache-${{ steps.get-month.outputs.month }}-${{ steps.get-rustv.outputs.rustv }}-${{ env.CONTAINER }}-${{ env.CC }}-${{ env.BUILDTYPE }}-${{ env.SCCACHE_CACHE_VERSION}}- - name: Install sccache env: LINK: https://github.com/mozilla/sccache/releases/download SCCACHE_VERSION: v0.3.1 run: | SCCACHE_FILE=sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl mkdir -p $HOME/.local/bin curl -v -L "$LINK/$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache chmod +x $HOME/.local/bin/sccache echo "$HOME/.local/bin" >> $GITHUB_PATH - name: Start sccache server run: sccache --start-server - name: Build run: . ci/container_scripts/build_and_install.sh - name: Test run: . ci/container_scripts/test.sh - name: Compress logs if: failure() run: | shopt -s globstar tar -cJf build/Testing/Temporary{.tar.xz,/} for f in build/**/*.data; do tar -cJf "$f.tar.xz" "$f/"; done - name: Upload shadow data directories uses: actions/upload-artifact@v4 if: failure() with: name: shadow-data-dirs path: build/**/*.data.tar.xz - name: Upload shadow log file uses: actions/upload-artifact@v4 if: failure() with: name: shadow-log-file path: build/Testing/Temporary.tar.xz