[tor-commits] [Git][tpo/applications/tor-browser][base-browser-128.0esr-14.0-1] 2 commits: fixup! Add CI for Base Browser

Pier Angelo Vendrame (@pierov) git at gitlab.torproject.org
Thu Jul 18 09:34:35 UTC 2024



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
fixup! Add CI for Base Browser

Bug 42722: Use custom Dockerfile for lint CI jobs to address
missing dependencies issues with clang-format and l10n linters.

- - - - -
fa88a433 by Beatriz Rizental at 2024-07-18T11:34:24+02:00
fixup! Add CI for Base Browser

Bug 42722: Cache mozbuild path instead of specifically the pip path

- - - - -


4 changed files:

- .gitlab-ci.yml
- + .gitlab/ci/docker/base/Dockerfile
- .gitlab/ci/lint.yml
- .gitlab/ci/scripts/run_linters.py


Changes:

=====================================
.gitlab-ci.yml
=====================================
@@ -1,5 +1,8 @@
 stages:
   - lint
 
+variables:
+  IMAGE_PATH: containers.torproject.org/tpo/applications/tor-browser/base:latest
+
 include:
   - local: '.gitlab/ci/lint.yml'


=====================================
.gitlab/ci/docker/base/Dockerfile
=====================================
@@ -0,0 +1,69 @@
+FROM debian:latest
+
+# Base image which includes all* dependencies checked by ./mach configure.
+#
+# * Actually not all dependencies. WASM sandboxed depencies were left out for now.
+# This installs all dependencies checked by `./mach configure --without-wasm-sandboxed-libraries`.
+#
+# # Building and publishing
+#
+# Whenever this file changes, the updated Docker image must be built and published _manually_ to
+# the tor-browser container registry (https://gitlab.torproject.org/tpo/applications/tor-browser/container_registry/185).
+#
+# This image copies a script from the taskcluster/ folder, which requires it
+# to be built from a folder which is a parent of the taskcluster/ folder.
+#
+# To build, run:
+#
+# ```bash
+# docker build \
+#   -f <PATH_TO_DOCKERFILE> \
+#   -t <REGISTRY_URL>/<IMAGE_NAME>:<IMAGE_TAG>
+#   .
+# ```
+#
+# For example, when building from the root of this repository to the main tor-browser repository
+# and assuming image name to be "base" and tag "latest" -- which is the current terminology:
+#
+# ```bash
+# docker build \
+#   -f .gitlab/ci/docker/Dockerfile \
+#   -t containers.torproject.org/tpo/applications/tor-browser/base:latest
+#   .
+# ```
+
+RUN apt-get update && apt-get install -y \
+    clang \
+    curl \
+    git \
+    libasound2-dev \
+    libdbus-glib-1-dev \
+    libgtk-3-dev \
+    libpango1.0-dev \
+    libpulse-dev \
+    libx11-xcb-dev \
+    libxcomposite-dev \
+    libxcursor-dev \
+    libxdamage-dev \
+    libxi-dev \
+    libxrandr-dev \
+    libxtst-dev \
+    m4 \
+    mercurial \
+    nasm \
+    pkg-config \
+    python3 \
+    python3-pip \
+    unzip \
+    wget
+
+COPY taskcluster/docker/recipes/install-node.sh /scripts/install-node.sh
+RUN chmod +x /scripts/install-node.sh
+RUN /scripts/install-node.sh
+
+RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
+RUN $HOME/.cargo/bin/cargo install cbindgen
+
+WORKDIR /app
+
+CMD ["/bin/bash"]


=====================================
.gitlab/ci/lint.yml
=====================================
@@ -1,20 +1,20 @@
-variables:
-  # This needs to be kept in sync with the max Python version accepted by ./mach
-  PYTHON_VERSION: "3.11.7"
-
 .base:
   stage: lint
   interruptible: true
   variables:
-    PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
+    MOZBUILD_STATE_PATH: "$CI_PROJECT_DIR/.cache/mozbuild"
   cache:
     paths:
       - node_modules
-      - .cache/pip
+      - .cache/mozbuild
+    # Store the cache regardless on job outcome
+    when: 'always'
+    # Share the cache throughout all pipelines running for a given branch
+    key: $CI_COMMIT_REF_SLUG
 
 eslint:
   extends: .base
-  image: cimg/python:$PYTHON_VERSION-node
+  image: $IMAGE_PATH
   script:
     - .gitlab/ci/scripts/run_linters.py eslint
   rules:
@@ -45,7 +45,7 @@ eslint:
 
 stylelint:
   extends: .base
-  image: cimg/python:$PYTHON_VERSION-node
+  image: $IMAGE_PATH
   script:
     - .gitlab/ci/scripts/run_linters.py stylelint
   rules:
@@ -65,7 +65,7 @@ stylelint:
 
 py-black:
   extends: .base
-  image: cimg/python:$PYTHON_VERSION
+  image: $IMAGE_PATH
   script:
     - .gitlab/ci/scripts/run_linters.py black
   rules:
@@ -86,7 +86,7 @@ py-black:
 
 py-ruff:
   extends: .base
