[tbb-commits] [Git][tpo/applications/tor-browser][tor-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:23:53 UTC 2024



Pier Angelo Vendrame pushed to branch tor-browser-128.0esr-14.0-1 at The Tor Project / Applications / Tor Browser


Commits:
a274adca by Beatriz Rizental at 2024-07-18T09:17:07+00: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.

- - - - -
83fef5d0 by Beatriz Rizental at 2024-07-18T09:17:07+00: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
=====================================
@@ -2,6 +2,9 @@ stages:
   - lint
   - update-translations
 
+variables:
+  IMAGE_PATH: containers.torproject.org/tpo/applications/tor-browser/base:latest
+
 include:
   - local: '.gitlab/ci/lint.yml'
   - local: '.gitlab/ci/update-translations.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/8c9bb13d71828b138f97577d3de0faf9f7bcb26c...83fef5d0e37892704f22f6c1d0578d4496fba341

-- 
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/8c9bb13d71828b138f97577d3de0faf9f7bcb26c...83fef5d0e37892704f22f6c1d0578d4496fba341
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/tbb-commits/attachments/20240718/fe484bc2/attachment-0001.htm>


More information about the tbb-commits mailing list