Pier Angelo Vendrame pushed to branch base-browser-128.0esr-14.0-1 at The Tor Project / Applications / Tor Browser
Commits:
- 
ac54df57
by Beatriz Rizental at 2024-07-18T11:34:23+02:00
- 
fa88a433
by Beatriz Rizental at 2024-07-18T11:34:24+02:00
4 changed files:
- .gitlab-ci.yml
- + .gitlab/ci/docker/base/Dockerfile
- .gitlab/ci/lint.yml
- .gitlab/ci/scripts/run_linters.py
Changes:
| 1 | 1 |  stages:
 | 
| 2 | 2 |    - lint
 | 
| 3 | 3 | |
| 4 | +variables:
 | |
| 5 | +  IMAGE_PATH: containers.torproject.org/tpo/applications/tor-browser/base:latest
 | |
| 6 | + | |
| 4 | 7 |  include:
 | 
| 5 | 8 |    - local: '.gitlab/ci/lint.yml' | 
| 1 | +FROM debian:latest
 | |
| 2 | + | |
| 3 | +# Base image which includes all* dependencies checked by ./mach configure.
 | |
| 4 | +#
 | |
| 5 | +# * Actually not all dependencies. WASM sandboxed depencies were left out for now.
 | |
| 6 | +# This installs all dependencies checked by `./mach configure --without-wasm-sandboxed-libraries`.
 | |
| 7 | +#
 | |
| 8 | +# # Building and publishing
 | |
| 9 | +#
 | |
| 10 | +# Whenever this file changes, the updated Docker image must be built and published _manually_ to
 | |
| 11 | +# the tor-browser container registry (https://gitlab.torproject.org/tpo/applications/tor-browser/container_registry/185).
 | |
| 12 | +#
 | |
| 13 | +# This image copies a script from the taskcluster/ folder, which requires it
 | |
| 14 | +# to be built from a folder which is a parent of the taskcluster/ folder.
 | |
| 15 | +#
 | |
| 16 | +# To build, run:
 | |
| 17 | +#
 | |
| 18 | +# ```bash
 | |
| 19 | +# docker build \
 | |
| 20 | +#   -f <PATH_TO_DOCKERFILE> \
 | |
| 21 | +#   -t <REGISTRY_URL>/<IMAGE_NAME>:<IMAGE_TAG>
 | |
| 22 | +#   .
 | |
| 23 | +# ```
 | |
| 24 | +#
 | |
| 25 | +# For example, when building from the root of this repository to the main tor-browser repository
 | |
| 26 | +# and assuming image name to be "base" and tag "latest" -- which is the current terminology:
 | |
| 27 | +#
 | |
| 28 | +# ```bash
 | |
| 29 | +# docker build \
 | |
| 30 | +#   -f .gitlab/ci/docker/Dockerfile \
 | |
| 31 | +#   -t containers.torproject.org/tpo/applications/tor-browser/base:latest
 | |
| 32 | +#   .
 | |
| 33 | +# ```
 | |
| 34 | + | |
| 35 | +RUN apt-get update && apt-get install -y \
 | |
| 36 | +    clang \
 | |
| 37 | +    curl \
 | |
| 38 | +    git \
 | |
| 39 | +    libasound2-dev \
 | |
| 40 | +    libdbus-glib-1-dev \
 | |
| 41 | +    libgtk-3-dev \
 | |
| 42 | +    libpango1.0-dev \
 | |
| 43 | +    libpulse-dev \
 | |
| 44 | +    libx11-xcb-dev \
 | |
| 45 | +    libxcomposite-dev \
 | |
| 46 | +    libxcursor-dev \
 | |
| 47 | +    libxdamage-dev \
 | |
| 48 | +    libxi-dev \
 | |
| 49 | +    libxrandr-dev \
 | |
| 50 | +    libxtst-dev \
 | |
| 51 | +    m4 \
 | |
| 52 | +    mercurial \
 | |
| 53 | +    nasm \
 | |
| 54 | +    pkg-config \
 | |
