Andrew Geissler | 23e0279 | 2023-07-21 09:06:10 -0500 | [diff] [blame] | 1 | #! /usr/bin/env python3 |
| 2 | |
| 3 | """ |
| 4 | Download the lockfile.yml produced by a CI pipeline, specified by the GitLab |
| 5 | server, full name of the meta-arm project, and the refspec that was executed. |
| 6 | |
| 7 | For example, |
| 8 | $ ./download-lockfile.py https://gitlab.com/ rossburton/meta-arm master |
| 9 | |
| 10 | SPDX-FileCopyrightText: Copyright 2023 Arm Limited and Contributors |
| 11 | SPDX-License-Identifier: GPL-2.0-only |
| 12 | """ |
| 13 | |
| 14 | import argparse |
| 15 | import gitlab |
| 16 | import io |
| 17 | import zipfile |
| 18 | |
| 19 | parser = argparse.ArgumentParser() |
| 20 | parser.add_argument("server", help="GitLab server name") |
| 21 | parser.add_argument("project", help="meta-arm project name") |
| 22 | parser.add_argument("refspec", help="Branch/commit") |
| 23 | args = parser.parse_args() |
| 24 | |
| 25 | gl = gitlab.Gitlab(args.server) |
| 26 | project = gl.projects.get(args.project) |
| 27 | artefact = project.artifacts.download(ref_name=args.refspec, job="update-repos") |
| 28 | |
| 29 | z = zipfile.ZipFile(io.BytesIO(artefact)) |
| 30 | z.extract("lockfile.yml") |
| 31 | print("Fetched lockfile.yml") |