--- # Use merge request pipelines when a merge request is open for the branch. # Use branch pipelines when a merge request is not open for the branch. # https://docs.gitlab.com/ci/yaml/workflow/#switch-between-branch-pipelines-and-merge-request-pipelines workflow: rules: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS when: never - if: $CI_COMMIT_BRANCH stages: - lint - main # the main platforms sdkmanager is used and developed on - test # default for jobs that do not specify stage: variables: pip: pip3 --timeout 100 --retries 10 # speed up git checkout phase GIT_DEPTH: 1 .apt-template: &apt-template variables: DEBIAN_FRONTEND: noninteractive LANG: C.UTF-8 before_script: - echo Etc/UTC > /etc/timezone - echo 'APT::Install-Recommends "0";' 'APT::Install-Suggests "0";' 'APT::Get::Assume-Yes "true";' 'Acquire::Retries "20";' 'Dpkg::Use-Pty "0";' 'quiet "1";' >> /etc/apt/apt.conf.d/99gitlab # Ubuntu and other distros often lack https:// support - grep Debian /etc/issue.net && { find /etc/apt/sources.list* -type f | xargs sed -i s,http:,https:, ; } - echo 'Acquire::https::Verify-Peer "false";' > /etc/apt/apt.conf.d/99nocacertificates - apt-get update - apt-get install ca-certificates - rm /etc/apt/apt.conf.d/99nocacertificates - apt-get dist-upgrade # For jobs that only need to run when there are changes to Python files. .python-rules-changes: &python-rules-changes rules: - changes: - .gitlab-ci.yml - "*.py" .apt-test-template: &apt-test-template - apt-get install git gpgv python3-argcomplete python3-defusedxml python3-packaging python3-requests python3-requests-cache python3-setuptools .pip-test-template: &pip-test-template - apt-get install git gpgv python3-pip - pip install --break-system-packages .[test] - pip wheel . # `timeout` is used in case one of those runs fails, and waits forever # for user input. .test-template: &test-template - python3 -m unittest --verbose - export ANDROID_SDK_ROOT=/tmp/android-sdk - ./sdkmanager.py --list - echo y | ./sdkmanager.py --licenses # accept the licenses - timeout 120 ./sdkmanager.py --licenses # now there should be unaccepted licenses - apt-get update # cmdline-tools;20.0 requires Java 17+ - grep bullseye /etc/os-release && apt-get install openjdk-17-jdk-headless || apt-get install default-jdk-headless - export ver=20.0 - ./sdkmanager.py "cmdline-tools;${ver}" - export sdkmanager="$ANDROID_SDK_ROOT/cmdline-tools/${ver}/bin/sdkmanager" # ensure that Android's sdkmanager understands fdroid's installs - for package in "build-tools;37.0.0" "cmake;4.1.2" "cmdline-tools;${ver}" "ndk;29.0.14206865" "platform-tools" "platforms;android-37.0" "skiaparser;3" "system-images;android-35;default;x86_64" "tools" ; do ./sdkmanager.py $package; echo "Does $sdkmanager detect that $package was installed:"; $sdkmanager --list | grep --fixed-strings $package | grep --fixed-strings ${package//;/\/}; done # ensure that Android's sdkmanager understands fdroid's licenses - timeout 120 $sdkmanager --licenses black: stage: lint image: debian:trixie-slim <<: *python-rules-changes <<: *apt-template script: - apt-get install black - black --check --diff --color $CI_PROJECT_DIR # Run all the various linters and static analysis tools. hooks/pre-commit: stage: lint image: debian:trixie-slim variables: LANG: C.UTF-8 <<: *python-rules-changes <<: *apt-template script: - apt-get install bash ca-certificates dash gcc git pycodestyle pyflakes3 - ./hooks/pre-commit bandit: stage: lint image: debian:trixie-slim <<: *python-rules-changes <<: *apt-template script: - apt-get install bandit - bandit -c pyproject.toml -r . pylint: stage: lint image: debian:trixie-slim <<: *python-rules-changes <<: *apt-template script: - apt-get install pylint python3-pylint-gitlab - pylint --output-format=pylint_gitlab.GitlabCodeClimateReporter *.py > pylint-report.json || { pylint --output-format=colorized --reports=n *.py; exit 1; } artifacts: reports: codequality: pylint-report.json when: always shellcheck: stage: lint image: debian:trixie-slim rules: - changes: - .gitlab-ci.yml - completion/bash-completion - hooks/install-hooks.sh - hooks/pre-commit <<: *apt-template script: - apt-get install shellcheck # TODO GitLab Code Quality report https://github.com/koalaman/shellcheck/issues/3155 - shellcheck --exclude SC2207,SC2086 --severity=warning --color=always hooks/install-hooks.sh hooks/pre-commit completion/bash-completion test pip bookworm: image: debian:bookworm-slim <<: *apt-template script: - *pip-test-template - *test-template test pip trixie: image: debian:trixie-slim <<: *apt-template script: - *pip-test-template - *test-template test pip forky: image: debian:forky-slim <<: *apt-template script: - *pip-test-template - *test-template test pip Python 3.14: stage: main image: python:3.14-slim-trixie <<: *apt-template script: - *pip-test-template - *test-template test pip Python 3.15: image: python:3.15-rc-slim <<: *apt-template script: - *pip-test-template - *test-template test bullseye: image: debian:bullseye-slim <<: *apt-template script: - *apt-test-template - *test-template test bookworm: image: debian:bookworm-slim <<: *apt-template script: - *apt-test-template - *test-template test trixie: stage: main image: debian:trixie-slim <<: *apt-template script: - *apt-test-template - *test-template test forky: image: debian:forky-slim <<: *apt-template script: - *apt-test-template - *test-template build_app_offline: image: debian:bookworm rules: - if: $CI_COMMIT_BRANCH == "build_app_offline" # TODO disabled until someone gets it working <<: *apt-template script: - printf 'Package\x3a *\nPin\x3a release a=bookworm\nPin-Priority\x3a 1\n' >> /etc/apt/preferences.d/bookworm - echo 'deb https://deb.debian.org/debian bookworm main' >> /etc/apt/sources.list - apt-get install default-jdk-headless git gradle gradle-debian-helper python3-argcomplete python3-pip python3-requests python3-setuptools python3-wheel - $pip install --break-system-packages -e . - export ANDROID_HOME=/opt/android-sdk - sdkmanager "build-tools;24.0.0" "platforms;android-23" "platforms;android-25" - mkdir -p $ANDROID_HOME/licenses/ - echo '24333f8a63b6825ea9c5514f83c2829b004d1fee' > $ANDROID_HOME/licenses/android-sdk-license - mkdir ~/.android - git clone --depth 1 --branch 0.2.13 https://gitlab.com/fdroid/privileged-extension.git - cd privileged-extension - sed -i -e "s,jcenter(),maven { url 'file:///usr/share/maven-repo' }," -e '/com\.android\.support/d' build.gradle app/build.gradle - | tee --append gradle.properties <