102 lines
3.4 KiB
Docker
102 lines
3.4 KiB
Docker
FROM archlinux
|
|
|
|
RUN pacman-key --init
|
|
RUN pacman -Syu --noconfirm
|
|
RUN pacman-key --recv-key 3056513887B78AEB --keyserver keyserver.ubuntu.com
|
|
RUN pacman-key --lsign-key 3056513887B78AEB
|
|
RUN pacman -U 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-keyring.pkg.tar.zst' --noconfirm
|
|
RUN pacman -U 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-mirrorlist.pkg.tar.zst' --noconfirm
|
|
RUN <<EOF cat >> /etc/pacman.conf
|
|
[chaotic-aur]
|
|
Include = /etc/pacman.d/chaotic-mirrorlist
|
|
EOF
|
|
RUN pacman -Syu base-devel android-sdk-cmdline-tools-latest flutter-bin jdk21-openjdk lxqt xorg-server libx11 libbsd lcov --noconfirm
|
|
|
|
RUN <<EOF cat >> /root/init.sh
|
|
#!/bin/bash
|
|
export PATH="/opt/flutter/bin/:$PATH"
|
|
source /etc/profile
|
|
git config --global --add safe.directory /opt/flutter
|
|
|
|
yes | sdkmanager --licenses
|
|
sdkmanager --install "build-tools;34.0.0" "build-tools;36.0.0" "cmake;3.22.1" "cmdline-tools;latest" "emulator" "ndk;27.0.12077973" "platform-tools" "platforms;android-34" "platforms;android-35" "sources;android-35" "system-images;android-35;google_apis_playstore;x86_64" "system-images;android-35-ext15;android-wear;x86_64"
|
|
EOF
|
|
|
|
RUN chmod +x /root/*.sh
|
|
RUN /root/init.sh
|
|
|
|
RUN mkdir /src
|
|
RUN mkdir /work
|
|
RUN useradd user -u 1000 -r --create-home
|
|
RUN chown -R user /opt/flutter/
|
|
RUN chown -R user /opt/android-sdk
|
|
RUN chown -R user /src
|
|
RUN chown -R user /work
|
|
|
|
RUN pacman -Syu xorg-server-xvfb --noconfirm
|
|
|
|
USER user
|
|
|
|
RUN echo no | /opt/android-sdk/cmdline-tools/latest/bin/avdmanager create avd --force --name 'Medium_Phone_API_35' --abi google_apis_playstore/x86_64 --package 'system-images;android-35;google_apis_playstore;x86_64'
|
|
RUN echo no | /opt/android-sdk/cmdline-tools/latest/bin/avdmanager create avd --force --name 'Wear_OS_Small_Round' --abi android-wear/x86_64 --package 'system-images;android-35-ext15;android-wear;x86_64'
|
|
|
|
RUN <<EOF cat >> /home/user/entrypoint.sh
|
|
#!/bin/bash
|
|
export PATH="/opt/android-sdk/platform-tools/:/opt/flutter/bin/:$PATH"
|
|
source /etc/profile
|
|
|
|
flutter config --no-analytics --no-cli-animations >/dev/null
|
|
|
|
cp -r /src/* /work
|
|
cd /work/firka
|
|
flutter pub get
|
|
|
|
xvfb-run /opt/android-sdk/emulator/emulator -avd Medium_Phone_API_35 >/dev/null &
|
|
xvfb-run /opt/android-sdk/emulator/emulator -avd Wear_OS_Small_Round >/dev/null &
|
|
|
|
max_retries=5
|
|
retry_count=0
|
|
|
|
tests_and_build() {
|
|
echo Waiting for emulators to boot up
|
|
while :
|
|
do
|
|
sleep 2
|
|
adb devices
|
|
(flutter devices | grep gphone64 >/dev/null) && (flutter devices | grep gwear >/dev/null) && break
|
|
done
|
|
|
|
phone=\$(flutter devices | grep gphone64 | awk '{ print \$7 }')
|
|
wear=\$(flutter devices | grep gwear | awk '{ print \$7 }')
|
|
|
|
echo phone: \$phone
|
|
echo wear: \$wear
|
|
|
|
echo Running tests...
|
|
|
|
flutter test integration_test/wear_* -d \$wear --coverage && \
|
|
mv coverage/lcov.info coverage/wear_lcov.info && \
|
|
flutter test integration_test/phone_* -d \$phone --coverage && \
|
|
mv coverage/lcov.info coverage/phone_lcov.info && \
|
|
flutter test test/ --coverage && \
|
|
genhtml coverage/*.info -o coverage/html && \
|
|
flutter build apk --release --verbose --tree-shake-icons --split-per-abi --target-platform android-arm,android-arm64
|
|
}
|
|
|
|
until tests_and_build; do
|
|
((retry_count++))
|
|
|
|
if [ \$retry_count -ge \$max_retries ]; then
|
|
echo "Command failed after \$max_retries attempts."
|
|
exit 1
|
|
fi
|
|
|
|
echo "Retrying... (\$retry_count/\$max_retries)"
|
|
sleep 1
|
|
done
|
|
EOF
|
|
|
|
RUN chmod +x /home/user/*.sh
|
|
|
|
ENTRYPOINT [ "/home/user/entrypoint.sh" ]
|