Commit c9bebb26 authored by brizental's avatar brizental
Browse files

TB 44860: Add CI for generating test builds

parent 61c6c0dc
Loading
Loading
Loading
Loading
Loading

.gitlab-ci.yml

0 → 100644
+87 −0
Original line number Diff line number Diff line
stages:
  - update-container-image
  - build

build-image:
  stage: update-container-image
  rules:
    - when: manual
  allow_failure: true
  interruptible: true
  image: containers.torproject.org/tpo/tpa/base-images/podman:trixie
  script:
    - export TAG="${CI_REGISTRY_IMAGE}/base:latest"
    - podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - |
      podman build --layers=false $IMAGE -t ${TAG} -f - . <<'EOF'
        FROM containers.torproject.org/brizental/tor-browser/android:latest

        USER root
        RUN apt-get update && apt-get install -y \
          build-essential \
          gyp \
          ninja-build \
          zlib1g-dev

        RUN rm -rf /var/lib/apt/lists/* && \
            apt-get clean

        USER gitlab-runner
      EOF
    - |
      echo -e "\e[33mPushing new image to registry as ${TAG}\e[0m"
      podman push ${TAG}

dev-build:
  image: containers.torproject.org/tpo/applications/application-services/base:latest
  stage: build
  rules:
    - when: manual
  allow_failure: true
  tags:
    - firefox
  variables:
    MOZBUILD_STATE_PATH: "/var/tmp/mozbuild"
    # Reset cargo home to a writable directory.
    CARGO_HOME: $CI_PROJECT_DIR/.cargo
  script:
    - |
      set -xe

      # Setup environment
      export JAVA_HOME=$(ls -d "$MOZBUILD_STATE_PATH/jdk"/jdk-* 2>/dev/null | head -1)
      export ANDROID_HOME=$MOZBUILD_STATE_PATH/android-sdk-linux/
      export ANDROID_NDK_HOME=$(ls -d "$MOZBUILD_STATE_PATH"/android-ndk-* 2>/dev/null | head -1)
      export ANDROID_NDK_ROOT=$ANDROID_NDK_HOME
      export RUST_ANDROID_GRADLE_PYTHON_COMMAND=python3

      # Link NDK into the SDK ndk/ directory
      NDK_REVISION=$(grep "Pkg.Revision" "$ANDROID_NDK_HOME/source.properties" | cut -d'=' -f2 | tr -d ' ')
      mkdir -p "$ANDROID_HOME/ndk"
      ln -s "$ANDROID_NDK_HOME" "$ANDROID_HOME/ndk/$NDK_REVISION"

      # Fetch and build uniffi-rs
      git clone --depth 1 --single-branch https://gitlab.torproject.org/tpo/applications/uniffi-rs.git
      cd uniffi-rs
      cargo build
      export UNIFFI_LOCATION="$(pwd)/target/debug/uniffi-bindgen"
      cd ..

      # Pre-build
      cd libs
      ./build-all.sh desktop
      ./build-all.sh android
      cd ..

      # Build
      ./gradlew --no-daemon -PuniffiBindgenNoop="$UNIFFI_LOCATION" publish

      # Mimic the directory structure of the tor-browser-build archive.
      mv build application-services
      # Create archive
      tar -czf "$CI_COMMIT_REF_SLUG.tar.gz" application-services/maven/

  artifacts:
    paths:
      - "*.tar.gz"
    expire_in: 1 week