| 55 | +    python3 \
 | |
| 56 | +    python3-pip \
 | |
| 57 | +    unzip \
 | |
| 58 | +    wget
 | |
| 59 | + | |
| 60 | +COPY taskcluster/docker/recipes/install-node.sh /scripts/install-node.sh
 | |
| 61 | +RUN chmod +x /scripts/install-node.sh
 | |
| 62 | +RUN /scripts/install-node.sh
 | |
| 63 | + | |
| 64 | +RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
 | |
| 65 | +RUN $HOME/.cargo/bin/cargo install cbindgen
 | |
| 66 | + | |
| 67 | +WORKDIR /app
 | |
| 68 | + | |
| 69 | +CMD ["/bin/bash"] | 
| 1 | -variables:
 | |
| 2 | -  # This needs to be kept in sync with the max Python version accepted by ./mach
 | |
| 3 | -  PYTHON_VERSION: "3.11.7"
 | |
| 4 | - | |
| 5 | 1 |  .base:
 | 
| 6 | 2 |    stage: lint
 | 
| 7 | 3 |    interruptible: true
 | 
| 8 | 4 |    variables:
 | 
| 9 | -    PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
 | |
| 5 | +    MOZBUILD_STATE_PATH: "$CI_PROJECT_DIR/.cache/mozbuild"
 | |
| 10 | 6 |    cache:
 | 
| 11 | 7 |      paths:
 | 
| 12 | 8 |        - node_modules
 | 
| 13 | -      - .cache/pip
 | |
| 9 | +      - .cache/mozbuild
 | |
| 10 | +    # Store the cache regardless on job outcome
 | |
| 11 | +    when: 'always'
 | |
| 12 | +    # Share the cache throughout all pipelines running for a given branch
 | |
| 13 | +    key: $CI_COMMIT_REF_SLUG
 | |
| 14 | 14 | |
| 15 | 15 |  eslint:
 | 
| 16 | 16 |    extends: .base
 | 
| 17 | -  image: cimg/python:$PYTHON_VERSION-node
 | |
| 17 | +  image: $IMAGE_PATH
 | |
| 18 | 18 |    script:
 | 
| 19 | 19 |      - .gitlab/ci/scripts/run_linters.py eslint
 | 
| 20 | 20 |    rules:
 | 
| ... | ... | @@ -45,7 +45,7 @@ eslint: | 
| 45 | 45 | |
| 46 | 46 |  stylelint:
 | 
| 47 | 47 |    extends: .base
 | 
| 48 | -  image: cimg/python:$PYTHON_VERSION-node
 | |
| 48 | +  image: $IMAGE_PATH
 | |
| 49 | 49 |    script:
 | 
| 50 | 50 |      - .gitlab/ci/scripts/run_linters.py stylelint
 | 
| 51 | 51 |    rules:
 | 
| ... | ... | @@ -65,7 +65,7 @@ stylelint: | 
| 65 | 65 | |
| 66 | 66 |  py-black:
 | 
| 67 | 67 |    extends: .base
 | 
| 68 | -  image: cimg/python:$PYTHON_VERSION
 | |
| 68 | +  image: $IMAGE_PATH
 | |
| 69 | 69 |    script:
 | 
| 70 | 70 |      - .gitlab/ci/scripts/run_linters.py black
 | 
| 71 | 71 |    rules:
 | 
| ... | ... | @@ -86,7 +86,7 @@ py-black: | 
| 86 | 86 | |
| 87 | 87 |  py-ruff:
 | 
| 88 | 88 |    extends: .base
 | 
| 89 | -  image: cimg/python:$PYTHON_VERSION
 | |
| 89 | +  image: $IMAGE_PATH
 | |
| 90 | 90 |    script:
 | 
| 91 | 91 |      - .gitlab/ci/scripts/run_linters.py ruff
 | 
| 92 | 92 |    rules:
 | 
| ... | ... | @@ -107,7 +107,7 @@ py-ruff: | 
| 107 | 107 | |
| 108 | 108 |  yaml:
 | 
