Commit f970b38c authored by henry's avatar henry Committed by henry
Browse files

fixup! Add CI for Base Browser



TB 44104: Do not run linter when a merge request has no overall change.

We also use `\0` to separate file names, rather than `\n`.


(cherry picked from commit 87c721a5889b1a2c4ecf9658afe72f78077fe8be)

Co-authored-by: default avatarHenry Wilkes <henry@torproject.org>
parent b95639fd
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -84,6 +84,10 @@ def get_list_of_changed_files():
    if os.getenv("CI_PIPELINE_SOURCE") == "merge_request_event":
        # For merge requests, the base_reference is the common ancestor between the MR and the target branch
        base_reference = os.getenv("CI_MERGE_REQUEST_DIFF_BASE_SHA")
        if not base_reference:
            # Probably because there has been no overall change.
            # See gitlab.com/gitlab-org/gitlab/-/issues/375047#note_2648459916
            return []
    else:
        # When not in merge requests, the base reference is the Firefox tag
        base_reference = get_firefox_tag(os.getenv("CI_COMMIT_BRANCH"))
@@ -118,6 +122,8 @@ if __name__ == "__main__":
    if args.get_firefox_tag:
        print(get_firefox_tag(args.get_firefox_tag))
    elif args.get_changed_files:
        print("\n".join(get_list_of_changed_files()))
        # Separate the file names with a 0 byte to be parsed by xargs -0. Also
        # drop the trailing '\n'.
        print("\0".join(get_list_of_changed_files()), end="")
    else:
        print("No valid option provided.")
+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ lint-all:
    - firefox
  script:
    - ./mach configure --without-wasm-sandboxed-libraries --with-base-browser-version=0.0.0
    - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -v
    - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -0 --no-run-if-empty ./mach lint -v
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
    # Run job whenever a commit is merged to a protected branch