Skip to content

Commit 60fe522

Browse files
committed
test avd
1 parent 847682f commit 60fe522

File tree

7 files changed

+209
-139
lines changed

7 files changed

+209
-139
lines changed

.github/workflows/package_avd.yml renamed to .github/workflows/package_waydroid.yml

Lines changed: 77 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515
## limitations under the License.
1616
##
1717

18-
name: Packages-TUR-AVD
18+
name: Packages-TUR-Waydroid
1919

2020
on:
2121
push:
2222
branches:
2323
- tur-avd
2424
paths:
25-
- 'tur-avd/**'
25+
- 'tur-waydroid/**'
2626
pull_request:
2727
paths:
28-
- 'tur-avd/**'
28+
- 'tur-waydroid/**'
2929
workflow_dispatch:
3030
inputs:
3131
packages:
@@ -34,26 +34,50 @@ on:
3434

3535
jobs:
3636
build:
37-
runs-on: macos-latest
37+
runs-on: ubuntu-24.04
38+
env:
39+
ANDROID_HOME: "/opt/termux/android-sdk"
40+
NDK: "/opt/termux/android-ndk"
41+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
3842
strategy:
3943
matrix:
40-
target_arch:
41-
# Disabled for aarch64 due to arm64-v8a emulator cannot start.
42-
# - {"TERMUX_ARCH": "aarch64", "EMU_ARCH": "arm64-v8a"}
43-
- {"TERMUX_ARCH": "arm", "EMU_ARCH": "armeabi-v7a"}
44-
- {"TERMUX_ARCH": "i686", "EMU_ARCH": "x86"}
45-
- {"TERMUX_ARCH": "x86_64", "EMU_ARCH": "x86_64"}
44+
target_arch: [i686, x86_64]
45+
# target_arch: [aarch64, arm, i686, x86_64]
4646
fail-fast: false
4747
steps:
48+
- name: Install DKMS and missing modules
49+
run: |
50+
sudo apt update
51+
sudo apt install dkms -y
52+
git clone https://github.com/licy183/anbox-modules -b 6.8.x-ubuntu2404
53+
cd anbox-modules && ./INSTALL.sh
54+
- name: Install wayland
55+
run: |
56+
sudo apt update
57+
sudo apt install xwayland mutter pulseaudio -y
58+
- name: Install waydroid
59+
run: |
60+
sudo apt update
61+
sudo apt install curl ca-certificates -y
62+
curl https://repo.waydro.id | sudo bash
63+
sudo apt update
64+
sudo apt install waydroid -y
65+
sudo waydroid init
66+
- name: Solve network issues for waydroid
67+
run: |
68+
# https://unix.stackexchange.com/a/743946
69+
sudo sed -i~ -E 's/=.\$\(command -v (nft|ip6?tables-legacy).*/=/g' \
70+
/usr/lib/waydroid/data/scripts/waydroid-net.sh
71+
4872
- name: Clone repository
4973
uses: actions/checkout@v3
5074
with:
5175
fetch-depth: 1000
52-
path: ${{ github.workspace }}
53-
- name: Install basic tools
54-
run: brew install coreutils
76+
submodules: true
77+
5578
- name: Merge repos
5679
run: ./setup-environment.sh
80+
5781
- name: Gather build summary
5882
run: |
5983
if [ "${{ github.event_name }}" != "workflow_dispatch" ]; then
@@ -79,16 +103,29 @@ jobs:
79103
fi
80104
mkdir -p ./artifacts ./debs
81105
touch ./debs/.placeholder
82-
echo "File changed: ${CHANGED_FILES}"
83106
if [ "${{ github.event_name }}" != "workflow_dispatch" ]; then
107+
# Process tag '%ci:no-build' that may be added as line to commit message.
108+
# Forces CI to cancel current build with status 'passed'
109+
if grep -qiP '^\s*%ci:no-build\s*$' <(git log --format="%B" -n 1 "HEAD"); then
110+
tar cf artifacts/debs-${{ matrix.target_arch }}.tar debs
111+
echo "[!] Force exiting as tag '%ci:no-build' was applied to HEAD commit message."
112+
exit 0
113+
fi
114+
# XXX: TUR uses the termux-builder directly and may add custom builder image later.
115+
# Build local Docker image if setup scripts were changed.
116+
# Useful for pull requests submitting changes for both build environment and packages.
117+
# if grep -qP '^scripts/(Dockerfile|setup-android-sdk\.sh|setup-ubuntu\.sh)$' <<< "$CHANGED_FILES"; then
118+
# echo "Detected changes for environment setup scripts. Building custom Docker image now."
119+
# cd ./scripts
120+
# docker build -t termux/package-builder:latest .
121+
# cd ..
122+
# fi
84123
for repo_path in $(jq --raw-output 'keys | .[]' repo.json); do
85124
repo=$(jq --raw-output '.["'${repo_path}'"].name' repo.json)
86-
echo "Processing on repo: ${repo}"
87125
# Parse changed files and identify new packages and deleted packages.
88126
# Create lists of those packages that will be passed to upload job for
89127
# further processing.
90-
for file in $(echo "${CHANGED_FILES}"); do
91-
echo "File path: ${file}"
128+
while read -r file; do
92129
if ! [[ $file == ${repo_path}/* ]]; then
93130
# This file does not belong to a package, so ignore it
94131
continue
@@ -114,7 +151,7 @@ jobs:
114151
echo "$pkg" >> ./deleted_${repo}_packages
115152
fi
116153
fi
117-
done
154+
done<<<${CHANGED_FILES}
118155
done
119156
else
120157
for pkg in ${{ github.event.inputs.packages }}; do
@@ -141,20 +178,24 @@ jobs:
141178
if [ -f ./built_${repo}_packages.txt ]; then
142179
uniq ./built_${repo}_packages.txt > ./built_${repo}_packages.txt.tmp
143180
mv ./built_${repo}_packages.txt.tmp ./built_${repo}_packages.txt
144-
echo "./built_${repo}_packages.txt: "
145-
cat ./built_${repo}_packages.txt
146181
fi
147182
if [ -f ./built_${repo}_subpackages.txt ]; then
148183
uniq ./built_${repo}_subpackages.txt > ./built_${repo}_subpackages.txt.tmp
149184
mv ./built_${repo}_subpackages.txt.tmp ./built_${repo}_subpackages.txt
150-
echo "./built_${repo}_subpackages.txt: "
151-
cat ./built_${repo}_subpackages.txt
152185
fi
153186
if [ -f ./deleted_${repo}_packages.txt ]; then
154187
uniq ./deleted_${repo}_packages.txt > ./deleted_${repo}_packages.txt.tmp
155188
mv ./deleted_${repo}_packages.txt.tmp ./deleted_${repo}_packages.txt
156189
fi
157190
done
191+
- name: Free additional disk space (if necessary)
192+
run: |
193+
if grep -q '^code-server$\|^demo-package2$\$' ./built_tur_packages.txt; then
194+
sudo apt purge -yq $(dpkg -l | grep '^ii' | awk '{ print $2 }' | grep -P '(cabal-|dotnet-|ghc-|libmono|php|aspnetcore)') \
195+
mono-runtime-common monodoc-manual ruby
196+
sudo apt autoremove -yq
197+
sudo rm -rf /opt/hostedtoolcache /usr/local /usr/share/dotnet /usr/share/swift
198+
fi
158199
- name: Lint packages
159200
run: |
160201
declare -a package_recipes
@@ -167,39 +208,22 @@ jobs:
167208
if [ ! -z "$package_recipes" ]; then
168209
./scripts/lint-packages.sh $package_recipes
169210
fi
170-
171-
# TODO: Generate AVD Snapshot for caching
172-
# - name: Check AVD Cache
173-
# uses: actions/cache@v3
174-
# id: avd-cache
175-
# with:
176-
# path: |
177-
# ~/.android/avd/*
178-
# ~/.android/adb*
179-
# key: avd-24-${{ matrix.build_env.MAJOR_VERSION }}
180-
181-
# - name: Create AVD and Generate Snapshot for Caching
182-
# if: steps.avd-cache.outputs.cache-hit != 'true'
183-
# uses: reactivecircus/android-emulator-runner@v2
184-
# with:
185-
# api-level: 24
186-
# force-avd-creation: false
187-
# emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
188-
# disable-animations: false
189-
# script: echo "Generated AVD snapshot for caching."
190-
191211
- name: Build packages
192-
uses: licy183/[email protected]
193-
with:
194-
arch: ${{ matrix.target_arch.EMU_ARCH }}
195-
api-level: 24
196-
force-avd-creation: false
197-
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
198-
disable-animations: true
199-
script: env TERMUX_ARCH=${{ matrix.target_arch.TERMUX_ARCH }} ./common-files/action-avd-step-build-packages.sh
212+
run: |
213+
declare -a packages
214+
for repo_path in $(jq --raw-output 'keys | .[]' repo.json); do
215+
repo=$(jq --raw-output '.["'${repo_path}'"].name' repo.json)
216+
if [ -f ./built_${repo}_packages.txt ]; then
217+
packages="$packages $(cat ./built_${repo}_packages.txt)"
218+
fi
219+
done
220+
if [ ! -z "$packages" ]; then
221+
PACKAGE_TO_BUILD="$packages" bash -x ./waydroid-build-wrapper.sh
222+
fi
200223
- name: Generate build artifacts
201224
if: always()
202225
run: |
226+
test -d tur/output && mv tur/output/* ./output/
203227
for repo in $(jq --raw-output '.[].name' repo.json); do
204228
# Put package lists into directory with *.deb files so they will be transferred to
205229
# upload job.
@@ -216,8 +240,7 @@ jobs:
216240
done
217241
# Files containing certain symbols (e.g. ":") will cause failure in actions/upload-artifact.
218242
# Archiving *.deb files in a tarball to avoid issues with uploading.
219-
tar cf artifacts/debs-${{ matrix.target_arch.TERMUX_ARCH }}-${{ github.sha }}.tar debs
220-
rm -rf output
243+
tar cf artifacts/debs-${{ matrix.target_arch }}-${{ github.sha }}.tar debs
221244
- name: Checksums for built *.deb files
222245
if: always()
223246
run: |
@@ -226,7 +249,7 @@ jobs:
226249
if: always()
227250
uses: actions/upload-artifact@v3
228251
with:
229-
name: debs-${{ matrix.target_arch.TERMUX_ARCH }}-${{ github.sha }}
252+
name: debs-${{ matrix.target_arch }}-${{ github.sha }}
230253
path: ./artifacts
231254

232255
upload:

adb-build-wrapper.sh

Lines changed: 0 additions & 63 deletions
This file was deleted.

common-files/action-avd-step-build-packages.sh

Lines changed: 0 additions & 12 deletions
This file was deleted.

repo.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@
1717
"component": "tur-on-device",
1818
"url": "https://tur.kcubeterm.com"
1919
},
20-
"tur-avd": {
21-
"name": "tur-avd",
22-
"distribution": "tur-packages",
23-
"component": "tur-avd",
24-
"url": "https://tur.kcubeterm.com"
25-
},
2620
"tur-hacking": {
2721
"name": "tur-hacking",
2822
"distribution": "tur-packages",
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
TERMUX_PKG_HOMEPAGE=https://github.com/termux-user-repository/tur
2-
TERMUX_PKG_DESCRIPTION="Dummy test for TUR AVD"
2+
TERMUX_PKG_DESCRIPTION="Dummy test for TUR Waydroid"
33
TERMUX_PKG_LICENSE="GPL-2.0"
44
TERMUX_PKG_MAINTAINER="@termux-user-repository"
55
TERMUX_PKG_VERSION=0.1
66
TERMUX_PKG_SKIP_SRC_EXTRACT=true
77
TERMUX_PKG_BUILD_IN_SRC=true
88

99
termux_step_make() {
10-
$CC $CFLAGS $CPPFLAGS $TERMUX_PKG_BUILDER_DIR/main.c -o hello-tur-avd
10+
$CC $CFLAGS $CPPFLAGS $TERMUX_PKG_BUILDER_DIR/main.c -o hello-tur-waydroid
1111
}
1212

1313
termux_step_make_install() {
14-
install -Dm700 hello-tur-avd $TERMUX_PREFIX/bin/hello-tur-avd
14+
install -Dm700 hello-tur-waydroid $TERMUX_PREFIX/bin/hello-tur-waydroid
1515
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#include <stdio.h>
22
int main() {
3-
puts("Hello TUR AVD.");
3+
puts("Hello TUR Waydroid.");
44
}

0 commit comments

Comments
 (0)