| 109 | 109 |    extends: .base
 | 
| 110 | -  image: cimg/python:$PYTHON_VERSION
 | |
| 110 | +  image: $IMAGE_PATH
 | |
| 111 | 111 |    script:
 | 
| 112 | 112 |      - .gitlab/ci/scripts/run_linters.py yaml
 | 
| 113 | 113 |    rules:
 | 
| ... | ... | @@ -124,7 +124,7 @@ yaml: | 
| 124 | 124 | |
| 125 | 125 |  shellcheck:
 | 
| 126 | 126 |    extends: .base
 | 
| 127 | -  image: cimg/python:$PYTHON_VERSION
 | |
| 127 | +  image: $IMAGE_PATH
 | |
| 128 | 128 |    script:
 | 
| 129 | 129 |      - .gitlab/ci/scripts/run_linters.py shellcheck
 | 
| 130 | 130 |    rules:
 | 
| ... | ... | @@ -140,8 +140,9 @@ shellcheck: | 
| 140 | 140 | |
| 141 | 141 |  clang-format:
 | 
| 142 | 142 |    extends: .base
 | 
| 143 | -  image: cimg/python:$PYTHON_VERSION
 | |
| 143 | +  image: $IMAGE_PATH
 | |
| 144 | 144 |    script:
 | 
| 145 | +    - ./mach configure --without-wasm-sandboxed-libraries --with-base-browser-version=0.0.0
 | |
| 145 | 146 |      - .gitlab/ci/scripts/run_linters.py clang-format
 | 
| 146 | 147 |    rules:
 | 
| 147 | 148 |      - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
 | 
| ... | ... | @@ -161,7 +162,7 @@ clang-format: | 
| 161 | 162 | |
| 162 | 163 |  rustfmt:
 | 
| 163 | 164 |    extends: .base
 | 
| 164 | -  image: cimg/python:$PYTHON_VERSION
 | |
| 165 | +  image: $IMAGE_PATH
 | |
| 165 | 166 |    script:
 | 
| 166 | 167 |      - .gitlab/ci/scripts/run_linters.py rustfmt
 | 
| 167 | 168 |    rules:
 | 
| ... | ... | @@ -177,7 +178,7 @@ rustfmt: | 
| 177 | 178 | |
| 178 | 179 |  fluent-lint:
 | 
| 179 | 180 |    extends: .base
 | 
| 180 | -  image: cimg/python:$PYTHON_VERSION
 | |
| 181 | +  image: $IMAGE_PATH
 | |
| 181 | 182 |    script:
 | 
| 182 | 183 |      - .gitlab/ci/scripts/run_linters.py fluent-lint
 | 
| 183 | 184 |    rules:
 | 
| ... | ... | @@ -194,7 +195,7 @@ fluent-lint: | 
| 194 | 195 | |
| 195 | 196 |  localization:
 | 
| 196 | 197 |    extends: .base
 | 
| 197 | -  image: cimg/python:$PYTHON_VERSION
 | |
| 198 | +  image: $IMAGE_PATH
 | |
| 198 | 199 |    script:
 | 
| 199 | 200 |      - .gitlab/ci/scripts/run_linters.py l10n
 | 
| 200 | 201 |    rules:
 | 
| ... | ... | @@ -213,7 +214,7 @@ localization: | 
| 213 | 214 | |
| 214 | 215 |  mingw-capitalization:
 | 
| 215 | 216 |    extends: .base
 | 
| 216 | -  image: cimg/python:$PYTHON_VERSION
 | |
| 217 | +  image: $IMAGE_PATH
 | |
| 217 | 218 |    script:
 | 
| 218 | 219 |      - .gitlab/ci/scripts/run_linters.py mingw-capitalization
 | 
| 219 | 220 |    rules:
 | 
| ... | ... | @@ -232,7 +233,7 @@ mingw-capitalization: | 
| 232 | 233 | |
| 233 | 234 |  mscom-init:
 | 