-  image: cimg/python:$PYTHON_VERSION
+  image: $IMAGE_PATH
   script:
     - .gitlab/ci/scripts/run_linters.py ruff
   rules:
@@ -107,7 +107,7 @@ py-ruff:
 
 yaml:
   extends: .base
-  image: cimg/python:$PYTHON_VERSION
+  image: $IMAGE_PATH
   script:
     - .gitlab/ci/scripts/run_linters.py yaml
   rules:
@@ -124,7 +124,7 @@ yaml:
 
 shellcheck:
   extends: .base
-  image: cimg/python:$PYTHON_VERSION
+  image: $IMAGE_PATH
   script:
     - .gitlab/ci/scripts/run_linters.py shellcheck
   rules:
@@ -140,8 +140,9 @@ shellcheck:
 
 clang-format:
   extends: .base
-  image: cimg/python:$PYTHON_VERSION
+  image: $IMAGE_PATH
   script:
+    - ./mach configure --without-wasm-sandboxed-libraries --with-base-browser-version=0.0.0
     - .gitlab/ci/scripts/run_linters.py clang-format
   rules:
     - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
@@ -161,7 +162,7 @@ clang-format:
 
 rustfmt:
   extends: .base
-  image: cimg/python:$PYTHON_VERSION
+  image: $IMAGE_PATH
   script:
     - .gitlab/ci/scripts/run_linters.py rustfmt
   rules:
@@ -177,7 +178,7 @@ rustfmt:
 
 fluent-lint:
   extends: .base
-  image: cimg/python:$PYTHON_VERSION
+  image: $IMAGE_PATH
   script:
     - .gitlab/ci/scripts/run_linters.py fluent-lint
   rules:
@@ -194,7 +195,7 @@ fluent-lint:
 
 localization:
   extends: .base
-  image: cimg/python:$PYTHON_VERSION
+  image: $IMAGE_PATH
   script:
     - .gitlab/ci/scripts/run_linters.py l10n
   rules:
@@ -213,7 +214,7 @@ localization:
 
 mingw-capitalization:
   extends: .base
-  image: cimg/python:$PYTHON_VERSION
+  image: $IMAGE_PATH
   script:
     - .gitlab/ci/scripts/run_linters.py mingw-capitalization
   rules:
@@ -232,7 +233,7 @@ mingw-capitalization:
 
 mscom-init:
   extends: .base
-  image: cimg/python:$PYTHON_VERSION
+  image: $IMAGE_PATH
   script:
     - .gitlab/ci/scripts/run_linters.py mscom-init
   rules:
@@ -251,7 +252,7 @@ mscom-init:
 
 file-whitespace:
   extends: .base
-  image: cimg/python:$PYTHON_VERSION
+  image: $IMAGE_PATH
   script:
     - .gitlab/ci/scripts/run_linters.py file-whitespace
   rules:
@@ -282,7 +283,7 @@ file-whitespace:
 
 test-manifest:
   extends: .base
-  image: cimg/python:$PYTHON_VERSION
+  image: $IMAGE_PATH
   script:
     - .gitlab/ci/scripts/run_linters.py test-manifest-alpha test-manifest-disable test-manifest-skip-if
   rules:
@@ -299,7 +300,7 @@ test-manifest:
 
 trojan-source:
   extends: .base
-  image: cimg/python:$PYTHON_VERSION
+  image: $IMAGE_PATH
   script:
     - .gitlab/ci/scripts/run_linters.py trojan-source
   rules:


=====================================
.gitlab/ci/scripts/run_linters.py
=====================================
@@ -54,7 +54,7 @@ def get_firefox_tag_from_branch_name(branch_name):
         return match.group(0).split()[0]
     else:
         raise ValueError(
-            f"Failed to find reference specifier for Firefox tag in branch '{branch_name}'."
+            f"Failed to find reference specifier for Firefox tag '{tag}' in branch '{branch_name}'."
         )
 
 
@@ -98,13 +98,13 @@ if __name__ == "__main__":
     )
     args = parser.parse_args()
 
-    command = [
-        "./mach",
-        "lint",
-        "-v",
-        *(s for l in args.linters for s in ("-l", l)),
-        *get_list_of_changed_files(),
-    ]
-    result = subprocess.run(command, text=True)
-
-    sys.exit(result.returncode)
+    changed_files = get_list_of_changed_files()
+    if changed_files:
+        command = ["./mach", "lint", "-v"]
+        for linter in args.linters:
+            command.extend(["-l", linter])
+        command.extend(changed_files)
+        result = subprocess.run(command, text=True)
+        sys.exit(result.returncode)
+    else:
+        print("No files changed, skipping linting.")



View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/1f329b97d3037d83ec4a9ec38dad191436f57f23...fa88a4333bf83e26f96fec8566406815218663b9

-- 
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/1f329b97d3037d83ec4a9ec38dad191436f57f23...fa88a4333bf83e26f96fec8566406815218663b9
You're receiving this email because of your account on gitlab.torproject.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tor-commits/attachments/20240718/1fcc9f66/attachment-0001.htm>


More information about the tor-commits mailing list