Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Slowroll:Build:1
obs-scm-bridge
obs-scm-bridge-0.5.2.obscpio
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File obs-scm-bridge-0.5.2.obscpio of Package obs-scm-bridge
07070100000000000041ED0000000000000000000000026734C0B500000000000000000000000000000000000000000000001D00000000obs-scm-bridge-0.5.2/.github07070100000001000041ED0000000000000000000000026734C0B500000000000000000000000000000000000000000000002700000000obs-scm-bridge-0.5.2/.github/workflows07070100000002000081A40000000000000000000000016734C0B500000268000000000000000000000000000000000000002E00000000obs-scm-bridge-0.5.2/.github/workflows/ci.yml--- name: CI on: push: branches: - "main" pull_request: jobs: integration: name: Run the integration tests runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: python-version: '3.11' cache: 'pip' - uses: actions/cache@v3 with: path: ~/.cache/pypoetry/virtualenvs key: poetry-${{ hashFiles('poetry.lock') }} - run: | pip install --upgrade poetry - name: Run tests run: | poetry install poetry run pytest -vv -- -n auto 07070100000003000081A40000000000000000000000016734C0B500000114000000000000000000000000000000000000002000000000obs-scm-bridge-0.5.2/DEVELOP.md To execute the test suite locally, run: ```ShellSession $ poetry run pytest -vv -x --pytest-container-log-level=debug ``` To run the tests in parallel, add the `-n auto` or `-n $nproc` parameter. To run only a specific test case, append the `-k $TEST_CASE_NAME` parameter. 07070100000004000081A40000000000000000000000016734C0B5000044EB000000000000000000000000000000000000001D00000000obs-scm-bridge-0.5.2/LICENSE GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. one line to give the program's name and an idea of what it does. Copyright (C) yyyy name of author This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. 07070100000005000081A40000000000000000000000016734C0B500000179000000000000000000000000000000000000001E00000000obs-scm-bridge-0.5.2/Makefileprefix = /usr PYTHON ?= python servicedir = ${prefix}/lib/obs/service all: install: install -d $(DESTDIR)$(servicedir) install -m 0755 obs_scm_bridge $(DESTDIR)$(servicedir) test: flake8 set_version tests/ ${PYTHON} -m unittest discover tests/ clean: find -name "*.pyc" -exec rm {} \; find -name '*.pyo' -exec rm {} \; rm -rf set_versionc .PHONY: all install test 07070100000006000081A40000000000000000000000016734C0B500000E7C000000000000000000000000000000000000001F00000000obs-scm-bridge-0.5.2/README.md Native OBS SCM bridge helper ============================ Native OBS scm support for the build recipies and additional files. This is bridging an external authoritative scm repository into OBS. Any source change or merge workflow must be provided via the scm repository hoster in this scenario. Only git is supported atm, but this can be extended later to further systems. It is not recommended to put large binary files into git directly as this won't scale. Use the asset support instead, which is described in pbuild documentation: http://opensuse.github.io/obs-build/pbuild.html#_remote_assets These assets will be downloaded by osc and OBS. The verification via sha256 sum is optional. Alternatively, put large binary files into [git-lfs](https://git-lfs.github.com/). This service will automatically download git-lfs assets. HOWTO manage a single package ============================= The current way to define a git repository for an OBS package is using the `scmsync` element inside the package meta. ``` <scmsync>https://github.com/foo/bar</scmsync> ``` For doing a local checkout use a 1.0 release candidate of osc. This version allows you to do # osc co $project <$package> which will create a git repository inside of the classic osc checkout. It also supports local building, but you need to use git for any source modification or operation. HOWTO manage an entire project ============================== A git repository can also get defined for entire project. This can be done via the scmsync element in project meta. Any top level subdirectory will be handled as package container. It is recomended to use git submodules for each package if it is a larger project. This allows partial cloning of the specific package. Special directives ================== Special directives can be given via cgi parameters to the bridge. Extend your url with * `lfs=0` to skip downloading LFS assets * arch=<ARCH> CGI parameter to specify arch specific assets downloads * keepmeta=1 CGI parameter to include full git vcs data (.git directory) * subdir=<DIRECTORY> CGI parameter to package only a subdirectory Special directives for entire projects ====================================== * projectmode=1 is switching project mode on. The bridge will just prepare package meta files for each subdirectory. * onlybuild=<DIRECTORY> can be used to specify to only export defined packages without modifing the git source. The parameter can be used multiple times to collect multiple. Special configuration files =========================== These configuration files are optional and usually only used on OBS server side. /etc/obs/services/scm-bridge/critical-instances Each line contain a list of critical git server instances. These instances are support to be reachable always. In case of errors the OBS server will retry always to re-run the server. Please note that dropped or not accessible repositories still count as an error. /etc/obs/services/scm-bridge/credentials Each line must contain a triplet with a space seperated: PROJECT_NAMESPACE HOSTNAME USERNAME TOKEN/PASSWORD These credentials will be used for git cloning when no other credentials are defined in the specified URL. PROJECT_NAMESPACE is also valid for all sub projects. When using '*' it is valid for all projects. TODO ==== * signature validation * find a better way to store files in .osc and .assets of the checkout, as they do not belong to the git repository auto extending .gitignore? (esp. when downloading asset files?) * make cpio generation bit identical (avoiding mtime from clone) 07070100000007000081A40000000000000000000000016734C0B50000072A000000000000000000000000000000000000002900000000obs-scm-bridge-0.5.2/obs-scm-bridge.spec# # spec file for package obs-scm-bridge # # Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via https://bugs.opensuse.org/ # %if 0%{?fedora} || 0%{?rhel} %define build_pkg_name obs-build %else %define build_pkg_name build %endif Name: obs-scm-bridge Version: 0.4.2 Release: 0 Summary: A help service to work with git repositories in OBS License: GPL-2.0-or-later URL: https://github.com/openSUSE/obs-scm-bridge Source0: %{name}-%{version}.tar.xz BuildRequires: python311-PyYAML BuildRequires: python311-PyYAML Requires: %{build_pkg_name} >= 20211125 Requires: git-lfs # these are just recommends in build package, but we need it here Requires: perl(Date::Parse) Requires: perl(LWP::UserAgent) Requires: perl(Net::SSL) Requires: perl(Pod::Usage) Requires: perl(Time::Zone) Requires: perl(URI) Requires: perl(XML::Parser) Requires: perl(YAML::LibYAML) Requires: python311-PyYAML Recommends: python311-packaging BuildArch: noarch %if 0%{?fedora} || 0%{?rhel} Requires: git %else Requires: git-core %endif %description %prep %autosetup %build %install %make_install %files %{_prefix}/lib/obs/service %changelog 07070100000008000081A40000000000000000000000016734C0B500006C1C000000000000000000000000000000000000002400000000obs-scm-bridge-0.5.2/obs_scm_bridge#!/usr/bin/python3 # -*- coding: utf-8 -*- # scm (only git atm) cloning and packaging for Open Build Service # # (C) 2021 by Adrian Schröter <adrian@suse.de> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # See http://www.gnu.org/licenses/gpl-2.0.html for full license text. import argparse import os import re import shutil import sys import logging import subprocess import tempfile import yaml from html import escape from typing import Dict, List, Optional, Set, TextIO, Tuple, Union import urllib.parse import configparser download_assets = '/usr/lib/build/download_assets' critical_instances_config = "/etc/obs/services/scm-bridge/critical-instances" credentials_config = "/etc/obs/services/scm-bridge/credentials" export_debian_orig_from_git = '/usr/lib/build/export_debian_orig_from_git' pack_directories = False get_assets = False shallow_clone = True create_obsinfo = False if os.environ.get('DEBUG_SCM_BRIDGE') == "1": logging.getLogger().setLevel(logging.DEBUG) if os.environ.get('OBS_SERVICE_DAEMON'): pack_directories = True get_assets = True create_obsinfo = True if os.environ.get('OSC_VERSION'): get_assets = True shallow_clone = False create_obsinfo = False os.environ['LANG'] = "C" class ObsGit(object): _REGEXP = re.compile(r"^[a-zA-Z0-9\.\-\_\+]*$"); def __init__(self, outdir: str, url: str, projectscmsync: str) -> None: self.outdir = outdir self.revision = None self.subdir = None self.projectscmsync = projectscmsync self.keep_meta = False self.enforced_deep_clone = False self.arch = [] self.critical_git_servers = [] self.onlybuild = None self.url = list(urllib.parse.urlparse(url)) self.no_lfs = False self.enforce_bcntsynctag = False # for project level mode self.export_files = set(["_config", "_scmsync.obsinfo"]) self.gitsubmodules: Set[str] = set() self.revisions: Optional[Dict[str, str]] = None self.processed = {} self.git_store = None query = urllib.parse.parse_qs(self.url[4]) if "subdir" in query: self.subdir = query['subdir'][0] del query['subdir'] self.url[4] = urllib.parse.urlencode(query) if "arch" in query: self.arch = query['arch'] del query['arch'] self.url[4] = urllib.parse.urlencode(query) if "enforce_bcntsynctag" in query: self.enforce_bcntsynctag = True del query['enforce_bcntsynctag'] self.url[4] = urllib.parse.urlencode(query) if "keepmeta" in query: self.enforced_deep_clone = True self.keep_meta = True del query['keepmeta'] self.url[4] = urllib.parse.urlencode(query) if "lfs" in query: self.no_lfs = query["lfs"] == ["0"] del query["lfs"] self.url[4] = urllib.parse.urlencode(query) if "onlybuild" in query: ob = query['onlybuild'] self.onlybuild={ob[i]:1 for i in range(len(ob))} del query['onlybuild'] self.url[4] = urllib.parse.urlencode(query) if self.url[5]: self.revision = self.url[5] self.url[5] = '' # if we keep the meta files we always want a deep clone if self.keep_meta: shallow_clone = False # scmtoolurl is the url we pass to the the scm tool scmtoolurl = self.url.copy() if scmtoolurl[0] and scmtoolurl[0][0:4] == 'git+': scmtoolurl[0] = scmtoolurl[0][4:] self.scmtoolurl = urllib.parse.urlunparse(scmtoolurl) def add_critical_instance( self, name: str ) -> None: self.critical_git_servers.append(name) def setup_credentials( self, cred_file: str ) -> None: self.git_store = tempfile.mkstemp(prefix="obs-scm-bridge-git-cred-store", text=True) cmd = [ 'git', 'config', '--global', 'credential.helper', f"store --file {self.git_store[1]}" ] self.run_cmd(cmd, fatal="git config credential.helper") with open(cred_file, "r", encoding="utf-8") as cred: for l in cred.readlines(): line = l.rstrip() entry = line.split(' ') if len(entry) != 4: continue project = str(os.getenv('OBS_SERVICE_PROJECT')) if entry[0] != '*' and not project.startswith(entry[0]): continue cmd = [ 'git', 'credential-store', '--file', self.git_store[1], 'store' ] proc = subprocess.Popen(cmd, shell=False, encoding="utf-8", stdin=subprocess.PIPE) # hostname username token/password text=f"protocol=https\nhost={entry[1]}\nusername={entry[2]}\npassword={entry[3]}\n" proc.communicate(input=text) if proc.returncode != 0: logging.error("Could not setup git credential store") sys.exit(1) def run_cmd_nonfatal( self, cmd: List[str], *, cwd: Optional[str]=None, stdout: Union[int, TextIO]=subprocess.PIPE, env: Optional[Dict[str, str]]=None, ) -> Tuple[int, str]: logging.debug("COMMAND: %s" % cmd) stderr = subprocess.PIPE if stdout == subprocess.PIPE: stderr = subprocess.STDOUT proc = subprocess.Popen(cmd, shell=False, stdout=stdout, stderr=stderr, cwd=cwd, env=env) std_out = proc.communicate()[0] output = std_out.decode() if std_out else '' logging.debug("RESULT(%d): %s", proc.returncode, repr(output)) return (proc.returncode, output) def run_cmd( self, cmd: List[str], *, fatal: str, cwd: Optional[str]=None, stdout: Union[int, TextIO]=subprocess.PIPE, env: Optional[Dict[str, str]]=None, ) -> str: returncode, output = self.run_cmd_nonfatal(cmd, cwd=cwd, stdout=stdout, env=env) if returncode != 0: print("ERROR: " + fatal + " failed: ", output) transient_error = False for name in self.critical_git_servers: if output.find("Failed to connect to " + name) >= 0: transient_error = True if output.find("unable to access") >= 0 and output.find(name) >= 0: transient_error = True if transient_error: print("TRANSIENT ERROR: " + fatal + " failed") sys.exit(returncode) return output def do_clone_commit(self, outdir: str, include_submodules: bool=False) -> None: assert self.revision, "no revision is set but do_clone_commit was called" objectformat='--object-format=sha1' if len(self.revision) == 64: objectformat='--object-format=sha256' cmd = [ 'git', 'init', objectformat, outdir ] self.run_cmd(cmd, fatal="git init") cmd = [ 'git', '-C', outdir, 'remote', 'add', 'origin', self.scmtoolurl ] self.run_cmd(cmd, fatal="git remote add origin") cmd = [ 'git', '-C', outdir, 'fetch', 'origin', self.revision ] if shallow_clone: cmd += [ '--depth', '1' ] if include_submodules: # try to select specific submodule first when a subdir is given and fall back if self.subdir is None or self.run_cmd_nonfatal(cmd + [ "--recurse-submodules=" + self.subdir ])[0] != 0: cmd += [ '--recurse-submodules' ] self.run_cmd(cmd, fatal="git fetch") else: self.run_cmd(cmd, fatal="git fetch") cmd = [ 'git', '-C', outdir, 'checkout', '-q', self.revision ] env = {"GIT_LFS_SKIP_SMUDGE": "1", **os.environ} if self.no_lfs else None self.run_cmd(cmd, fatal="git checkout", env=env) if include_submodules: cmd = [ 'git', '-C', outdir, 'submodule', 'init' ] self.run_cmd(cmd, fatal="git submodule init") cmd = [ 'git', '-C', outdir, 'submodule', 'update' ] self.run_cmd(cmd, fatal="git submodule update") def do_clone(self, outdir: str, include_submodules: bool=False) -> None: if self.revision and re.match(r"^[0-9a-fA-F]{40,}$", self.revision): self.do_clone_commit(outdir, include_submodules=include_submodules) return cmd = [ 'git', 'clone', self.scmtoolurl, outdir ] if include_submodules: if self.subdir: cmd += [ "--recurse-submodules=" + self.subdir ] else: cmd += [ '--recurse-submodules' ] if shallow_clone: cmd += [ '--depth', '1' ] if self.revision: cmd.insert(2, '-b') cmd.insert(3, self.revision) env = {"GIT_LFS_SKIP_SMUDGE": "1", **os.environ} if self.no_lfs else None self.run_cmd(cmd, fatal="git clone", env=env) # the _scmsync.obsinfo file might become obsolete again when we store entire # git history by default later. def write_obsinfo(self, outdir: str) -> None: if not create_obsinfo: # we write it only when importing data into the source server return cmd = [ 'git', 'rev-parse', 'HEAD' ] line = self.run_cmd(cmd, cwd=outdir, fatal="git rev-parse") commit = line.rstrip() cmd = [ 'git', 'log', '-n1', '--date=format:%Y%m%d', '--no-show-signature', '--pretty=format:%ct' ] line = self.run_cmd(cmd, cwd=outdir, fatal="git rev-parse") tstamp = line.rstrip() infofile = os.path.join(outdir, '_scmsync.obsinfo') if os.path.exists(infofile): logging.error("ERROR: The _scmsync.obsinfo file must not be part of the git repository.") sys.exit(1) with open(infofile, 'x') as obsinfo: obsinfo.write("mtime: " + tstamp + "\n") obsinfo.write("commit: " + commit + "\n") if self.scmtoolurl: obsinfo.write("url: " + self.scmtoolurl + "\n") if self.revision: obsinfo.write("revision: " + self.revision + "\n") if self.subdir: obsinfo.write("subdir: " + self.subdir + "\n") if self.projectscmsync: obsinfo.write("projectscmsync: " + self.projectscmsync + "\n") def clone(self, include_submodules: bool=False) -> None: if not self.subdir: self.do_clone(self.outdir, include_submodules=include_submodules) self.write_obsinfo(self.outdir) return clonedir = tempfile.mkdtemp(prefix="obs-scm-bridge") self.do_clone(clonedir, include_submodules=include_submodules) fromdir = os.path.join(clonedir, self.subdir) if os.path.islink(fromdir): target = os.readlink(fromdir).rstrip('/') # this is no recursive lookup, but is there a usecase? if '/' in target: print("ERROR: only local links are supported: " + self.subdir) sys.exit(1) # switch subdir and clone again self.subdir=target shutil.rmtree(clonedir) clonedir = tempfile.mkdtemp(prefix="obs-scm-bridge") fromdir = os.path.join(clonedir, self.subdir) self.do_clone(clonedir, include_submodules=include_submodules) self.write_obsinfo(clonedir) if not os.path.realpath(fromdir+'/').startswith(os.path.realpath(clonedir+'/')): print("ERROR: subdir is not below clone directory") sys.exit(1) if not os.path.isdir(fromdir): print("ERROR: subdir " + self.subdir + " does not exist") sys.exit(1) if not os.path.isdir(self.outdir): os.makedirs(self.outdir) for name in os.listdir(fromdir): shutil.move(os.path.join(fromdir, name), self.outdir) shutil.rmtree(clonedir) def fetch_tags(self) -> None: cmd = [ 'git', '-C', self.outdir, 'fetch', '--tags', 'origin', '+refs/heads/*:refs/remotes/origin/*' ] logging.info("fetching all tags") self.run_cmd(cmd, fatal="fetch --tags") def cpio_directory(self, directory: str) -> None: logging.info("create archivefile for %s", directory) cmd = [ download_assets, '--create-cpio', '--', directory ] with open(directory + '.obscpio', 'x') as archivefile: self.run_cmd(cmd, stdout=archivefile, fatal="cpio creation") def cpio_specials(self, specials: List[str]) -> None: if not specials: return logging.info("create archivefile for specials") cmd = [ download_assets, '--create-cpio', '--', '.' ] + specials with open('build.specials.obscpio', 'x') as archivefile: self.run_cmd(cmd, stdout=archivefile, fatal="cpio creation") def cpio_directories(self) -> None: logging.debug("walk via %s", self.outdir) os.chdir(self.outdir) listing = sorted(os.listdir(".")) specials = [] for name in listing: if name in ('.git', '.gitattributes') and not self.keep_meta: # we do not store git meta data by default to avoid bloat storage continue if name[0:1] == '.': specials.append(name) continue if os.path.islink(name): specials.append(name) continue if os.path.isdir(name): logging.info("CPIO %s ", name) self.cpio_directory(name) shutil.rmtree(name) if specials: self.cpio_specials(specials) for name in specials: if os.path.isdir(name): shutil.rmtree(name) else: os.unlink(name) def get_assets(self) -> None: logging.info("downloading assets") cmd = [ download_assets ] for arch in self.arch: cmd += [ '--arch', arch ] if pack_directories: cmd += [ '--noassetdir', '--', self.outdir ] else: cmd += [ '--unpack', '--noassetdir', '--', self.outdir ] self.run_cmd(cmd, fatal="asset download") def copyfile(self, src: str, dst: str) -> None: shutil.copy2(os.path.join(self.outdir, src), os.path.join(self.outdir, dst)) def export_debian_files(self) -> None: if os.path.isfile(self.outdir + "/debian/control") and \ not os.path.isfile(self.outdir + "/debian.control"): self.copyfile("debian/control", "debian.control") if os.path.isfile(self.outdir + "/debian/changelog") and \ not os.path.isfile(self.outdir + "/debian.changelog"): self.copyfile("debian/changelog", "debian.changelog") def get_debian_origtar(self) -> None: if os.path.isfile(self.outdir + "/debian/control"): # need up get all tags if not self.subdir: self.fetch_tags() cmd = [ export_debian_orig_from_git, self.outdir ] logging.info("exporting debian origtar") self.run_cmd(cmd, fatal="debian origtar export") def get_subdir_info(self, dir: str) -> str: cmd = [ download_assets, '--show-dir-srcmd5', '--', dir ] info = self.run_cmd(cmd, fatal="download_assets --show-dir-srcmd5") return info.strip() def write_info_file(self, filename: str, info: str) -> None: if not filename.startswith("/"): filename = self.outdir + "/" + filename if os.path.exists(filename): logging.error(f"ERROR: The {filename} file must not be part of the git repository.") sys.exit(1) with open(filename, 'x') as infofile: infofile.write(info + '\n') def add_service_info(self) -> None: info = None if self.subdir: info = self.get_subdir_info(self.outdir) else: cmd = [ 'git', '-C', self.outdir, 'show', '-s', '--pretty=format:%H', 'HEAD' ] info = self.run_cmd(cmd, fatal="git show -s HEAD") info = info.strip() if info: self.write_info_file(os.path.join(self.outdir, "_service_info"), info) def write_package_xml_file(self, name: str, url: str, projectscmsync: str=None) -> None: projecturlxml='' if self.onlybuild and not name in self.onlybuild.keys(): return if projectscmsync: projecturlxml=f"""\n <url>{escape(projectscmsync)}</url>""" filename = f"{self.outdir}/{name}.xml" if os.path.exists(filename): logging.error(f"ERROR: The {name}.xml file must not be part of the git repository.") sys.exit(1) with open(filename, 'x') as xmlfile: xmlfile.write(f"""<package name="{escape(name)}">""") if self.enforce_bcntsynctag: xmlfile.write(f"""<bcntsynctag>{escape(name)}</bcntsynctag>{projecturlxml}""") xmlfile.write(f"""<scmsync>{escape(url)}</scmsync> </package>\n""") def write_package_xml_local_link(self, target: str, name: str) -> None: filename = f"{self.outdir}/{name}.xml" if os.path.exists(filename): logging.error(f"ERROR: The {name}.xml file must not be part of the git repository.") sys.exit(1) with open(filename, 'x') as xmlfile: xmlfile.write(f"""<package name="{escape(name)}">""") if self.enforce_bcntsynctag: xmlfile.write(f"""<bcntsynctag>{escape(name)}</bcntsynctag>{projecturlxml}""") xmlfile.write(f"""</package>""") self.export_files.add(name + ".xml") filename = f"{self.outdir}/{name}.link" if os.path.exists(filename): logging.error(f"ERROR: The {name}.link file must not be part of the git repository.") sys.exit(1) with open(filename, 'x') as linkfile: linkfile.write(f"""<link package="{escape(target)}" cicount="copy" />""") self.export_files.add(name + ".link") def list_submodule_revisions(self) -> None: self.revisions = {} cmd = [ 'git', 'ls-tree', 'HEAD', '.' ] output = self.run_cmd(cmd, fatal="git ls-tree") for line in output.splitlines(): lstree = line.split(maxsplit=4) if lstree[1] == 'commit' and len(lstree[2]) >= 40: self.revisions[lstree[3]] = lstree[2] def process_package_submodule(self, gsmsection: configparser.SectionProxy, package_name: Optional[str]=None) -> None: path = gsmsection['path'] urlstr = gsmsection['url'] if not package_name: package_name = path if package_name in self.processed: return if '/' in path: # we handle only top level submodules in project mode return # find revision of submodule if not self.revisions: self.list_submodule_revisions() assert self.revisions, "self.revisions must not be None after calling self.list_submodule_revisions" revision = self.revisions.get(path, None) if not revision: logging.error("Could not determine revision of submodule for " + path) sys.exit(1) # all good, write xml file and register the module self.gitsubmodules.add(path) url = list(urllib.parse.urlparse(urlstr)) url[5] = revision if self.arch: query = urllib.parse.parse_qs(url[4]); query['arch'] = self.arch url[4] = urllib.parse.urlencode(query) # handle relative urls in submodules unparsed_url = urllib.parse.urlunparse(url) if ".." == unparsed_url[0:2]: # need to append a '/' to the base url so that the relative # path is properly resolved, otherwise we might descend one # directory too far unparsed_url = urllib.parse.urljoin(self.scmtoolurl+'/', unparsed_url) if self.url[0][0:4] == 'git+': unparsed_url = 'git+' + unparsed_url projecturl = self.url.copy() # replace the fragment with the checked out commit id cmd = [ 'git', 'rev-parse', 'HEAD' ] line = self.run_cmd(cmd, cwd=self.outdir, fatal="git rev-parse") projecturl[5] = line.rstrip() projectscmsync = urllib.parse.urlunparse(projecturl) self.processed[package_name] = True self.write_package_xml_file(package_name, unparsed_url, projectscmsync) self.write_info_file(package_name + ".info", revision) self.export_files.add(package_name + ".xml") self.export_files.add(package_name + ".info") def process_package_subdirectory(self, directory: str, subdir: str) -> None: info = self.get_subdir_info(subdir + directory) shutil.rmtree(subdir + directory) if not self._REGEXP.match(directory): logging.warn("directory name contains invalid char: %s", directory) return # add subdir info file self.write_info_file(directory + ".info", info) self.export_files.add(directory + ".info") # add subdir parameter to url url = self.url.copy() query = urllib.parse.parse_qs(url[4]) query['subdir'] = subdir + directory url[4] = urllib.parse.urlencode(query) if self.revision: url[5] = self.revision self.write_package_xml_file(directory, urllib.parse.urlunparse(url)) self.export_files.add(directory + ".xml") def generate_package_xml_files(self) -> None: self.generate_package_xml_files_of_directory(self.outdir) def generate_package_xml_files_of_directory(self, directory) -> None: logging.debug("check %s", directory) subdir_yml = None if os.path.isfile(directory + '/_subdirs'): with open(directory + '/_subdirs') as stream: subdir_yml = yaml.safe_load(stream) for subdir in subdir_yml['subdirs']: self.generate_package_xml_files_of_directory(directory + '/' + subdir) if not 'toplevel' in subdir_yml or subdir_yml['toplevel'] != 'include': return subdir = directory.removeprefix(self.outdir).lstrip("/") if len(subdir) > 0: subdir = subdir + '/' os.chdir(self.outdir) # find all top level git submodules gsmconfig = None if os.path.isfile('.gitmodules'): gsmconfig = configparser.ConfigParser() gsmconfig.read('.gitmodules') for section in gsmconfig.sections(): if not 'path' in gsmconfig[section]: logging.warn("path not defined for git submodule " + section) continue if not 'url' in gsmconfig[section]: logging.warn("url not defined for git submodule " + section) continue self.process_package_submodule(gsmconfig[section]) # handle plain files and directories logging.debug("walk via %s", directory) listing = sorted(os.listdir(directory)) for name in listing: fname = subdir + name if os.path.islink(fname): if name in self.processed: os.unlink(fname) continue target = os.readlink(fname).rstrip('/') # this is no recursive lookup, but is there a usecase? if '/' in target: logging.warn("only local links are supported, skipping: " + name) continue if target in self.gitsubmodules or os.path.isdir(target): self.write_package_xml_local_link(target, name) self.processed[name] = True os.unlink(name) else: logging.debug("skipping symlink to a non git submodule %s -> %s", name, target) os.unlink(name) continue if name == '.git' and not self.keep_meta: shutil.rmtree(fname) continue if os.path.islink(fname): continue elif os.path.isdir(fname): if name in self.gitsubmodules: # already handled as git submodule shutil.rmtree(name) continue if name in self.processed: continue if subdir_yml and name in subdir_yml['subdirs']: shutil.rmtree(name) continue self.process_package_subdirectory(name, subdir) self.processed[name] = True else: if not name in self.export_files: os.unlink(name) if __name__ == '__main__': parser = argparse.ArgumentParser( description='Open Build Service source service for managing packaging files in git.' 'This is a special service for OBS git integration.') parser.add_argument('--outdir', required=True, help='output directory for modified sources', nargs=1, type=str) parser.add_argument('--url', help='REQUIRED: url to git repository', required=True, nargs=1, type=str) parser.add_argument('--projectmode', help='just return the package list based on the subdirectories') parser.add_argument('--projectscmsync', help='add also reference information of a project git for a package clone') parser.add_argument('--debug', help='verbose debug mode') args = vars(parser.parse_args()) url = args['url'][0] outdir = args['outdir'][0] project_mode = args['projectmode'] projectscmsync = args['projectscmsync'] if args['debug']: logging.getLogger().setLevel(logging.DEBUG) logging.debug("Running in debug mode") # workflow obsgit = ObsGit(outdir, url, projectscmsync) obsgit.add_critical_instance("src.opensuse.org") if os.path.isfile(critical_instances_config): with open(critical_instances_config) as conf: for line in conf.readlines(): obsgit.add_critical_instance(line.rstrip()) if os.path.isfile(credentials_config): obsgit.setup_credentials(credentials_config) if project_mode == 'true' or project_mode == '1': obsgit.clone() obsgit.generate_package_xml_files() sys.exit(0) obsgit.clone(include_submodules=True) if pack_directories: obsgit.add_service_info() if get_assets: obsgit.get_assets() obsgit.get_debian_origtar() if pack_directories: obsgit.export_debian_files() obsgit.cpio_directories() 07070100000009000081A40000000000000000000000016734C0B50000530B000000000000000000000000000000000000002100000000obs-scm-bridge-0.5.2/poetry.lock# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "atomicwrites" version = "1.4.1" description = "Atomic file writes." optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" files = [ {file = "atomicwrites-1.4.1.tar.gz", hash = "sha256:81b2c9071a49367a7f770170e5eec8cb66567cfbbc8c73d20ce5ca4a8d71cf11"}, ] [[package]] name = "attrs" version = "22.2.0" description = "Classes Without Boilerplate" optional = false python-versions = ">=3.6" files = [ {file = "attrs-22.2.0-py3-none-any.whl", hash = "sha256:29e95c7f6778868dbd49170f98f8818f78f3dc5e0e37c0b1f474e3561b240836"}, {file = "attrs-22.2.0.tar.gz", hash = "sha256:c9227bfc2f01993c03f68db37d1d15c9690188323c067c641f1a35ca58185f99"}, ] [package.extras] cov = ["attrs[tests]", "coverage-enable-subprocess", "coverage[toml] (>=5.3)"] dev = ["attrs[docs,tests]"] docs = ["furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier", "zope.interface"] tests = ["attrs[tests-no-zope]", "zope.interface"] tests-no-zope = ["cloudpickle", "cloudpickle", "hypothesis", "hypothesis", "mypy (>=0.971,<0.990)", "mypy (>=0.971,<0.990)", "pympler", "pympler", "pytest (>=4.3.0)", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-mypy-plugins", "pytest-xdist[psutil]", "pytest-xdist[psutil]"] [[package]] name = "cached-property" version = "1.5.2" description = "A decorator for caching properties in classes." optional = false python-versions = "*" files = [ {file = "cached-property-1.5.2.tar.gz", hash = "sha256:9fa5755838eecbb2d234c3aa390bd80fbd3ac6b6869109bfc1b499f7bd89a130"}, {file = "cached_property-1.5.2-py2.py3-none-any.whl", hash = "sha256:df4f613cf7ad9a588cc381aaf4a512d26265ecebd5eb9e1ba12f1319eb85a6a0"}, ] [[package]] name = "colorama" version = "0.4.5" description = "Cross-platform colored terminal text." optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" files = [ {file = "colorama-0.4.5-py2.py3-none-any.whl", hash = "sha256:854bf444933e37f5824ae7bfc1e98d5bce2ebe4160d46b5edf346a89358e99da"}, {file = "colorama-0.4.5.tar.gz", hash = "sha256:e6c6b4334fc50988a639d9b98aa429a0b57da6e17b9a44f0451f930b6967b7a4"}, ] [[package]] name = "dataclasses" version = "0.8" description = "A backport of the dataclasses module for Python 3.6" optional = false python-versions = ">=3.6, <3.7" files = [ {file = "dataclasses-0.8-py3-none-any.whl", hash = "sha256:0201d89fa866f68c8ebd9d08ee6ff50c0b255f8ec63a71c16fda7af82bb887bf"}, {file = "dataclasses-0.8.tar.gz", hash = "sha256:8479067f342acf957dc82ec415d355ab5edb7e7646b90dc6e2fd1d96ad084c97"}, ] [[package]] name = "deprecation" version = "2.1.0" description = "A library to handle automated deprecations" optional = false python-versions = "*" files = [ {file = "deprecation-2.1.0-py2.py3-none-any.whl", hash = "sha256:a10811591210e1fb0e768a8c25517cabeabcba6f0bf96564f8ff45189f90b14a"}, {file = "deprecation-2.1.0.tar.gz", hash = "sha256:72b3bde64e5d778694b0cf68178aed03d15e15477116add3fb773e581f9518ff"}, ] [package.dependencies] packaging = "*" [[package]] name = "execnet" version = "1.9.0" description = "execnet: rapid multi-Python deployment" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" files = [ {file = "execnet-1.9.0-py2.py3-none-any.whl", hash = "sha256:a295f7cc774947aac58dde7fdc85f4aa00c42adf5d8f5468fc630c1acf30a142"}, {file = "execnet-1.9.0.tar.gz", hash = "sha256:8f694f3ba9cc92cab508b152dcfe322153975c29bda272e2fd7f3f00f36e47c5"}, ] [package.extras] testing = ["pre-commit"] [[package]] name = "filelock" version = "3.4.1" description = "A platform independent file lock." optional = false python-versions = ">=3.6" files = [ {file = "filelock-3.4.1-py3-none-any.whl", hash = "sha256:a4bc51381e01502a30e9f06dd4fa19a1712eab852b6fb0f84fd7cce0793d8ca3"}, {file = "filelock-3.4.1.tar.gz", hash = "sha256:0f12f552b42b5bf60dba233710bf71337d35494fc8bdd4fd6d9f6d082ad45e06"}, ] [package.extras] docs = ["furo (>=2021.8.17b43)", "sphinx (>=4.1)", "sphinx-autodoc-typehints (>=1.12)"] testing = ["covdefaults (>=1.2.0)", "coverage (>=4)", "pytest (>=4)", "pytest-cov", "pytest-timeout (>=1.4.2)"] [[package]] name = "importlib-metadata" version = "4.8.3" description = "Read metadata from Python packages" optional = false python-versions = ">=3.6" files = [ {file = "importlib_metadata-4.8.3-py3-none-any.whl", hash = "sha256:65a9576a5b2d58ca44d133c42a241905cc45e34d2c06fd5ba2bafa221e5d7b5e"}, {file = "importlib_metadata-4.8.3.tar.gz", hash = "sha256:766abffff765960fcc18003801f7044eb6755ffae4521c8e8ce8e83b9c9b0668"}, ] [package.dependencies] typing-extensions = {version = ">=3.6.4", markers = "python_version < \"3.8\""} zipp = ">=0.5" [package.extras] docs = ["jaraco.packaging (>=8.2)", "rst.linker (>=1.9)", "sphinx"] perf = ["ipython"] testing = ["flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pep517", "pyfakefs", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.0.1)", "pytest-flake8", "pytest-mypy", "pytest-perf (>=0.9.2)"] [[package]] name = "iniconfig" version = "1.1.1" description = "iniconfig: brain-dead simple config-ini parsing" optional = false python-versions = "*" files = [ {file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"}, {file = "iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"}, ] [[package]] name = "packaging" version = "21.3" description = "Core utilities for Python packages" optional = false python-versions = ">=3.6" files = [ {file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"}, {file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"}, ] [package.dependencies] pyparsing = ">=2.0.2,<3.0.5 || >3.0.5" [[package]] name = "pluggy" version = "1.0.0" description = "plugin and hook calling mechanisms for python" optional = false python-versions = ">=3.6" files = [ {file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"}, {file = "pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"}, ] [package.dependencies] importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} [package.extras] dev = ["pre-commit", "tox"] testing = ["pytest", "pytest-benchmark"] [[package]] name = "py" version = "1.11.0" description = "library with cross-python path, ini-parsing, io, code, log facilities" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" files = [ {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, ] [[package]] name = "pyparsing" version = "3.0.7" description = "Python parsing module" optional = false python-versions = ">=3.6" files = [ {file = "pyparsing-3.0.7-py3-none-any.whl", hash = "sha256:a6c06a88f252e6c322f65faf8f418b16213b51bdfaece0524c1c1bc30c63c484"}, {file = "pyparsing-3.0.7.tar.gz", hash = "sha256:18ee9022775d270c55187733956460083db60b37d0d0fb357445f3094eed3eea"}, ] [package.extras] diagrams = ["jinja2", "railroad-diagrams"] [[package]] name = "pytest" version = "7.0.1" description = "pytest: simple powerful testing with Python" optional = false python-versions = ">=3.6" files = [ {file = "pytest-7.0.1-py3-none-any.whl", hash = "sha256:9ce3ff477af913ecf6321fe337b93a2c0dcf2a0a1439c43f5452112c1e4280db"}, {file = "pytest-7.0.1.tar.gz", hash = "sha256:e30905a0c131d3d94b89624a1cc5afec3e0ba2fbdb151867d8e0ebd49850f171"}, ] [package.dependencies] atomicwrites = {version = ">=1.0", markers = "sys_platform == \"win32\""} attrs = ">=19.2.0" colorama = {version = "*", markers = "sys_platform == \"win32\""} importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} iniconfig = "*" packaging = "*" pluggy = ">=0.12,<2.0" py = ">=1.8.2" tomli = ">=1.0.0" [package.extras] testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"] [[package]] name = "pytest-container" version = "0.4.2" description = "Pytest fixtures for writing container based tests" optional = false python-versions = ">=3.6.2,<4.0" files = [] develop = false [package.dependencies] cached-property = {version = "^1.5", markers = "python_version < \"3.8\""} dataclasses = {version = ">=0.8", markers = "python_version < \"3.7\""} deprecation = "^2.1" filelock = "^3.4" pytest = ">= 3.10" pytest-testinfra = [ {version = ">=6.4.0", markers = "python_version < \"3.7\""}, {version = ">=7.0", markers = "python_version >= \"3.7\" and python_version < \"3.8\""}, {version = ">=8.0", markers = "python_version >= \"3.8\""}, ] typing-extensions = {version = ">=3.0", markers = "python_version < \"3.8\""} [package.source] type = "git" url = "https://github.com/dcermak/pytest_container.git" reference = "main" resolved_reference = "54738a5098f4db43da54fd7102b58761167f8aad" [[package]] name = "pytest-testinfra" version = "6.8.0" description = "Test infrastructures" optional = false python-versions = ">=3.6" files = [ {file = "pytest-testinfra-6.8.0.tar.gz", hash = "sha256:07c8c2c472aca7d83099ebc5f850d383721cd654b66c60ffbb145e45e584ff99"}, {file = "pytest_testinfra-6.8.0-py3-none-any.whl", hash = "sha256:56ac1dfc61342632a1189091473e253db1a3cdcecce0d49d6a769f33cd264814"}, ] [package.dependencies] pytest = "!=3.0.2" [package.extras] ansible = ["ansible"] paramiko = ["paramiko"] salt = ["salt"] winrm = ["pywinrm"] [[package]] name = "pytest-testinfra" version = "7.0.0" description = "Test infrastructures" optional = false python-versions = ">=3.7" files = [ {file = "pytest-testinfra-7.0.0.tar.gz", hash = "sha256:38c2ce2df4e25f685636c7db9ac15083a7cf3e4a8a997d5fa654e8a7bedeadce"}, {file = "pytest_testinfra-7.0.0-py3-none-any.whl", hash = "sha256:0b28076d7088fb0c8e868119639f1259f95dd0e735ae8045ead34433ce8cbc98"}, ] [package.dependencies] pytest = "!=3.0.2" [package.extras] ansible = ["ansible"] paramiko = ["paramiko"] salt = ["salt"] winrm = ["pywinrm"] [[package]] name = "pytest-testinfra" version = "8.1.0" description = "Test infrastructures" optional = false python-versions = ">=3.8" files = [ {file = "pytest-testinfra-8.1.0.tar.gz", hash = "sha256:9b40828b58fb7ac2bff29cc1465934adf434f10dd5a108f60535dee52660a63d"}, {file = "pytest_testinfra-8.1.0-py3-none-any.whl", hash = "sha256:bf7df6306244da6a832f977766e75408317315aa1452c41c30e2541ef7978007"}, ] [package.dependencies] pytest = "!=3.0.2" [package.extras] ansible = ["ansible"] paramiko = ["paramiko"] salt = ["salt"] winrm = ["pywinrm"] [[package]] name = "pytest-xdist" version = "3.0.2" description = "pytest xdist plugin for distributed testing and loop-on-failing modes" optional = false python-versions = ">=3.6" files = [ {file = "pytest-xdist-3.0.2.tar.gz", hash = "sha256:688da9b814370e891ba5de650c9327d1a9d861721a524eb917e620eec3e90291"}, {file = "pytest_xdist-3.0.2-py3-none-any.whl", hash = "sha256:9feb9a18e1790696ea23e1434fa73b325ed4998b0e9fcb221f16fd1945e6df1b"}, ] [package.dependencies] execnet = ">=1.1" pytest = ">=6.2.0" [package.extras] psutil = ["psutil (>=3.0)"] setproctitle = ["setproctitle"] testing = ["filelock"] [[package]] name = "pyyaml" version = "6.0.1" description = "YAML parser and emitter for Python" optional = false python-versions = ">=3.6" files = [ {file = "PyYAML-6.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d858aa552c999bc8a8d57426ed01e40bef403cd8ccdd0fc5f6f04a00414cac2a"}, {file = "PyYAML-6.0.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:fd66fc5d0da6d9815ba2cebeb4205f95818ff4b79c3ebe268e75d961704af52f"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515"}, {file = "PyYAML-6.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:326c013efe8048858a6d312ddd31d56e468118ad4cdeda36c719bf5bb6192290"}, {file = "PyYAML-6.0.1-cp310-cp310-win32.whl", hash = "sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924"}, {file = "PyYAML-6.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d"}, {file = "PyYAML-6.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007"}, {file = "PyYAML-6.0.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f003ed9ad21d6a4713f0a9b5a7a0a79e08dd0f221aff4525a2be4c346ee60aab"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673"}, {file = "PyYAML-6.0.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e7d73685e87afe9f3b36c799222440d6cf362062f78be1013661b00c5c6f678b"}, {file = "PyYAML-6.0.1-cp311-cp311-win32.whl", hash = "sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741"}, {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, {file = "PyYAML-6.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:0d3304d8c0adc42be59c5f8a4d9e3d7379e6955ad754aa9d6ab7a398b59dd1df"}, {file = "PyYAML-6.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47"}, {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98"}, {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c"}, {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:afd7e57eddb1a54f0f1a974bc4391af8bcce0b444685d936840f125cf046d5bd"}, {file = "PyYAML-6.0.1-cp36-cp36m-win32.whl", hash = "sha256:fca0e3a251908a499833aa292323f32437106001d436eca0e6e7833256674585"}, {file = "PyYAML-6.0.1-cp36-cp36m-win_amd64.whl", hash = "sha256:f22ac1c3cac4dbc50079e965eba2c1058622631e526bd9afd45fedd49ba781fa"}, {file = "PyYAML-6.0.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:b1275ad35a5d18c62a7220633c913e1b42d44b46ee12554e5fd39c70a243d6a3"}, {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:18aeb1bf9a78867dc38b259769503436b7c72f7a1f1f4c93ff9a17de54319b27"}, {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:596106435fa6ad000c2991a98fa58eeb8656ef2325d7e158344fb33864ed87e3"}, {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:baa90d3f661d43131ca170712d903e6295d1f7a0f595074f151c0aed377c9b9c"}, {file = "PyYAML-6.0.1-cp37-cp37m-win32.whl", hash = "sha256:9046c58c4395dff28dd494285c82ba00b546adfc7ef001486fbf0324bc174fba"}, {file = "PyYAML-6.0.1-cp37-cp37m-win_amd64.whl", hash = "sha256:4fb147e7a67ef577a588a0e2c17b6db51dda102c71de36f8549b6816a96e1867"}, {file = "PyYAML-6.0.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:1d4c7e777c441b20e32f52bd377e0c409713e8bb1386e1099c2415f26e479595"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735"}, {file = "PyYAML-6.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:49a183be227561de579b4a36efbb21b3eab9651dd81b1858589f796549873dd6"}, {file = "PyYAML-6.0.1-cp38-cp38-win32.whl", hash = "sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206"}, {file = "PyYAML-6.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62"}, {file = "PyYAML-6.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8"}, {file = "PyYAML-6.0.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:c8098ddcc2a85b61647b2590f825f3db38891662cfc2fc776415143f599bb859"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c"}, {file = "PyYAML-6.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:04ac92ad1925b2cff1db0cfebffb6ffc43457495c9b3c39d3fcae417d7125dc5"}, {file = "PyYAML-6.0.1-cp39-cp39-win32.whl", hash = "sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c"}, {file = "PyYAML-6.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486"}, {file = "PyYAML-6.0.1.tar.gz", hash = "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"}, ] [[package]] name = "tomli" version = "1.2.3" description = "A lil' TOML parser" optional = false python-versions = ">=3.6" files = [ {file = "tomli-1.2.3-py3-none-any.whl", hash = "sha256:e3069e4be3ead9668e21cb9b074cd948f7b3113fd9c8bba083f48247aab8b11c"}, {file = "tomli-1.2.3.tar.gz", hash = "sha256:05b6166bff487dc068d322585c7ea4ef78deed501cc124060e0f238e89a9231f"}, ] [[package]] name = "typing-extensions" version = "4.1.1" description = "Backported and Experimental Type Hints for Python 3.6+" optional = false python-versions = ">=3.6" files = [ {file = "typing_extensions-4.1.1-py3-none-any.whl", hash = "sha256:21c85e0fe4b9a155d0799430b0ad741cdce7e359660ccbd8b530613e8df88ce2"}, {file = "typing_extensions-4.1.1.tar.gz", hash = "sha256:1a9462dcc3347a79b1f1c0271fbe79e844580bb598bafa1ed208b94da3cdcd42"}, ] [[package]] name = "zipp" version = "3.6.0" description = "Backport of pathlib-compatible object wrapper for zip files" optional = false python-versions = ">=3.6" files = [ {file = "zipp-3.6.0-py3-none-any.whl", hash = "sha256:9fe5ea21568a0a70e50f273397638d39b03353731e6cbbb3fd8502a33fec40bc"}, {file = "zipp-3.6.0.tar.gz", hash = "sha256:71c644c5369f4a6e07636f0aa966270449561fcea2e3d6747b8d23efaa9d7832"}, ] [package.extras] docs = ["jaraco.packaging (>=8.2)", "rst.linker (>=1.9)", "sphinx"] testing = ["func-timeout", "jaraco.itertools", "pytest (>=4.6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.0.1)", "pytest-flake8", "pytest-mypy"] [metadata] lock-version = "2.0" python-versions = ">=3.6.2,<4.0" content-hash = "cd22d3efa3e332c8e38fe0c4f2a42edc2975e3cdefb2ea69a0567cf722bbd71a" 0707010000000A000081A40000000000000000000000016734C0B500000270000000000000000000000000000000000000002400000000obs-scm-bridge-0.5.2/pyproject.toml[tool.poetry] name = "obs-scm-bridge" version = "0.2.1" description = "A helper service to work with git repositories in OBS" authors = ["Adrian Schröter <adrian@suse.de>", "Michael Schroeder <mls@suse.de>"] license = "GPL-2.0-or-later" readme = "README.md" packages = [{include = "obs_scm_bridge"}] [tool.poetry.dependencies] python = ">=3.6.2,<4.0" pyyaml = ">=6.0.0" [tool.poetry.group.dev.dependencies] pytest-container = { git = "https://github.com/dcermak/pytest_container.git", branch = "main" } pytest-xdist = ">=3.0" [build-system] requires = ["poetry-core", "pyyaml"] build-backend = "poetry.core.masonry.api" 0707010000000B000041ED0000000000000000000000026734C0B500000000000000000000000000000000000000000000001A00000000obs-scm-bridge-0.5.2/test0707010000000C000081A40000000000000000000000016734C0B500000000000000000000000000000000000000000000002600000000obs-scm-bridge-0.5.2/test/__init__.py0707010000000D000081A40000000000000000000000016734C0B500000201000000000000000000000000000000000000002600000000obs-scm-bridge-0.5.2/test/conftest.pyfrom pytest_container import add_extra_run_and_build_args_options from pytest_container import add_logging_level_options from pytest_container import auto_container_parametrize from pytest_container import set_logging_level_from_cli_args def pytest_generate_tests(metafunc): auto_container_parametrize(metafunc) def pytest_addoption(parser): add_extra_run_and_build_args_options(parser) add_logging_level_options(parser) def pytest_configure(config): set_logging_level_from_cli_args(config) 0707010000000E000081A40000000000000000000000016734C0B500001F9A000000000000000000000000000000000000002A00000000obs-scm-bridge-0.5.2/test/test_service.pyfrom itertools import product from typing import Optional import xml.etree.ElementTree as ET import pytest from pytest_container import DerivedContainer from pytest_container.container import ContainerData _RPMS_DIR = "/src/rpms/" _AAA_BASE_URL = "https://github.com/openSUSE/aaa_base" _LIBECONF_URL = "https://github.com/openSUSE/libeconf" CONTAINERFILE = f"""RUN set -eux; \ zypper -n in python311 git-core build diff python311-PyYAML; \ . /etc/os-release && [[ ${{NAME}} = "SLES" ]] || zypper -n in git-lfs; \ for recom in $(rpm -q --recommends build|grep ^perl); do zypper -n in $recom; done RUN git config --global user.name "SUSE Bot" && \ git config --global user.email "noreply@suse.com" && \ git config --global protocol.file.allow always RUN mkdir -p {_RPMS_DIR}ring0 && \ cd {_RPMS_DIR} && git clone {_LIBECONF_URL} && \ cd libeconf && git rev-parse HEAD > /src/libeconf && \ cd {_RPMS_DIR}ring0 && \ git init && git submodule add {_AAA_BASE_URL} && \ git commit -m "add aaa_base" && \ git submodule add ../libeconf && git commit -m "add libeconf" && \ cd aaa_base && git rev-parse HEAD > /src/aaa_base COPY obs_scm_bridge /usr/bin/ RUN sed -i 's,^#!/usr/bin/python3.*,#!/usr/bin/python3.11,' /usr/bin/obs_scm_bridge RUN chmod +x /usr/bin/obs_scm_bridge """ TUMBLEWEED = DerivedContainer( base="registry.opensuse.org/opensuse/tumbleweed", containerfile=CONTAINERFILE ) LEAP_LATEST = DerivedContainer( base="registry.opensuse.org/opensuse/leap:15.5", containerfile=CONTAINERFILE, ) BCI_BASE_LATEST = DerivedContainer( base="registry.suse.com/bci/bci-base:15.5", containerfile=CONTAINERFILE ) CONTAINER_IMAGES = [TUMBLEWEED, LEAP_LATEST, BCI_BASE_LATEST] _OBS_SCM_BRIDGE_CMD = "obs_scm_bridge --debug 1" def test_service_help(auto_container: ContainerData): """This is just a simple smoke test to check whether the script works.""" auto_container.connection.run_expect([0], f"{_OBS_SCM_BRIDGE_CMD} --help") def test_clones_the_repository(auto_container_per_test: ContainerData): """Check that the service clones the manually created repository correctly.""" dest = "/tmp/ring0" auto_container_per_test.connection.run_expect( [0], f"{_OBS_SCM_BRIDGE_CMD} --outdir {dest} --url file://{_RPMS_DIR}ring0" ) auto_container_per_test.connection.run_expect([0], f"diff {dest} {_RPMS_DIR}ring0") @pytest.mark.parametrize("container_per_test", CONTAINER_IMAGES, indirect=True) @pytest.mark.parametrize( "fragment", ( "", "#main", # sha of the 0.3.0 release tag "#9907826c17ca7b650c4040e9c2b45bfef4d9821f", ), ) def test_clones_subdir(container_per_test: ContainerData, fragment: str): dest = "/tmp/scm-bridge/" container_per_test.connection.run_expect( [0], f"{_OBS_SCM_BRIDGE_CMD} --outdir {dest} " f"--url https://github.com/openSUSE/obs-scm-bridge?subdir=test{fragment}", ) def test_creates_packagelist(auto_container_per_test: ContainerData): """Smoke test for the generation of the package list files `$pkg_name.xml` and `$pkg_name.info`: - verify that the destination folder contains all expected `.info` and `.xml` files - check the `scmsync` elements in the `.xml` files - check the HEAD hashes in the `.info` files """ dest = "/tmp/ring0" auto_container_per_test.connection.run_expect( [0], f"{_OBS_SCM_BRIDGE_CMD} --outdir {dest} --url file://{_RPMS_DIR}ring0 --projectmode 1", ) libeconf_hash, aaa_base_hash = ( auto_container_per_test.connection.file( f"/src/{pkg_name}" ).content_string.strip() for pkg_name in ("libeconf", "aaa_base") ) files = auto_container_per_test.connection.file(dest).listdir() assert len(files) == 4 for file_name in ( f"{pkg}.{ext}" for pkg, ext in product(("aaa_base", "libeconf"), ("xml", "info")) ): assert file_name in files def _test_pkg_xml(pkg_name: str, expected_url: str, expected_head_hash: str): conf = ET.fromstring( auto_container_per_test.connection.file( f"{dest}/{pkg_name}.xml" ).content_string ) assert conf.attrib["name"] == pkg_name scm_sync_elements = conf.findall("scmsync") assert len(scm_sync_elements) == 1 and scm_sync_elements[0].text assert f"{expected_url}#{expected_head_hash}" in scm_sync_elements[0].text _test_pkg_xml("aaa_base", _AAA_BASE_URL, aaa_base_hash) _test_pkg_xml("libeconf", f"{_RPMS_DIR}libeconf", libeconf_hash) for pkg_name, pkg_head_hash in ( ("aaa_base", aaa_base_hash), ("libeconf", libeconf_hash), ): assert ( pkg_head_hash == auto_container_per_test.connection.file( f"{dest}/{pkg_name}.info" ).content_string.strip() ) LFS_REPO = "https://src.opensuse.org/pool/trivy.git" @pytest.mark.parametrize("fragment", ["#eab0f16835309c7e772f81d523bb47356f3e14f05de74bfa88eaf59d73712215"]) @pytest.mark.parametrize("query", ["?lfs=1"]) @pytest.mark.parametrize("container_per_test", [TUMBLEWEED, LEAP_LATEST], indirect=True) def test_downloads_lfs(container_per_test: ContainerData, fragment: str, query: str): """Test that the lfs file is automatically downloaded from the lfs server on clone. """ _DEST = "/tmp/lfs-example" container_per_test.connection.run_expect( [0], f"{_OBS_SCM_BRIDGE_CMD} --outdir {_DEST} --url {LFS_REPO}{query}{fragment}" ) tar_archive = container_per_test.connection.file(f"{_DEST}/trivy-0.54.1.tar.zst") assert tar_archive.exists and tar_archive.is_file assert tar_archive.size > 10 * 1024 @pytest.mark.parametrize("fragment", ["#eab0f16835309c7e772f81d523bb47356f3e14f05de74bfa88eaf59d73712215"]) def test_lfs_opt_out(auto_container_per_test: ContainerData, fragment: str): _DEST = "/tmp/lfs-example" auto_container_per_test.connection.run_expect( [0], f"{_OBS_SCM_BRIDGE_CMD} --outdir {_DEST} --url {LFS_REPO}?lfs=0{fragment}" ) tar_archive = auto_container_per_test.connection.file( f"{_DEST}/trivy-0.54.1.tar.zst" ) assert tar_archive.exists and tar_archive.is_file assert tar_archive.size < 1024 assert "version https://git-lfs.github.com/spec" in tar_archive.content_string @pytest.mark.parametrize( "git_repo_url,expected_head", [ (f"{_LIBECONF_URL}{fragment}", commit) for fragment, commit in ( ("", None), ("#master", None), (f"{pref}892dc9b83009c859ecfde218566a242241b95ad7" for pref in ("#", "")), ("#v0.4.5", "c9658f240b5c6d8d85f52f5019e47bc29c88b83f"), ) ], ) def test_clone_commit( auto_container_per_test: ContainerData, git_repo_url: str, expected_head: Optional[str], ): """Check that the service can clone libeconf at certain commits/branches or tags and verify that `HEAD` is at the correct commit. """ _DEST = "/tmp/libeconf" auto_container_per_test.connection.run_expect( [0], f"{_OBS_SCM_BRIDGE_CMD} --outdir {_DEST} --url {git_repo_url}" ) head = auto_container_per_test.connection.run_expect( [0], f"git -C {_DEST} rev-parse HEAD" ).stdout.strip() if expected_head: assert head == expected_head @pytest.mark.parametrize( "env_var,shallow", [("", True), ("OSC_VERSION=1", False)], ) def test_fetch_depth( auto_container_per_test: ContainerData, env_var: str, shallow: bool ): _DEST = "/tmp/libeconf" auto_container_per_test.connection.run_expect( [0], f"{env_var} {_OBS_SCM_BRIDGE_CMD} --outdir {_DEST} --url {_LIBECONF_URL}" ) history_length = len( auto_container_per_test.connection.run_expect( [0], f"git -C {_DEST} log --oneline" ) .stdout.strip() .splitlines() ) if shallow: assert history_length == 1 else: assert history_length > 1 07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!166 blocks
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor