mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
GitHub Actions: Use self-hosted runner
This commit is contained in:
69
.github/workflows/main.yml
vendored
69
.github/workflows/main.yml
vendored
@@ -7,71 +7,24 @@ on:
|
|||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
jobs:
|
jobs:
|
||||||
Build:
|
Test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: self-hosted
|
||||||
steps:
|
steps:
|
||||||
- name: Check out source code
|
- name: Check out source code
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v1
|
||||||
|
|
||||||
- name: Install Java Development Kit 11
|
- name: Build project
|
||||||
uses: actions/setup-java@v1
|
|
||||||
with:
|
|
||||||
java-version: 11
|
|
||||||
|
|
||||||
- name: Build Project
|
|
||||||
run: ./build.sh build
|
run: ./build.sh build
|
||||||
|
|
||||||
- name: Upload Build Artifacts
|
- name: Run Android tests
|
||||||
|
run: ./build.sh android-tests-parallel 23 24 25 26 27 28 30 31
|
||||||
|
|
||||||
|
- name: Upload artifacts
|
||||||
|
if: always()
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: uhabits-android
|
name: build
|
||||||
path: uhabits-android/build/outputs/
|
|
||||||
|
|
||||||
AndroidTest:
|
|
||||||
needs: Build
|
|
||||||
runs-on: macOS-10.15
|
|
||||||
timeout-minutes: 60
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
api: [
|
|
||||||
25,
|
|
||||||
27,
|
|
||||||
28,
|
|
||||||
30,
|
|
||||||
31,
|
|
||||||
]
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Check out source code
|
|
||||||
uses: actions/checkout@v1
|
|
||||||
|
|
||||||
- name: Download Previously Built APK
|
|
||||||
uses: actions/download-artifact@v2
|
|
||||||
with:
|
|
||||||
name: uhabits-android
|
|
||||||
path: uhabits-android/build/outputs/
|
|
||||||
|
|
||||||
- name: Install Linux utils
|
|
||||||
run: |
|
|
||||||
brew unlink parallel
|
|
||||||
brew install util-linux moreutils coreutils
|
|
||||||
echo "/usr/local/opt/util-linux/bin" >> $GITHUB_PATH
|
|
||||||
echo "/usr/local/opt/moreutils/bin" >> $GITHUB_PATH
|
|
||||||
echo "/usr/local/opt/coreutils/libexec/gnubin" >> $GITHUB_PATH
|
|
||||||
|
|
||||||
- name: AVD cache
|
|
||||||
uses: actions/cache@v3
|
|
||||||
id: avd-cache
|
|
||||||
with:
|
|
||||||
path: |
|
path: |
|
||||||
~/.android/avd/*
|
build/*log
|
||||||
~/.android/adb*
|
uhabits-android/build/outputs
|
||||||
key: avd-${{ matrix.api }}
|
|
||||||
|
|
||||||
- name: Setup AVD
|
|
||||||
if: steps.avd-cache.outputs.cache-hit != 'true'
|
|
||||||
run: ./build.sh android-setup ${{ matrix.api }}
|
|
||||||
|
|
||||||
- name: Run Android Tests
|
|
||||||
run: ./build.sh android-tests ${{ matrix.api }}
|
|
||||||
|
|
||||||
|
|||||||
50
build.sh
50
build.sh
@@ -15,7 +15,6 @@
|
|||||||
# You should have received a copy of the GNU General Public License along
|
# You should have received a copy of the GNU General Public License along
|
||||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
set -o xtrace
|
|
||||||
cd "$(dirname "$0")" || exit
|
cd "$(dirname "$0")" || exit
|
||||||
|
|
||||||
ADB="${ANDROID_HOME}/platform-tools/adb"
|
ADB="${ANDROID_HOME}/platform-tools/adb"
|
||||||
@@ -99,11 +98,6 @@ android_setup() {
|
|||||||
$EMULATOR \
|
$EMULATOR \
|
||||||
-avd $AVDNAME \
|
-avd $AVDNAME \
|
||||||
-port 6${API}0 \
|
-port 6${API}0 \
|
||||||
-no-window \
|
|
||||||
-gpu swiftshader_indirect \
|
|
||||||
-noaudio \
|
|
||||||
-no-boot-anim \
|
|
||||||
-camera-back none \
|
|
||||||
1>/dev/null 2>&1 &
|
1>/dev/null 2>&1 &
|
||||||
|
|
||||||
log_info "Waiting for emulator to boot..."
|
log_info "Waiting for emulator to boot..."
|
||||||
@@ -114,16 +108,6 @@ android_setup() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log_info "Disabling animations..."
|
|
||||||
$ADB root || return 1
|
|
||||||
sleep 5
|
|
||||||
$ADB shell settings put global window_animation_scale 0 || return 1
|
|
||||||
$ADB shell settings put global transition_animation_scale 0 || return 1
|
|
||||||
$ADB shell settings put global animator_duration_scale 0 || return 1
|
|
||||||
|
|
||||||
log_info "Acquiring wake lock..."
|
|
||||||
$ADB shell 'echo android-test > /sys/power/wake_lock' || return 1
|
|
||||||
|
|
||||||
log_info "Saving snapshot..."
|
log_info "Saving snapshot..."
|
||||||
$ADB emu avd snapshot save fresh-install
|
$ADB emu avd snapshot save fresh-install
|
||||||
}
|
}
|
||||||
@@ -154,6 +138,17 @@ android_boot_attempt() {
|
|||||||
log_error "Emulator failed to boot after $BOOT_TIMEOUT seconds."
|
log_error "Emulator failed to boot after $BOOT_TIMEOUT seconds."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
log_info "Disabling animations..."
|
||||||
|
$ADB root || return 1
|
||||||
|
sleep 5
|
||||||
|
$ADB shell settings put global window_animation_scale 0 || return 1
|
||||||
|
$ADB shell settings put global transition_animation_scale 0 || return 1
|
||||||
|
$ADB shell settings put global animator_duration_scale 0 || return 1
|
||||||
|
|
||||||
|
log_info "Acquiring wake lock..."
|
||||||
|
$ADB shell 'echo android-test > /sys/power/wake_lock' || return 1
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
android_boot() {
|
android_boot() {
|
||||||
@@ -216,6 +211,8 @@ android_test() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
android_test_parallel() {
|
android_test_parallel() {
|
||||||
|
# Launch background processes
|
||||||
|
PIDS=""
|
||||||
for API in $*; do
|
for API in $*; do
|
||||||
(
|
(
|
||||||
LOG=build/android-test-$API.log
|
LOG=build/android-test-$API.log
|
||||||
@@ -223,12 +220,27 @@ android_test_parallel() {
|
|||||||
if android_test $API 1>$LOG 2>&1; then
|
if android_test $API 1>$LOG 2>&1; then
|
||||||
log_info "API $API: Passed"
|
log_info "API $API: Passed"
|
||||||
else
|
else
|
||||||
log_error "API $API: Failed. See $LOG for more details."
|
log_error "API $API: Failed"
|
||||||
fi
|
fi
|
||||||
pkill -9 -f ${AVD_PREFIX}${API}
|
pkill -9 -f ${AVD_PREFIX}${API}
|
||||||
)&
|
)&
|
||||||
|
PIDS+=" $!"
|
||||||
done
|
done
|
||||||
wait
|
|
||||||
|
# Check exit codes
|
||||||
|
RET_CODE=0
|
||||||
|
for pid in $PIDS; do
|
||||||
|
wait $pid || RET_CODE=1
|
||||||
|
done
|
||||||
|
|
||||||
|
# Print all logs
|
||||||
|
for API in $*; do
|
||||||
|
echo "::group::Android Tests (API $API)"
|
||||||
|
cat build/android-test-$API.log
|
||||||
|
echo "::endgroup::"
|
||||||
|
done
|
||||||
|
|
||||||
|
return $RET_CODE
|
||||||
}
|
}
|
||||||
|
|
||||||
android_build() {
|
android_build() {
|
||||||
@@ -300,12 +312,14 @@ CI/CD script for Loop Habit Tracker.
|
|||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
build.sh build [options]
|
build.sh build [options]
|
||||||
|
build.sh android-setup <API>
|
||||||
build.sh android-tests <API> [options]
|
build.sh android-tests <API> [options]
|
||||||
build.sh android-tests-parallel <API> <API>... [options]
|
build.sh android-tests-parallel <API> <API>... [options]
|
||||||
build.sh android-accept-images [options]
|
build.sh android-accept-images [options]
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
build Build the app and run small tests
|
build Build the app and run small tests
|
||||||
|
android-setup Create Android virtual machine
|
||||||
android-tests Run medium and large Android tests on an emulator
|
android-tests Run medium and large Android tests on an emulator
|
||||||
android-tests-parallel Tests multiple API levels simultaneously
|
android-tests-parallel Tests multiple API levels simultaneously
|
||||||
android-accept-images Copy fetched images to corresponding assets folder
|
android-accept-images Copy fetched images to corresponding assets folder
|
||||||
|
|||||||
Reference in New Issue
Block a user