| 234 | 235 |    extends: .base
 | 
| 235 | -  image: cimg/python:$PYTHON_VERSION
 | |
| 236 | +  image: $IMAGE_PATH
 | |
| 236 | 237 |    script:
 | 
| 237 | 238 |      - .gitlab/ci/scripts/run_linters.py mscom-init
 | 
| 238 | 239 |    rules:
 | 
| ... | ... | @@ -251,7 +252,7 @@ mscom-init: | 
| 251 | 252 | |
| 252 | 253 |  file-whitespace:
 | 
| 253 | 254 |    extends: .base
 | 
| 254 | -  image: cimg/python:$PYTHON_VERSION
 | |
| 255 | +  image: $IMAGE_PATH
 | |
| 255 | 256 |    script:
 | 
| 256 | 257 |      - .gitlab/ci/scripts/run_linters.py file-whitespace
 | 
| 257 | 258 |    rules:
 | 
| ... | ... | @@ -282,7 +283,7 @@ file-whitespace: | 
| 282 | 283 | |
| 283 | 284 |  test-manifest:
 | 
| 284 | 285 |    extends: .base
 | 
| 285 | -  image: cimg/python:$PYTHON_VERSION
 | |
| 286 | +  image: $IMAGE_PATH
 | |
| 286 | 287 |    script:
 | 
| 287 | 288 |      - .gitlab/ci/scripts/run_linters.py test-manifest-alpha test-manifest-disable test-manifest-skip-if
 | 
| 288 | 289 |    rules:
 | 
| ... | ... | @@ -299,7 +300,7 @@ test-manifest: | 
| 299 | 300 | |
| 300 | 301 |  trojan-source:
 | 
| 301 | 302 |    extends: .base
 | 
| 302 | -  image: cimg/python:$PYTHON_VERSION
 | |
| 303 | +  image: $IMAGE_PATH
 | |
| 303 | 304 |    script:
 | 
| 304 | 305 |      - .gitlab/ci/scripts/run_linters.py trojan-source
 | 
| 305 | 306 |    rules:
 | 
| ... | ... | @@ -54,7 +54,7 @@ def get_firefox_tag_from_branch_name(branch_name): | 
| 54 | 54 |          return match.group(0).split()[0]
 | 
| 55 | 55 |      else:
 | 
| 56 | 56 |          raise ValueError(
 | 
| 57 | -            f"Failed to find reference specifier for Firefox tag in branch '{branch_name}'."
 | |
| 57 | +            f"Failed to find reference specifier for Firefox tag '{tag}' in branch '{branch_name}'."
 | |
| 58 | 58 |          )
 | 
| 59 | 59 | |
| 60 | 60 | |
| ... | ... | @@ -98,13 +98,13 @@ if __name__ == "__main__": | 
| 98 | 98 |      )
 | 
| 99 | 99 |      args = parser.parse_args()
 | 
| 100 | 100 | |
| 101 | -    command = [
 | |
| 102 | -        "./mach",
 | |
| 103 | -        "lint",
 | |
| 104 | -        "-v",
 | |
| 105 | -        *(s for l in args.linters for s in ("-l", l)),
 | |
| 106 | -        *get_list_of_changed_files(),
 | |
| 107 | -    ]
 | |
| 108 | -    result = subprocess.run(command, text=True)
 | |
| 109 | - | |
| 110 | -    sys.exit(result.returncode) | |
| 101 | +    changed_files = get_list_of_changed_files()
 | |
| 102 | +    if changed_files:
 | |
| 103 | +        command = ["./mach", "lint", "-v"]
 | |
| 104 | +        for linter in args.linters:
 | |
| 105 | +            command.extend(["-l", linter])
 | |
| 106 | +        command.extend(changed_files)
 | |
| 107 | +        result = subprocess.run(command, text=True)
 | |
| 108 | +        sys.exit(result.returncode)
 | |
| 109 | +    else:
 | |
| 110 | +        print("No files changed, skipping linting.") |