Make the microannotate_generator script generate a version file and upload it as an artifact

This is a pre-requisite to regenerating the repos when there are meaningful changes in
rust-code-analysis or microannotate.
This commit is contained in:
Marco Castelluccio 2019-12-21 14:55:14 +01:00
Родитель e783316049
Коммит 10135b6ef5
2 изменённых файлов: 23 добавлений и 1 удалений

Просмотреть файл

@ -26,6 +26,10 @@ tasks:
- /cache/ - /cache/
- https://github.com/marco-c/gecko-dev-wordified - https://github.com/marco-c/gecko-dev-wordified
- --tokenize - --tokenize
artifacts:
public/gecko-dev-wordified.version:
path: /data/gecko-dev-wordified.version
type: file
cache: cache:
bugbug-mercurial-repository: /cache bugbug-mercurial-repository: /cache
features: features:
@ -61,6 +65,10 @@ tasks:
- /cache/ - /cache/
- https://github.com/marco-c/gecko-dev-comments-removed - https://github.com/marco-c/gecko-dev-comments-removed
- --remove-comments - --remove-comments
artifacts:
public/gecko-dev-comments-removed.version:
path: /data/gecko-dev-comments-removed.version
type: file
cache: cache:
bugbug-mercurial-repository: /cache bugbug-mercurial-repository: /cache
features: features:
@ -97,6 +105,10 @@ tasks:
- https://github.com/marco-c/gecko-dev-wordified-and-comments-removed - https://github.com/marco-c/gecko-dev-wordified-and-comments-removed
- --tokenize - --tokenize
- --remove-comments - --remove-comments
artifacts:
public/gecko-dev-wordified-and-comments-removed.version:
path: /data/gecko-dev-wordified-and-comments-removed.version
type: file
cache: cache:
bugbug-mercurial-repository: /cache bugbug-mercurial-repository: /cache
features: features:

Просмотреть файл

@ -8,13 +8,17 @@ from logging import INFO, basicConfig, getLogger
from microannotate import generator from microannotate import generator
from bugbug import repository from bugbug import db, repository
from bugbug.utils import get_secret, retry from bugbug.utils import get_secret, retry
basicConfig(level=INFO) basicConfig(level=INFO)
logger = getLogger(__name__) logger = getLogger(__name__)
# When updating the version, the git repositories will be recreated from scratch.
# This is useful when new meaningful versions of rust-code-analysis or microannotate
# are used.
VERSION = 1
COMMITS_STEP = 5000 COMMITS_STEP = 5000
@ -30,6 +34,12 @@ class MicroannotateGenerator(object):
self.repo_dir = os.path.join(cache_root, "mozilla-central") self.repo_dir = os.path.join(cache_root, "mozilla-central")
def generate(self): def generate(self):
db.register(
self.git_repo_path,
f"https://community-tc.services.mozilla.com/api/index/v1/task/project.relman.bugbug.microannotate_{self.git_repo_path}.latest/artifacts/public/",
VERSION,
)
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor: with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
cloner = executor.submit(repository.clone, self.repo_dir) cloner = executor.submit(repository.clone, self.repo_dir)
cloner.add_done_callback( cloner.add_done_callback(