mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-04 23:24:20 +00:00
Better CI
This commit is contained in:
parent
672fcf7b76
commit
6d6233079a
20
Dockerfile
20
Dockerfile
|
@ -26,12 +26,13 @@ RUN mkdir -p android-sdk/cmdline-tools && unzip commandlinetools-linux-${ANDROID
|
|||
&& rm commandlinetools-linux-${ANDROID_SDK_TOOLS_VERSION}_latest.zip && mv cmdline-tools android-sdk/cmdline-tools/latest
|
||||
|
||||
# Install Flutter
|
||||
ENV FLUTTER_HOME "/opt/flutter"
|
||||
ADD $FLUTTER_URL .
|
||||
RUN tar -vxf flutter_linux_${FLUTTER_VERSION}-stable.tar.xz && \
|
||||
rm flutter_linux_${FLUTTER_VERSION}-stable.tar.xz
|
||||
# Flutter doesn't work without write permissions, so fuck it, fuck.
|
||||
RUN chmod -R 777 /opt/flutter
|
||||
RUN git config --system --add safe.directory /opt/flutter
|
||||
RUN chmod -R 777 $FLUTTER_HOME
|
||||
RUN git config --system --add safe.directory $FLUTTER_HOME
|
||||
|
||||
ENV ANDROID_HOME "/opt/android-sdk"
|
||||
ENV ANDROID_SDK_ROOT "${ANDROID_HOME}"
|
||||
|
@ -43,20 +44,15 @@ RUN yes | sdkmanager 'build-tools;30.0.3' 'platforms;android-29' 'platforms;andr
|
|||
WORKDIR /tmp
|
||||
|
||||
# Prepare dependencies for offline build
|
||||
ENV PUB_CACHE "/tmp/flutter_pub_cache"
|
||||
ENV GRADLE_USER_HOME "/tmp/gradle"
|
||||
RUN git clone --depth=1 --single-branch https://git.selfprivacy.org/kherel/selfprivacy.org.app.git deps
|
||||
WORKDIR /tmp/deps
|
||||
RUN flutter build linux
|
||||
RUN flutter build apk
|
||||
WORKDIR /tmp
|
||||
RUN rm -rf deps
|
||||
RUN chmod -R 777 $PUB_CACHE $GRADLE_USER_HOME
|
||||
|
||||
# Install Python dependencies
|
||||
RUN pip3 install appimage-builder bandit setuptools portalocker pytz pytest pytest-mock \
|
||||
pytest-datadir huey gevent mnemonic coverage pylint pydantic \
|
||||
typing-extensions psutil black fastapi uvicorn strawberry-graphql \
|
||||
python-multipart python-dateutil pygments poetry graphql-core
|
||||
|
||||
# Install Flatpak dependencies
|
||||
RUN flatpak remote-add flathub https://flathub.org/repo/flathub.flatpakrepo \
|
||||
&& flatpak install -y org.freedesktop.Sdk/x86_64/${FREEDESKTOP_SDK_VERSION} \
|
||||
org.freedesktop.Platform/x86_64/${FREEDESKTOP_SDK_VERSION}
|
||||
# Install AppImage Builder
|
||||
RUN pip3 install appimage-builder
|
||||
|
|
26
ci.py
26
ci.py
|
@ -5,7 +5,7 @@ import subprocess
|
|||
import yaml
|
||||
import argparse
|
||||
|
||||
CONTAINER_IMAGE = "docker.io/alyasirko/flutter-build-env"
|
||||
CONTAINER_IMAGE = "localhost/flutter-build-env"
|
||||
HOST_HOME = "/var/lib/drone-runner-exec"
|
||||
CONTAINER_HOME = "/tmp/builder"
|
||||
|
||||
|
@ -19,7 +19,7 @@ HOST_MOUNTED_VOLUME = f"{HOST_HOME}/.local/share/containers/storage/volumes/rele
|
|||
# Environments
|
||||
|
||||
def podman_offline(dir, *args):
|
||||
subprocess.run(["podman", "run", "--rm", "--network=none", f"--workdir={dir}",
|
||||
subprocess.run(["podman", "run", "--rm", "--network=none", "--cap-add=CHOWN", f"--workdir={dir}",
|
||||
"-v", os.getcwd() + f":{CONTAINER_HOME}/src",
|
||||
"-v", f"{HOST_HOME}/fdroid:{CONTAINER_HOME}/fdroid",
|
||||
"-v", f"{HOST_HOME}/fdroid-keystore:{CONTAINER_HOME}/fdroid/fdroid-keystore",
|
||||
|
@ -31,7 +31,7 @@ def podman_offline(dir, *args):
|
|||
])
|
||||
|
||||
def podman_online(dir, *args):
|
||||
subprocess.run(["podman", "run", "--rm", "--privileged", f"--workdir={dir}",
|
||||
subprocess.run(["podman", "run", "--rm", "--cap-add=CHOWN", f"--workdir={dir}",
|
||||
"-v", os.getcwd() + f":{CONTAINER_HOME}/src",
|
||||
"--user", os.getuid().__str__() + ":" + os.getgid().__str__(), "--userns=keep-id",
|
||||
CONTAINER_IMAGE, "bash", "-c", ' '.join(args)
|
||||
|
@ -40,12 +40,13 @@ def podman_online(dir, *args):
|
|||
# Targets
|
||||
|
||||
def build_linux():
|
||||
podman_offline(f"{CONTAINER_HOME}/src", "flutter pub get --offline")
|
||||
podman_offline(f"{CONTAINER_HOME}/src", "flutter build linux")
|
||||
podman_offline(f"{CONTAINER_HOME}/src", "flutter pub get --offline",
|
||||
"&& flutter build linux")
|
||||
|
||||
def build_apk():
|
||||
podman_offline(f"{CONTAINER_HOME}/src", "flutter pub get --offline")
|
||||
podman_offline(f"{CONTAINER_HOME}/src", "flutter build apk")
|
||||
podman_offline(f"{CONTAINER_HOME}/src", "chown -R $(id -u):$(id -g) /tmp/gradle",
|
||||
"&& flutter pub get --offline",
|
||||
"&& flutter build apk")
|
||||
|
||||
def sign_apk_standalone():
|
||||
podman_offline(f"{CONTAINER_HOME}/src",
|
||||
|
@ -68,8 +69,8 @@ def package_linux_appimage():
|
|||
podman_online(f"{CONTAINER_HOME}/src", "appimage-builder --recipe appimage.yml")
|
||||
|
||||
def package_linux_flatpak():
|
||||
podman_online(f"{CONTAINER_HOME}/src", "flatpak-builder --disable-rofiles-fuse --force-clean --repo=flatpak-repo flatpak-build flatpak.yml")
|
||||
podman_online(f"{CONTAINER_HOME}/src", f"flatpak build-bundle flatpak-repo {APP_NAME}-{APP_SEMVER}.flatpak pro.kherel.selfprivacy")
|
||||
subprocess.run(["flatpak-builder", "--force-clean", "--repo=flatpak-repo", "flatpak-build", "flatpak.yml"])
|
||||
subprocess.run(["flatpak", "build-bundle", "flatpak-repo", f"{APP_NAME}-{APP_SEMVER}.flatpak", "pro.kherel.selfprivacy"])
|
||||
|
||||
def package_linux_archive():
|
||||
podman_online(f"{CONTAINER_HOME}/src", f"tar -C build/linux/x64/release/bundle -vacf {APP_NAME}-{APP_SEMVER}.tar.zstd .")
|
||||
|
@ -96,7 +97,8 @@ def ci_build_linux():
|
|||
podman_online(f"{CONTAINER_HOME}/src", "flutter build linux --debug")
|
||||
|
||||
def ci_build_apk():
|
||||
podman_online(f"{CONTAINER_HOME}/src", "flutter build apk --debug")
|
||||
podman_online(f"{CONTAINER_HOME}/src", "chown -R $(id -u):$(id -g) /tmp/gradle",
|
||||
"&& flutter build apk --debug")
|
||||
|
||||
def ci_run_tests():
|
||||
podman_online(f"{CONTAINER_HOME}/src", "flutter test")
|
||||
|
@ -106,8 +108,8 @@ def ci_run_tests():
|
|||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
group = parser.add_mutually_exclusive_group()
|
||||
group.add_argument("--build-linux", action="store_true", help="depends on podman src volume")
|
||||
group.add_argument("--build-apk", action="store_true", help="depends on podman src volume")
|
||||
group.add_argument("--build-linux", action="store_true")
|
||||
group.add_argument("--build-apk", action="store_true")
|
||||
group.add_argument("--sign-apk-standalone", action="store_true", help="depends on $STANDALONE_KEYSTORE_PASS")
|
||||
group.add_argument("--sign-apk-fdroid", action="store_true", help="depends on $FDROID_KEYSTORE_PASS")
|
||||
group.add_argument("--package-linux-appimage", action="store_true")
|
||||
|
|
Loading…
Reference in a new issue