Files
sousa-gecko/tools/update-verify/scripts/chunked-verify.py
T
Heitor Neiva 5664b93865 Bug 2029828 - Make update-verify Docker image self-contained by embedding scripts r=releng-reviewers,taskgraph-reviewers,bhearsum
The update-verify job no longer checks out the repository. Instead, the
scripts from tools/update-verify and their Python dependencies (mozrelease,
redo) are baked into the Docker image via COPY directives. The shell scripts
now use python3 directly instead of ./mach python.

Overall changes:
- Run update verify tests in a specific workspace directory
- Use `UV_SRC` as the base for other relative imports and references
- COPY required scripts and drop the checkout on update verify docker image
- Run update verify with python directly instead of mach

Differential Revision: https://phabricator.services.mozilla.com/D288300
2026-04-10 16:20:17 +00:00

76 lines
2.6 KiB
Python

#!/usr/bin/env python3
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
import logging
import os
import sys
from os import path
from tempfile import mkstemp
UV_SRC = os.environ.get("UV_SRC", path.dirname(path.dirname(__file__)))
sys.path.append(path.join(UV_SRC, "python"))
logging.basicConfig(stream=sys.stdout, level=logging.INFO, format="%(message)s")
log = logging.getLogger(__name__)
from async_download import download_from_config
from mozrelease.update_verify import UpdateVerifyConfig
from util.commands import run_cmd
UPDATE_VERIFY_COMMAND = [
"bash",
path.join(UV_SRC, "release/updates/verify.sh"),
"-c",
]
WORKSPACE_DIR = os.environ.get("WORKSPACE_DIR", path.join(os.getcwd(), "workspace"))
if __name__ == "__main__":
from argparse import ArgumentParser
parser = ArgumentParser("")
parser.set_defaults(
chunks=None,
thisChunk=None,
)
parser.add_argument("--verify-config", required=True, dest="verifyConfig")
parser.add_argument("--verify-channel", required=True, dest="verify_channel")
parser.add_argument("--chunks", required=True, dest="chunks", type=int)
parser.add_argument("--this-chunk", required=True, dest="thisChunk", type=int)
parser.add_argument("--diff-summary", required=True, type=str)
options = parser.parse_args()
assert options.chunks and options.thisChunk, "chunks and this-chunk are required"
assert path.isfile(options.verifyConfig), "Update verify config must exist!"
verifyConfigFile = options.verifyConfig
fd, configFile = mkstemp()
# Needs to be opened in "bytes" mode because we perform relative seeks on it
fh = os.fdopen(fd, "wb")
try:
verifyConfig = UpdateVerifyConfig()
verifyConfig.read(verifyConfigFile)
myVerifyConfig = verifyConfig.getChunk(options.chunks, options.thisChunk)
# override the channel if explicitly set
if options.verify_channel:
myVerifyConfig.channel = options.verify_channel
myVerifyConfig.write(fh)
fh.close()
run_cmd(["cat", configFile])
# Before verifying, we want to download and cache all required files
download_from_config(myVerifyConfig)
os.makedirs(WORKSPACE_DIR, exist_ok=True)
run_cmd(
UPDATE_VERIFY_COMMAND + [configFile],
cwd=WORKSPACE_DIR,
env={"DIFF_SUMMARY_LOG": path.abspath(options.diff_summary)},
)
finally:
if path.exists(configFile):
os.unlink(configFile)