From a141729113036517a7eb21043d1f5b537c09e746 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sat, 25 Mar 2023 10:00:52 +0100 Subject: [PATCH] CI: move freebsd & android jobs in separate workflows This because they are intermittent. When reviewing, I wish we didn't have to scroll to check that it is indeed freebsd or android failing. --- .github/workflows/CICD.yml | 140 ---------------------------------- .github/workflows/android.yml | 72 +++++++++++++++++ .github/workflows/freebsd.yml | 90 ++++++++++++++++++++++ 3 files changed, 162 insertions(+), 140 deletions(-) create mode 100644 .github/workflows/android.yml create mode 100644 .github/workflows/freebsd.yml diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index b7629ab46..1247b8abd 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -1027,146 +1027,6 @@ jobs: name: toybox-result.json path: ${{ steps.vars.outputs.TEST_SUMMARY_FILE }} - test_android: - name: Test Android builds - needs: [ min_version, deps ] - runs-on: macos-latest - timeout-minutes: 90 - strategy: - fail-fast: false - matrix: - api-level: [28] - target: [default] - arch: [x86] # , arm64-v8a - env: - TERMUX: v0.118.0 - SCCACHE_GHA_ENABLED: "true" - RUSTC_WRAPPER: "sccache" - steps: - - uses: actions/checkout@v3 - - uses: Swatinem/rust-cache@v2 - - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.3 - - name: AVD cache - uses: actions/cache@v3 - id: avd-cache - with: - path: | - ~/.android/avd/* - ~/.android/avd/*/snapshots/* - ~/.android/adb* - key: avd-${{ matrix.api-level }}-${{ matrix.arch }}+termux-${{ env.TERMUX }} - - name: Create and cache emulator image - if: steps.avd-cache.outputs.cache-hit != 'true' - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: ${{ matrix.api-level }} - target: ${{ matrix.target }} - arch: ${{ matrix.arch }} - ram-size: 2048M - disk-size: 5120M - force-avd-creation: true - emulator-options: -no-snapshot-load -noaudio -no-boot-anim -camera-back none - script: | - wget https://github.com/termux/termux-app/releases/download/${{ env.TERMUX }}/termux-app_${{ env.TERMUX }}+github-debug_${{ matrix.arch }}.apk - util/android-commands.sh snapshot termux-app_${{ env.TERMUX }}+github-debug_${{ matrix.arch }}.apk - adb -s emulator-5554 emu avd snapshot save ${{ matrix.api-level }}-${{ matrix.arch }}+termux-${{ env.TERMUX }} - echo "Emulator image created." - pkill -9 qemu-system-x86_64 - - name: Build and Test on Android - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: ${{ matrix.api-level }} - target: ${{ matrix.target }} - arch: ${{ matrix.arch }} - ram-size: 2048M - disk-size: 5120M - force-avd-creation: false - emulator-options: -no-snapshot-save -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -snapshot ${{ matrix.api-level }}-${{ matrix.arch }}+termux-${{ env.TERMUX }} - script: | - util/android-commands.sh sync - util/android-commands.sh build - util/android-commands.sh tests - - test_freebsd: - name: Tests/FreeBSD test suite - needs: [ min_version, deps ] - runs-on: ${{ matrix.job.os }} - timeout-minutes: 90 - strategy: - fail-fast: false - matrix: - job: - - { os: macos-12 , features: unix } ## GHA MacOS-11.0 VM won't have VirtualBox; refs: , - env: - mem: 4096 - SCCACHE_GHA_ENABLED: "true" - RUSTC_WRAPPER: "sccache" - steps: - - uses: actions/checkout@v3 - - uses: Swatinem/rust-cache@v2 - - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.3 - - name: Prepare, build and test - ## spell-checker:ignore (ToDO) sshfs usesh vmactions - uses: vmactions/freebsd-vm@v0.3.0 - with: - usesh: true - # sync: sshfs - prepare: pkg install -y curl gmake sudo - run: | - ## Prepare, build, and test - # implementation modelled after ref: - # * NOTE: All steps need to be run in this block, otherwise, we are operating back on the mac host - set -e - # - # We need a file-descriptor file system to test test_ls::test_ls_io_errors - mount -t fdescfs fdesc /dev/fd - # - TEST_USER=tester - REPO_NAME=${GITHUB_WORKSPACE##*/} - WORKSPACE_PARENT="/Users/runner/work/${REPO_NAME}" - WORKSPACE="${WORKSPACE_PARENT}/${REPO_NAME}" - # - pw adduser -n ${TEST_USER} -d /root/ -g wheel -c "Coreutils user to build" -w random - # chown -R ${TEST_USER}:wheel /root/ "${WORKSPACE_PARENT}"/ - chown -R ${TEST_USER}:wheel /root/ "/Users/runner/work/${REPO_NAME}"/ - whoami - # - # Further work needs to be done in a sudo as we are changing users - sudo -i -u ${TEST_USER} sh << EOF - set -e - whoami - curl https://sh.rustup.rs -sSf --output rustup.sh - sh rustup.sh -y --profile=minimal - . $HOME/.cargo/env - ## Info - # environment - echo "## environment" - echo "CI='${CI}'" - echo "REPO_NAME='${REPO_NAME}'" - echo "TEST_USER='${TEST_USER}'" - echo "WORKSPACE_PARENT='${WORKSPACE_PARENT}'" - echo "WORKSPACE='${WORKSPACE}'" - env | sort - # tooling info - echo "## tooling info" - cargo -V - rustc -V - # - # To ensure that files are cleaned up, we don't want to exit on error - set +e - cd "${WORKSPACE}" - unset FAULT - cargo build || FAULT=1 - export RUST_BACKTRACE=1 - if (test -z "\$FAULT"); then cargo test --features '${{ matrix.job.features }}' || FAULT=1 ; fi - if (test -z "\$FAULT"); then cargo test --all-features -p uucore || FAULT=1 ; fi - # Clean to avoid to rsync back the files - cargo clean - if (test -n "\$FAULT"); then exit 1 ; fi - EOF - coverage: name: Code Coverage runs-on: ${{ matrix.job.os }} diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml new file mode 100644 index 000000000..c5489919e --- /dev/null +++ b/.github/workflows/android.yml @@ -0,0 +1,72 @@ +name: Android + +on: [push, pull_request] + +permissions: + contents: read # to fetch code (actions/checkout) + +# End the current execution if there is a new changeset in the PR. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +jobs: + test_android: + name: Test Android builds + runs-on: macos-latest + timeout-minutes: 90 + strategy: + fail-fast: false + matrix: + api-level: [28] + target: [default] + arch: [x86] # , arm64-v8a + env: + TERMUX: v0.118.0 + SCCACHE_GHA_ENABLED: "true" + RUSTC_WRAPPER: "sccache" + steps: + - uses: actions/checkout@v3 + - uses: Swatinem/rust-cache@v2 + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.3 + - name: AVD cache + uses: actions/cache@v3 + id: avd-cache + with: + path: | + ~/.android/avd/* + ~/.android/avd/*/snapshots/* + ~/.android/adb* + key: avd-${{ matrix.api-level }}-${{ matrix.arch }}+termux-${{ env.TERMUX }} + - name: Create and cache emulator image + if: steps.avd-cache.outputs.cache-hit != 'true' + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: ${{ matrix.api-level }} + target: ${{ matrix.target }} + arch: ${{ matrix.arch }} + ram-size: 2048M + disk-size: 5120M + force-avd-creation: true + emulator-options: -no-snapshot-load -noaudio -no-boot-anim -camera-back none + script: | + wget https://github.com/termux/termux-app/releases/download/${{ env.TERMUX }}/termux-app_${{ env.TERMUX }}+github-debug_${{ matrix.arch }}.apk + util/android-commands.sh snapshot termux-app_${{ env.TERMUX }}+github-debug_${{ matrix.arch }}.apk + adb -s emulator-5554 emu avd snapshot save ${{ matrix.api-level }}-${{ matrix.arch }}+termux-${{ env.TERMUX }} + echo "Emulator image created." + pkill -9 qemu-system-x86_64 + - name: Build and Test on Android + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: ${{ matrix.api-level }} + target: ${{ matrix.target }} + arch: ${{ matrix.arch }} + ram-size: 2048M + disk-size: 5120M + force-avd-creation: false + emulator-options: -no-snapshot-save -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -snapshot ${{ matrix.api-level }}-${{ matrix.arch }}+termux-${{ env.TERMUX }} + script: | + util/android-commands.sh sync + util/android-commands.sh build + util/android-commands.sh tests diff --git a/.github/workflows/freebsd.yml b/.github/workflows/freebsd.yml new file mode 100644 index 000000000..b8d9ba026 --- /dev/null +++ b/.github/workflows/freebsd.yml @@ -0,0 +1,90 @@ +name: FreeBSD + +on: [push, pull_request] + +permissions: + contents: read # to fetch code (actions/checkout) + +# End the current execution if there is a new changeset in the PR. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +jobs: + test_freebsd: + name: Tests/FreeBSD test suite + runs-on: ${{ matrix.job.os }} + timeout-minutes: 90 + strategy: + fail-fast: false + matrix: + job: + - { os: macos-12 , features: unix } ## GHA MacOS-11.0 VM won't have VirtualBox; refs: , + env: + mem: 4096 + SCCACHE_GHA_ENABLED: "true" + RUSTC_WRAPPER: "sccache" + steps: + - uses: actions/checkout@v3 + - uses: Swatinem/rust-cache@v2 + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.3 + - name: Prepare, build and test + ## spell-checker:ignore (ToDO) sshfs usesh vmactions + uses: vmactions/freebsd-vm@v0.3.0 + with: + usesh: true + # sync: sshfs + prepare: pkg install -y curl gmake sudo + run: | + ## Prepare, build, and test + # implementation modelled after ref: + # * NOTE: All steps need to be run in this block, otherwise, we are operating back on the mac host + set -e + # + # We need a file-descriptor file system to test test_ls::test_ls_io_errors + mount -t fdescfs fdesc /dev/fd + # + TEST_USER=tester + REPO_NAME=${GITHUB_WORKSPACE##*/} + WORKSPACE_PARENT="/Users/runner/work/${REPO_NAME}" + WORKSPACE="${WORKSPACE_PARENT}/${REPO_NAME}" + # + pw adduser -n ${TEST_USER} -d /root/ -g wheel -c "Coreutils user to build" -w random + # chown -R ${TEST_USER}:wheel /root/ "${WORKSPACE_PARENT}"/ + chown -R ${TEST_USER}:wheel /root/ "/Users/runner/work/${REPO_NAME}"/ + whoami + # + # Further work needs to be done in a sudo as we are changing users + sudo -i -u ${TEST_USER} sh << EOF + set -e + whoami + curl https://sh.rustup.rs -sSf --output rustup.sh + sh rustup.sh -y --profile=minimal + . $HOME/.cargo/env + ## Info + # environment + echo "## environment" + echo "CI='${CI}'" + echo "REPO_NAME='${REPO_NAME}'" + echo "TEST_USER='${TEST_USER}'" + echo "WORKSPACE_PARENT='${WORKSPACE_PARENT}'" + echo "WORKSPACE='${WORKSPACE}'" + env | sort + # tooling info + echo "## tooling info" + cargo -V + rustc -V + # + # To ensure that files are cleaned up, we don't want to exit on error + set +e + cd "${WORKSPACE}" + unset FAULT + cargo build || FAULT=1 + export RUST_BACKTRACE=1 + if (test -z "\$FAULT"); then cargo test --features '${{ matrix.job.features }}' || FAULT=1 ; fi + if (test -z "\$FAULT"); then cargo test --all-features -p uucore || FAULT=1 ; fi + # Clean to avoid to rsync back the files + cargo clean + if (test -n "\$FAULT"); then exit 1 ; fi + EOF