Skip to content

Commit

Permalink
Merge pull request #5939 from cre4ture/fix/stabilize_improve_android_…
Browse files Browse the repository at this point in the history
…build

`ci:android` stabilize and improve android github actions
  • Loading branch information
cakebaker authored Feb 4, 2024
2 parents b485a48 + 93d922f commit 40694c5
Show file tree
Hide file tree
Showing 5 changed files with 484 additions and 134 deletions.
73 changes: 60 additions & 13 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,55 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

env:
TERMUX: v0.118.0
KEY_POSTFIX: nextest+rustc-hash+adb+sshd+upgrade+XGB+inc15
COMMON_EMULATOR_OPTIONS: -no-window -noaudio -no-boot-anim -camera-back none -gpu swiftshader_indirect
EMULATOR_DISK_SIZE: 12GB
EMULATOR_HEAP_SIZE: 2048M
EMULATOR_BOOT_TIMEOUT: 1200 # 20min

jobs:
test_android:
name: Test builds
runs-on: macos-latest
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest] # , macos-latest
cores: [4] # , 6
ram: [4096, 8192]
api-level: [28]
target: [default]
arch: [x86, x86_64] # , arm64-v8a
exclude:
- ram: 8192
arch: x86
- ram: 4096
arch: x86_64
runs-on: ${{ matrix.os }}
env:
TERMUX: v0.118.0
EMULATOR_RAM_SIZE: ${{ matrix.ram }}
EMULATOR_CORES: ${{ matrix.cores }}
RUNNER_OS: ${{ matrix.os }}
AVD_CACHE_KEY: "set later due to limitations of github actions not able to concatenate env variables"
steps:
- name: Concatenate values to environment file
run: |
echo "AVD_CACHE_KEY=${{ matrix.os }}-${{ matrix.cores }}-${{ matrix.ram }}-${{ matrix.api-level }}-${{ matrix.target }}-${{ matrix.arch }}+termux-${{ env.TERMUX }}+${{ env.KEY_POSTFIX }}" >> $GITHUB_ENV
- name: Collect information about runner
run: |
hostname
uname -a
free -mh
df -h
cat /proc/cpuinfo
- name: Enable KVM group perms (linux hardware acceleration)
if: ${{ runner.os == 'Linux' }}
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- uses: actions/checkout@v4
- name: Restore AVD cache
uses: actions/cache/restore@v4
Expand All @@ -41,7 +76,7 @@ jobs:
~/.android/avd/*/snapshots/*
~/.android/adb*
~/__rustc_hash__
key: avd-${{ matrix.api-level }}-${{ matrix.arch }}+termux-${{ env.TERMUX }}+nextest+rustc-hash
key: avd-${{ env.AVD_CACHE_KEY }}
- name: Delete AVD Lockfile when run from cache
if: steps.avd-cache.outputs.cache-hit == 'true'
run: |
Expand All @@ -50,15 +85,18 @@ jobs:
~/.android/avd/*/*.lock
- name: Create and cache emulator image
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
uses: reactivecircus/android-emulator-runner@v2.30.1
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
arch: ${{ matrix.arch }}
ram-size: 2048M
disk-size: 7GB
ram-size: ${{ env.EMULATOR_RAM_SIZE }}
heap-size: ${{ env.EMULATOR_HEAP_SIZE }}
disk-size: ${{ env.EMULATOR_DISK_SIZE }}
cores: ${{ env.EMULATOR_CORES }}
force-avd-creation: true
emulator-options: -no-window -no-snapshot-load -noaudio -no-boot-anim -camera-back none
emulator-options: ${{ env.COMMON_EMULATOR_OPTIONS }} -no-snapshot-load
emulator-boot-timeout: ${{ env.EMULATOR_BOOT_TIMEOUT }}
script: |
util/android-commands.sh init "${{ matrix.arch }}" "${{ matrix.api-level }}" "${{ env.TERMUX }}"
- name: Save AVD cache
Expand All @@ -70,12 +108,12 @@ jobs:
~/.android/avd/*/snapshots/*
~/.android/adb*
~/__rustc_hash__
key: avd-${{ matrix.api-level }}-${{ matrix.arch }}+termux-${{ env.TERMUX }}+nextest+rustc-hash
key: avd-${{ env.AVD_CACHE_KEY }}
- uses: juliangruber/read-file-action@v1
id: read_rustc_hash
with:
# ~ expansion didn't work
path: /Users/runner/__rustc_hash__
path: ${{ runner.os == 'Linux' && '/home/runner/__rustc_hash__' || '/Users/runner/__rustc_hash__' }}
trim: true
- name: Restore rust cache
id: rust-cache
Expand All @@ -86,15 +124,18 @@ jobs:
# the github cache during the development of this workflow
key: ${{ matrix.arch }}_${{ matrix.target}}_${{ steps.read_rustc_hash.outputs.content }}_${{ hashFiles('**/Cargo.toml', '**/Cargo.lock') }}_v3
- name: Build and Test
uses: reactivecircus/android-emulator-runner@v2
uses: reactivecircus/android-emulator-runner@v2.30.1
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
arch: ${{ matrix.arch }}
ram-size: 2048M
disk-size: 7GB
ram-size: ${{ env.EMULATOR_RAM_SIZE }}
heap-size: ${{ env.EMULATOR_HEAP_SIZE }}
disk-size: ${{ env.EMULATOR_DISK_SIZE }}
cores: ${{ env.EMULATOR_CORES }}
force-avd-creation: false
emulator-options: -no-window -no-snapshot-save -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -snapshot ${{ matrix.api-level }}-${{ matrix.arch }}+termux-${{ env.TERMUX }}
emulator-options: ${{ env.COMMON_EMULATOR_OPTIONS }} -no-snapshot-save -snapshot ${{ env.AVD_CACHE_KEY }}
emulator-boot-timeout: ${{ env.EMULATOR_BOOT_TIMEOUT }}
# This is not a usual script. Every line is executed in a separate shell with `sh -c`. If
# one of the lines returns with error the whole script is failed (like running a script with
# set -e) and in consequences the other lines (shells) are not executed.
Expand All @@ -109,3 +150,9 @@ jobs:
with:
path: ~/__rust_cache__
key: ${{ matrix.arch }}_${{ matrix.target}}_${{ steps.read_rustc_hash.outputs.content }}_${{ hashFiles('**/Cargo.toml', '**/Cargo.lock') }}_v3
- name: archive any output (error screenshots)
if: always()
uses: actions/upload-artifact@v4
with:
name: test_output_${{ env.AVD_CACHE_KEY }}
path: output
12 changes: 8 additions & 4 deletions src/uucore/src/lib/features/fsext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ impl FsMeta for StatFs {
any(
target_arch = "s390x",
target_vendor = "apple",
target_os = "android",
all(target_os = "android", target_pointer_width = "32"),
target_os = "openbsd",
not(target_pointer_width = "64")
)
Expand All @@ -675,7 +675,8 @@ impl FsMeta for StatFs {
target_os = "freebsd",
target_os = "illumos",
target_os = "solaris",
target_os = "redox"
target_os = "redox",
all(target_os = "android", target_pointer_width = "64"),
))]
return self.f_bsize.try_into().unwrap();
}
Expand Down Expand Up @@ -741,14 +742,17 @@ impl FsMeta for StatFs {
not(target_env = "musl"),
any(
target_vendor = "apple",
target_os = "android",
all(target_os = "android", target_pointer_width = "32"),
target_os = "freebsd",
target_arch = "s390x",
not(target_pointer_width = "64")
)
))]
return self.f_type.into();
#[cfg(target_env = "musl")]
#[cfg(any(
target_env = "musl",
all(target_os = "android", target_pointer_width = "64"),
))]
return self.f_type.try_into().unwrap();
}
#[cfg(not(any(
Expand Down
Loading

0 comments on commit 40694c5

Please sign in to comment.