From d61885f3cb4a2fb7a40bb954aecfc8c24d0adfbb Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 07 2019 15:43:13 +0000 Subject: [PATCH 1/8] Drop the run_ci_tests shell script that is no longer used Signed-off-by: Pierre-Yves Chibon --- diff --git a/run_ci_tests.sh b/run_ci_tests.sh deleted file mode 100755 index a8e1fba..0000000 --- a/run_ci_tests.sh +++ /dev/null @@ -1,55 +0,0 @@ -set -x - -echo "Installing Fedora Infra Tags repo" -cat >/etc/yum.repos.d/infra-tags.repo << 'EOF' -[infrastructure-tags] -name=Fedora Infrastructure tag $releasever - $basearch -baseurl=https://kojipkgs.fedoraproject.org/repos-dist/epel$releasever-infra/latest/$basearch/ -enabled=1 -gpgcheck=1 -gpgkey=https://infrastructure.fedoraproject.org/repo/infra/RPM-GPG-KEY-INFRA-TAGS -EOF - - -yum install -y python-virtualenv python34 python34-devel \ - gcc python-cryptography python34-cryptography \ - libgit2 libgit2-devel python-pygit2 \ - redis swig openssl-devel m2crypto \ - python2-fedmsg python34-fedmsg-core fedmsg \ - python-tox python-pip python34-pip \ - parallel zeromq-devel python-Cython \ - repoSpanner repoSpanner-bridge - -sysctl -w fs.file-max=2048 - -set -e - -echo "============== ENVIRONMENT =============" -/usr/bin/env -echo "============== END ENVIRONMENT =============" - -if [ -n "$REPO" -a -n "$BRANCH" ]; then -git remote rm proposed || true -git gc --auto -git remote add proposed "$REPO" -git fetch proposed -git checkout origin/master -git config --global user.email "you@example.com" -git config --global user.name "Your Name" -git merge --no-ff "proposed/$BRANCH" -m "Merge PR" - -echo "Running tests for branch $BRANCH of repo $REPO" -echo "Last commits:" -git log -2 -fi - -# Apparently newer requests has strong feeling about idna: -# https://github.com/requests/requests/commit/991e8b76b7a9d21f698b24fa -# and only in py3 we're having a version that is too old (2.1) -pip3 install --upgrade "idna<2.8" -pip install --upgrade "virtualenv<16.3.0" "tox<3.7.0" trollius coverage -pip install --upgrade --force-reinstall chardet -pip3 install "pygit2 <= `rpm -q libgit2 --queryformat='%{version}'`" -tox --sitepackages -e 'py27-flask011-ci' -- --results=results-py2-flask011 -tox --sitepackages -e 'py34-flask011-ci' -- --results=results-py3-flask011 -tox --sitepackages -e 'py34-flask100-ci' -- --results=results-py3-flask100 From b8a95b02f930eadf2ab9ccb70372c7ab3817cd84 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 08 2019 12:23:42 +0000 Subject: [PATCH 2/8] Respect the SELinux context when mounting the dir in the containers Signed-off-by: Pierre-Yves Chibon --- diff --git a/dev/run-tests-container.py b/dev/run-tests-container.py index 73fe99a..14dd8b3 100644 --- a/dev/run-tests-container.py +++ b/dev/run-tests-container.py @@ -82,7 +82,7 @@ if __name__ == "__main__": "--name", container_name, "-v", - "{}/results_{}:/pagure/results".format( + "{}/results_{}:/pagure/results:z".format( os.getcwd(), container_files[idx]), "-e", "BRANCH=$BRANCH", @@ -103,7 +103,7 @@ if __name__ == "__main__": "--name", container_name, "-v", - "{}/results_{}:/pagure/results".format( + "{}/results_{}:/pagure/results:z".format( os.getcwd(), container_files[idx]), "-e", "BRANCH={}".format(os.environ.get("BRANCH") or ""), diff --git a/run_ci_tests_containers.sh b/run_ci_tests_containers.sh index 38e3d14..fe11956 100644 --- a/run_ci_tests_containers.sh +++ b/run_ci_tests_containers.sh @@ -17,7 +17,7 @@ if [ ! -d `pwd`/results_f29-rpms-py3 ]; then fi podman run --rm -it --name pagure-f29-rpms-py3 \ - -v `pwd`/results_f29-rpms-py3:/pagure/results \ + -v `pwd`/results_f29-rpms-py3:/pagure/results:z \ -e BRANCH=$BRANCH \ -e REPO=$REPO \ pagure-f29-rpms-py3 @@ -32,7 +32,7 @@ if [ ! -d `pwd`/results_centos7-rpms-py2 ]; then fi podman run --rm -it --name pagure-c7-rpms-py2 \ - -v `pwd`/results_centos7-rpms-py2:/pagure/results \ + -v `pwd`/results_centos7-rpms-py2:/pagure/results:z \ -e BRANCH=$BRANCH \ -e REPO=$REPO \ pagure-c7-rpms-py2 From 29ff0af3cc6797c1e7193a4cfbca725de9790a37 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 08 2019 12:23:42 +0000 Subject: [PATCH 3/8] Replace calls to .get_object() by calls to .peel() Apparently pygit2 dropped support for .get_object() in its release 0.27.4. The .peel() method was introduced in 0.21.4 according to their changelog so it should be safe for use to just replace one by the other everywhere without needing some magic to use one or the other depending on the version. Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/internal/__init__.py b/pagure/internal/__init__.py index 5d9c6f4..9d02860 100644 --- a/pagure/internal/__init__.py +++ b/pagure/internal/__init__.py @@ -550,13 +550,13 @@ def get_branches_of_commit(): if compare_branch: merge_commit_obj = repo_obj.merge_base( - compare_branch.get_object().hex, branch.get_object().hex + compare_branch.peel().hex, branch.peel().hex ) if merge_commit_obj: merge_commit = merge_commit_obj.hex - repo_commit = repo_obj[branch.get_object().hex] + repo_commit = repo_obj[branch.peel().hex] for commit in repo_obj.walk( repo_commit.oid.hex, pygit2.GIT_SORT_NONE @@ -634,7 +634,7 @@ def get_branches_head(): if not repo_obj.is_empty and len(repo_obj.listall_branches()) > 1: for branchname in repo_obj.listall_branches(): branch = repo_obj.lookup_branch(branchname) - branches[branchname] = branch.get_object().hex + branches[branchname] = branch.peel().hex # invert the dict heads = collections.defaultdict(list) diff --git a/pagure/lib/git.py b/pagure/lib/git.py index 55f11fb..6dfb438 100644 --- a/pagure/lib/git.py +++ b/pagure/lib/git.py @@ -268,7 +268,7 @@ def _update_git(obj, repo): # See if there is a parent to this commit parent = None try: - parent = new_repo.head.get_object().oid + parent = new_repo.head.peel().oid except pygit2.GitError: pass @@ -341,7 +341,7 @@ def _clean_git(repo, obj_repotype, obj_uid): # See if there is a parent to this commit parent = None if not new_repo.is_empty: - parent = new_repo.head.get_object().oid + parent = new_repo.head.peel().oid parents = [] if parent: @@ -838,7 +838,7 @@ def _add_file_to_git(repo, issue, attachmentfolder, user, filename): # See if there is a parent to this commit parent = None try: - parent = new_repo.head.get_object().oid + parent = new_repo.head.peel().oid except pygit2.GitError: pass @@ -978,12 +978,10 @@ class TemporaryClone(object): # This gets checked out by default continue branch = self.repo.branches.remote.get("origin/%s" % localname) - self.repo.branches.local.create(localname, branch.get_object()) + self.repo.branches.local.create(localname, branch.peel()) elif ref.startswith("refs/pull/"): reference = self._origrepo.references.get(ref) - self.repo.references.create( - ref, reference.get_object().oid.hex - ) + self.repo.references.create(ref, reference.peel().oid.hex) return self @@ -1144,7 +1142,7 @@ def _update_file_in_git( # See if there is a parent to this commit branch_ref = get_branch_ref(new_repo, branch) - parent = branch_ref.get_object() + parent = branch_ref.peel() # See if we need to create the branch nbranch_ref = None @@ -1566,8 +1564,8 @@ def merge_pull_request(session, request, username, domerge=True): # Fetch the commits remote.fetch() - # repo_commit = fork_obj[branch.get_object().hex] - repo_commit = new_repo[branch.get_object().hex] + # repo_commit = fork_obj[branch.peel().hex] + repo_commit = new_repo[branch.peel().hex] # Checkout the correct branch if new_repo.is_empty or new_repo.head_is_unborn: @@ -1677,7 +1675,7 @@ def merge_pull_request(session, request, username, domerge=True): if domerge: _log.info(" PR merged using fast-forward") - head = new_repo.lookup_reference("HEAD").get_object() + head = new_repo.lookup_reference("HEAD").peel() if not request.project.settings.get("always_merge", False): if merge is not None: # This is depending on the pygit2 version @@ -1754,7 +1752,7 @@ def merge_pull_request(session, request, username, domerge=True): _log.info(" Merge non-FF PR is disabled for this project") return "MERGE" _log.info(" Writing down merge commit") - head = new_repo.lookup_reference("HEAD").get_object() + head = new_repo.lookup_reference("HEAD").peel() _log.info( " Basing on: %s - %s", head.hex, repo_commit.oid.hex ) @@ -1972,7 +1970,7 @@ def get_diff_info(repo_obj, orig_repo, branch_from, branch_to, prid=None): commitid = None if frombranch: - commitid = frombranch.get_object().hex + commitid = frombranch.peel().hex elif prid is not None: # If there is not branch found but there is a PR open, use the ref # of that PR in the main repo @@ -2000,7 +1998,7 @@ def get_diff_info(repo_obj, orig_repo, branch_from, branch_to, prid=None): "pagure.lib.git.get_diff_info: Pulling into a non-empty repo" ) if branch: - orig_commit = orig_repo[branch.get_object().hex] + orig_commit = orig_repo[branch.peel().hex] main_walker = orig_repo.walk( orig_commit.oid.hex, pygit2.GIT_SORT_NONE ) @@ -2067,7 +2065,7 @@ def get_diff_info(repo_obj, orig_repo, branch_from, branch_to, prid=None): repo_commit = repo_obj[repo_obj.head.target] else: branch = repo_obj.lookup_branch(branch_from) - repo_commit = branch.get_object() + repo_commit = branch.peel() for commit in repo_obj.walk(repo_commit.oid.hex, pygit2.GIT_SORT_NONE): diff_commits.append(commit) @@ -2252,7 +2250,7 @@ def get_git_tags(project, with_commits=False): if tag.startswith("refs/tags/"): ref = repo_obj.lookup_reference(tag) if ref: - com = ref.get_object() + com = ref.peel() if com: tags[tag.split("refs/tags/")[1]] = com.oid.hex else: @@ -2281,9 +2279,7 @@ def get_git_tags_objects(project): theobject = None objecttype = "" if isinstance(theobject, pygit2.Tag): - underlying_obj = theobject.get_object() - if isinstance(underlying_obj, pygit2.Tree): - continue + underlying_obj = theobject.peel(pygit2.Commit) commit_time = underlying_obj.commit_time objecttype = "tag" elif isinstance(theobject, pygit2.Commit): @@ -2396,7 +2392,7 @@ def new_git_branch( raise pagure.exceptions.PagureException( 'The "{0}" branch does not exist'.format(from_branch) ) - parent = get_branch_ref(repo_obj, from_branch).get_object() + parent = get_branch_ref(repo_obj, from_branch).peel() else: if from_commit not in repo_obj: raise pagure.exceptions.PagureException( diff --git a/pagure/lib/tasks.py b/pagure/lib/tasks.py index 211d77d..27ccb3d 100644 --- a/pagure/lib/tasks.py +++ b/pagure/lib/tasks.py @@ -947,7 +947,7 @@ def commits_author_stats(self, session, repopath): number_of_commits = 0 authors_email = set() for commit in repo_obj.walk( - repo_obj.head.get_object().oid.hex, pygit2.GIT_SORT_NONE + repo_obj.head.peel().oid.hex, pygit2.GIT_SORT_NONE ): # For each commit record how many times each combination of name and # e-mail appears in the git history. @@ -1008,7 +1008,7 @@ def commits_history_stats(self, session, repopath): dates = collections.defaultdict(int) for commit in repo_obj.walk( - repo_obj.head.get_object().oid.hex, pygit2.GIT_SORT_NONE + repo_obj.head.peel().oid.hex, pygit2.GIT_SORT_NONE ): delta = ( datetime.datetime.utcnow() - arrow.get(commit.commit_time).naive diff --git a/pagure/ui/fork.py b/pagure/ui/fork.py index 2b9231f..e67979f 100644 --- a/pagure/ui/fork.py +++ b/pagure/ui/fork.py @@ -432,7 +432,7 @@ def request_pull_to_diff_or_patch( branch = repo_obj.lookup_branch(request.branch_from) commitid = None if branch: - commitid = branch.get_object().hex + commitid = branch.peel().hex diff_commits = [] if request.status != "Open": diff --git a/pagure/ui/issues.py b/pagure/ui/issues.py index dd2bed7..2edeca6 100644 --- a/pagure/ui/issues.py +++ b/pagure/ui/issues.py @@ -1436,7 +1436,7 @@ def view_issue_raw_file(repo, filename=None, username=None, namespace=None): flask.abort(404, "Empty repo cannot have a file") branch = repo_obj.lookup_branch("master") - commit = branch.get_object() + commit = branch.peel() content = __get_file_in_tree( repo_obj, commit.tree, ["files", filename], bail_on_tree=True diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index a1c28e1..3b4736b 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -209,7 +209,7 @@ def view_repo_branch(repo, branchname, username=None, namespace=None): head = None cnt = 0 last_commits = [] - for commit in repo_obj.walk(branch.get_object().hex, pygit2.GIT_SORT_NONE): + for commit in repo_obj.walk(branch.peel().hex, pygit2.GIT_SORT_NONE): last_commits.append(commit) cnt += 1 if cnt == 3: @@ -240,11 +240,11 @@ def view_repo_branch(repo, branchname, username=None, namespace=None): commit_list = [ commit.oid.hex for commit in orig_repo.walk( - compare_branch.get_object().hex, + compare_branch.peel().hex, pygit2.GIT_SORT_NONE) ] - repo_commit = repo_obj[branch.get_object().hex] + repo_commit = repo_obj[branch.peel().hex] for commit in repo_obj.walk( repo_commit.oid.hex, pygit2.GIT_SORT_NONE): @@ -305,7 +305,7 @@ def view_commits(repo, branchname=None, username=None, namespace=None): branch = None if branchname and branchname in repo_obj.listall_branches(): branch = repo_obj.lookup_branch(branchname) - commit = branch.get_object() + commit = branch.peel() elif branchname: try: commit = repo_obj.get(branchname) @@ -314,16 +314,16 @@ def view_commits(repo, branchname=None, username=None, namespace=None): if "refs/tags/%s" % branchname in list(repo_obj.references): ref = repo_obj.lookup_reference("refs/tags/%s" % branchname) - commit = ref.get_object() + commit = ref.peel() # If we're arriving here from the release page, we may have a Tag # where we expected a commit, in this case, get the actual commit if isinstance(commit, pygit2.Tag): - commit = commit.get_object() + commit = commit.peel() branchname = commit.oid.hex elif not repo_obj.is_empty and not repo_obj.head_is_unborn: branch = repo_obj.lookup_branch(repo_obj.head.shorthand) - commit = branch.get_object() + commit = branch.peel() branchname = branch.branch_name if not repo_obj.is_empty and not repo_obj.head_is_unborn: @@ -515,7 +515,7 @@ def view_file(repo, identifier, filename, username=None, namespace=None): if identifier in repo_obj.listall_branches(): branchname = identifier branch = repo_obj.lookup_branch(identifier) - commit = branch.get_object() + commit = branch.peel() else: try: commit = repo_obj.get(identifier) @@ -528,7 +528,7 @@ def view_file(repo, identifier, filename, username=None, namespace=None): branchname = "master" if isinstance(commit, pygit2.Tag): - commit = commit.get_object() + commit = commit.peel() tree = None if isinstance(commit, pygit2.Tree): @@ -679,7 +679,7 @@ def view_raw_file( if identifier in repo_obj.listall_branches(): branch = repo_obj.lookup_branch(identifier) - commit = branch.get_object() + commit = branch.peel() else: try: commit = repo_obj.get(identifier) @@ -693,7 +693,7 @@ def view_raw_file( flask.abort(404, "Commit %s not found" % (identifier)) if isinstance(commit, pygit2.Tag): - commit = commit.get_object() + commit = commit.peel() if filename: if isinstance(commit, pygit2.Blob): @@ -743,7 +743,7 @@ def view_blame_file(repo, filename, username=None, namespace=None): if branchname in repo_obj.listall_branches(): branch = repo_obj.lookup_branch(branchname) - commit = branch.get_object() + commit = branch.peel() else: try: commit = repo_obj[branchname] @@ -751,7 +751,7 @@ def view_blame_file(repo, filename, username=None, namespace=None): commit = repo_obj[repo_obj.head.target] if isinstance(commit, pygit2.Tag): - commit = commit.get_object() + commit = commit.peel() content = __get_file_in_tree( repo_obj, commit.tree, filename.split("/"), bail_on_tree=True @@ -952,7 +952,7 @@ def view_tree(repo, identifier=None, username=None, namespace=None): if identifier in repo_obj.listall_branches(): branchname = identifier branch = repo_obj.lookup_branch(identifier) - commit = branch.get_object() + commit = branch.peel() else: try: commit = repo_obj.get(identifier) @@ -971,7 +971,7 @@ def view_tree(repo, identifier=None, username=None, namespace=None): # If we're arriving here from the release page, we may have a Tag # where we expected a commit, in this case, get the actual commit if isinstance(commit, pygit2.Tag): - commit = commit.get_object() + commit = commit.peel() branchname = commit.oid.hex if commit and not isinstance(commit, pygit2.Blob): @@ -2450,7 +2450,7 @@ def edit_file(repo, branchname, filename, username=None, namespace=None): branch = None if branchname in repo_obj.listall_branches(): branch = repo_obj.lookup_branch(branchname) - commit = branch.get_object() + commit = branch.peel() else: flask.abort(400, "Invalid branch specified") @@ -3447,7 +3447,7 @@ def generate_project_archive( tag = repo_obj[reference.target] if not isinstance(tag, pygit2.Tag): flask.abort(400, "Invalid reference provided") - commit = tag.get_object() + commit = tag.peel(pygit2.Commit) else: try: commit = repo_obj.get(ref) diff --git a/tests/__init__.py b/tests/__init__.py index c81e383..c21ac3d 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -728,7 +728,7 @@ def _clone_and_top_commits(folder, branch, branch_ref=False): commit = None try: if branch_ref_obj: - commit = repo[branch_ref_obj.get_object().hex] + commit = repo[branch_ref_obj.peel().hex] else: commit = repo.revparse_single('HEAD') except KeyError: @@ -894,7 +894,7 @@ def add_commit_git_repo(folder, ncommits=10, filename='sources', commit = None try: if branch_ref_obj: - commit = repo[branch_ref_obj.get_object().hex] + commit = repo[branch_ref_obj.peel().hex] else: commit = repo.revparse_single('HEAD') except (KeyError, AttributeError): @@ -945,7 +945,7 @@ def add_content_to_git( commit = None try: if branch_ref_obj: - commit = repo[branch_ref_obj.get_object().hex] + commit = repo[branch_ref_obj.peel().hex] else: commit = repo.revparse_single('HEAD') except (KeyError, AttributeError): diff --git a/tests/test_pagure_flask_api_project.py b/tests/test_pagure_flask_api_project.py index 22ea91f..8502d68 100644 --- a/tests/test_pagure_flask_api_project.py +++ b/tests/test_pagure_flask_api_project.py @@ -126,7 +126,7 @@ class PagureFlaskApiProjecttests(tests.Modeltests): # Create two other branches based on master for branch in ['pats-win-49', 'pats-win-51']: - clone_repo.create_branch(branch, clone_repo.head.get_object()) + clone_repo.create_branch(branch, clone_repo.head.peel()) refname = 'refs/heads/{0}:refs/heads/{0}'.format(branch) PagureRepo.push(clone_repo.remotes[0], refname) @@ -2841,7 +2841,7 @@ class PagureFlaskApiProjecttests(tests.Modeltests): self.session, 'aaabbbcccddd', 'create_branch') git_path = os.path.join(self.path, 'repos', 'test.git') repo_obj = pygit2.Repository(git_path) - parent = pagure.lib.git.get_branch_ref(repo_obj, 'master').get_object() + parent = pagure.lib.git.get_branch_ref(repo_obj, 'master').peel() repo_obj.create_branch('dev123', parent) headers = {'Authorization': 'token aaabbbcccddd'} args = {'branch': 'test123', 'from_branch': 'dev123'} diff --git a/tests/test_pagure_flask_ui_no_master_branch.py b/tests/test_pagure_flask_ui_no_master_branch.py index 1eeff35..6986425 100644 --- a/tests/test_pagure_flask_ui_no_master_branch.py +++ b/tests/test_pagure_flask_ui_no_master_branch.py @@ -67,7 +67,7 @@ class PagureFlaskNoMasterBranchtests(tests.SimplePagureTest): ) feature_branch = clone_repo.lookup_branch('feature') - first_commit = feature_branch.get_object().hex + first_commit = feature_branch.peel().hex # Second commit with open(os.path.join(repopath, '.gitignore'), 'w') as stream: diff --git a/tests/test_pagure_flask_ui_repo.py b/tests/test_pagure_flask_ui_repo.py index 9bdb959..be77354 100644 --- a/tests/test_pagure_flask_ui_repo.py +++ b/tests/test_pagure_flask_ui_repo.py @@ -4815,7 +4815,7 @@ index 0000000..fb7093d # list of binary strings representing parents of the new commit [] ) - repo_obj.create_branch("feature",repo_obj.head.get_object()) + repo_obj.create_branch("feature",repo_obj.head.peel()) data = { 'branches': 'feature', @@ -5386,7 +5386,7 @@ index 0000000..fb7093d path = os.path.join(self.path, 'repos', 'test.git') tests.add_content_git_repo(path) repo = pygit2.Repository(path) - repo.create_branch('foo', repo.head.get_object()) + repo.create_branch('foo', repo.head.peel()) # Check before deletion output = self.app.get('/test') @@ -5409,7 +5409,7 @@ index 0000000..fb7093d path = os.path.join(self.path, 'repos', 'test.git') tests.add_content_git_repo(path) repo = pygit2.Repository(path) - repo.create_branch('feature/foo', repo.head.get_object()) + repo.create_branch('feature/foo', repo.head.peel()) # Check before deletion output = self.app.get('/test') @@ -5440,7 +5440,7 @@ index 0000000..fb7093d path = os.path.join(self.path, 'repos', 'test.git') tests.add_content_git_repo(path) repo = pygit2.Repository(path) - repo.create_branch('foo', repo.head.get_object()) + repo.create_branch('foo', repo.head.peel()) user = tests.FakeUser(username = 'pingou') with tests.user_set(self.app.application, user): @@ -5464,7 +5464,7 @@ index 0000000..fb7093d path = os.path.join(self.path, 'repos', 'test.git') tests.add_content_git_repo(path) repo = pygit2.Repository(path) - repo.create_branch('foo', repo.head.get_object()) + repo.create_branch('foo', repo.head.peel()) user = tests.FakeUser(username = 'pingou') with tests.user_set(self.app.application, user): @@ -5503,7 +5503,7 @@ index 0000000..fb7093d path = os.path.join(self.path, 'repos', 'forks', 'foo', 'test.git') tests.add_content_git_repo(path) repo = pygit2.Repository(path) - repo.create_branch('foo', repo.head.get_object()) + repo.create_branch('foo', repo.head.peel()) user = tests.FakeUser(username = 'foo') with tests.user_set(self.app.application, user): diff --git a/tests/test_pagure_flask_ui_repo_slash_name.py b/tests/test_pagure_flask_ui_repo_slash_name.py index 9c1a3e9..70c57a7 100644 --- a/tests/test_pagure_flask_ui_repo_slash_name.py +++ b/tests/test_pagure_flask_ui_repo_slash_name.py @@ -229,7 +229,7 @@ class PagureFlaskSlashInNametests(tests.SimplePagureTest): gitrepo = os.path.join(self.path, 'repos', 'forks/test.git') repo = pygit2.Repository(gitrepo) master_branch = repo.lookup_branch('master') - first_commit = master_branch.get_object().hex + first_commit = master_branch.peel().hex output = self.app.get('/forks/test/commits') self.assertEqual(output.status_code, 200) diff --git a/tests/test_pagure_flask_ui_slash_branch_name.py b/tests/test_pagure_flask_ui_slash_branch_name.py index 7bb19c5..1f49cd9 100644 --- a/tests/test_pagure_flask_ui_slash_branch_name.py +++ b/tests/test_pagure_flask_ui_slash_branch_name.py @@ -70,7 +70,7 @@ class PagureFlaskSlashInBranchtests(tests.SimplePagureTest): PagureRepo.push(ori_remote, refname) master_branch = clone_repo.lookup_branch('master') - first_commit = master_branch.get_object().hex + first_commit = master_branch.peel().hex # Second commit with open(os.path.join(repopath, '.gitignore'), 'w') as stream: diff --git a/tests/test_pagure_lib_git.py b/tests/test_pagure_lib_git.py index 4915a65..e740c59 100644 --- a/tests/test_pagure_lib_git.py +++ b/tests/test_pagure_lib_git.py @@ -2627,7 +2627,7 @@ index 0000000..60f7480 # Case 4, get revs between two commits on two different branches newgitrepo = tempfile.mkdtemp(prefix='pagure-') newrepo = pygit2.clone_repository(gitrepo, newgitrepo) - newrepo.create_branch('feature', newrepo.head.get_object()) + newrepo.create_branch('feature', newrepo.head.peel()) with open(os.path.join(newgitrepo, 'sources'), 'w') as stream: stream.write('foo\n bar') @@ -3039,19 +3039,19 @@ index 0000000..60f7480 # make sure that creating works the first time pagure.lib.git.update_pull_ref(fake_pr, fork) - oldhex = fork.references["refs/heads/master"].get_object().hex + oldhex = fork.references["refs/heads/master"].peel().hex self.assertEqual( - orig.references["refs/pull/6/head"].get_object().hex, + orig.references["refs/pull/6/head"].peel().hex, oldhex, ) # make sure that updating works correctly tests.add_content_git_repo(projects[1], append="foobar") - newhex = fork.references["refs/heads/master"].get_object().hex + newhex = fork.references["refs/heads/master"].peel().hex self.assertNotEqual(oldhex, newhex) pagure.lib.git.update_pull_ref(fake_pr, fork) self.assertEqual( - orig.references["refs/pull/6/head"].get_object().hex, + orig.references["refs/pull/6/head"].peel().hex, newhex, ) @@ -3061,11 +3061,11 @@ index 0000000..60f7480 pagure.lib.git.update_pull_ref(fake_pr, fork) self.assertIsNotNone(fork.remotes["pingou_1234567"]) tests.add_content_git_repo(projects[1], append="foobarbaz") - newesthex = fork.references["refs/heads/master"].get_object().hex + newesthex = fork.references["refs/heads/master"].peel().hex self.assertNotEqual(newhex, newesthex) pagure.lib.git.update_pull_ref(fake_pr, fork) self.assertEqual( - orig.references["refs/pull/6/head"].get_object().hex, + orig.references["refs/pull/6/head"].peel().hex, newesthex, ) diff --git a/tests/test_pagure_lib_git_diff_pr.py b/tests/test_pagure_lib_git_diff_pr.py index d9fc3a9..6790eb3 100644 --- a/tests/test_pagure_lib_git_diff_pr.py +++ b/tests/test_pagure_lib_git_diff_pr.py @@ -310,7 +310,7 @@ class PagureFlaskForkPrtests(tests.Modeltests): self.assertTrue(cnt < 60) pr_ref = repo.lookup_reference('refs/pull/1/head') - commit = pr_ref.get_object() + commit = pr_ref.peel() self.assertEqual( commit.oid.hex, diff_commits[0].oid.hex @@ -350,7 +350,7 @@ class PagureFlaskForkPrtests(tests.Modeltests): self.assertTrue(cnt < 60) pr_ref = repo.lookup_reference('refs/pull/1/head') - commit = pr_ref.get_object() + commit = pr_ref.peel() self.assertEqual( commit.oid.hex, diff_commits[0].oid.hex @@ -366,7 +366,7 @@ class PagureFlaskForkPrtests(tests.Modeltests): clone_repo.index.add('sources') clone_repo.index.write() - last_commit = clone_repo.lookup_branch('feature_foo').get_object() + last_commit = clone_repo.lookup_branch('feature_foo').peel() # Commits the files added tree = clone_repo.index.write_tree() @@ -413,7 +413,7 @@ class PagureFlaskForkPrtests(tests.Modeltests): self.assertTrue(cnt < 60) pr_ref = repo.lookup_reference('refs/pull/1/head') - commit2 = pr_ref.get_object() + commit2 = pr_ref.peel() self.assertEqual( commit2.oid.hex, diff_commits[0].oid.hex @@ -457,7 +457,7 @@ class PagureFlaskForkPrtests(tests.Modeltests): self.assertTrue(cnt < 60) pr_ref = repo.lookup_reference('refs/pull/1/head') - commit = pr_ref.get_object() + commit = pr_ref.peel() self.assertEqual( commit.oid.hex, diff_commits[0].oid.hex @@ -489,7 +489,7 @@ class PagureFlaskForkPrtests(tests.Modeltests): self.assertTrue(cnt < 60) pr_ref = repo.lookup_reference('refs/pull/1/head') - commit2 = pr_ref.get_object() + commit2 = pr_ref.peel() self.assertEqual( commit2.oid.hex, diff_commits[0].oid.hex From 908eaa622e8b483747214b690ec0b1409eaee269 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 08 2019 12:23:42 +0000 Subject: [PATCH 4/8] Not all markdown version expose markdown.__version__.version_info Signed-off-by: Pierre-Yves Chibon --- diff --git a/tests/test_pagure_lib.py b/tests/test_pagure_lib.py index 2d6d535..84a264f 100644 --- a/tests/test_pagure_lib.py +++ b/tests/test_pagure_lib.py @@ -4120,7 +4120,10 @@ class PagureLibtests(tests.Modeltests): # old markdown generate other html import markdown - markdown_v = markdown.__version__.version_info + try: + markdown_v = markdown.__version__.version_info + except AttributeError: # pragma: no cover + markdown_v = markdown.__version_info__ old_markdown = markdown_v < (2, 6, 0) texts = [ From 86597acb4fdf940e6d6dd01bef3b3f0ff98052e2 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 08 2019 12:42:56 +0000 Subject: [PATCH 5/8] Add a pip-based container test Signed-off-by: Pierre-Yves Chibon --- diff --git a/dev/containers/fedora-pip-py3 b/dev/containers/fedora-pip-py3 new file mode 100644 index 0000000..7d7b31a --- /dev/null +++ b/dev/containers/fedora-pip-py3 @@ -0,0 +1,27 @@ +FROM fedora:latest + +RUN dnf -y install \ + python3-setuptools \ + redhat-rpm-config \ + python3-devel \ + libgit2-devel \ + python3-tox + libffi-devel \ + m2crypto \ + zeromq-devel \ + gcc \ + redis \ + which \ + git + +RUN cd / \ + && git clone https://pagure.io/pagure.git + +# Install pygit2 manually, outside of the virtualenv since it is tightly coupled +# which the version of libgit2 installed on the system. +RUN pip3 install "pygit2 <= `rpm -q libgit2 --queryformat='%{version}'`" && \ + cd /pagure + +WORKDIR /pagure +ENTRYPOINT ["/pagure/dev/containers/tox_py3.sh"] +CMD [] diff --git a/dev/containers/tox_py3.sh b/dev/containers/tox_py3.sh new file mode 100644 index 0000000..d9c806d --- /dev/null +++ b/dev/containers/tox_py3.sh @@ -0,0 +1,25 @@ +#!/bin/bash + + +ls -l / + +echo "============== ENVIRONMENT =============" +/usr/bin/env +echo "============== END ENVIRONMENT =============" + +if [ -n "$REPO" -a -n "$BRANCH" ]; then +git remote rm proposed || true +git gc --auto +git remote add proposed "$REPO" +git fetch proposed +git checkout origin/master +git config --global user.email "you@example.com" +git config --global user.name "Your Name" +git merge --no-ff "proposed/$BRANCH" -m "Merge PR" + +echo "Running tests for branch $BRANCH of repo $REPO" +echo "Last commits:" +git log -2 +fi + +tox -v --sitepackages -e 'py34-flask100-ci' -- --results=results diff --git a/dev/run-tests-container.py b/dev/run-tests-container.py index 14dd8b3..b9bd36e 100644 --- a/dev/run-tests-container.py +++ b/dev/run-tests-container.py @@ -22,6 +22,11 @@ def setup_parser(): help="Run the tests in centos environment", ) parser.add_argument( + "--pip", + action="store_true", + help="Run the tests in a venv on a Fedora host", + ) + parser.add_argument( "--skip-build", dest="skip_build", action="store_false", @@ -48,9 +53,18 @@ if __name__ == "__main__": elif args.fedora is True: container_names = ["pagure-f29-rpms-py3"] container_files = ["f29-rpms-py3"] + elif args.pip is True: + container_names = ["pagure-fedora-pip-py3"] + container_files = ["fedora-pip-py3"] else: - container_names = ["pagure-f29-rpms-py3", "pagure-c7-rpms-py2"] - container_files = ["f29-rpms-py3", "centos7-rpms-py2"] + container_names = [ + "pagure-f29-rpms-py3", "pagure-c7-rpms-py2", + "pagure-fedora-pip-py3" + ] + container_files = [ + "f29-rpms-py3", "centos7-rpms-py2", + "fedora-pip-py3" + ] for idx, container_name in enumerate(container_names): if args.skip_build is not False: From 02e44ac8c5b7fdf92e03896d37b351e13793016c Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 08 2019 12:42:56 +0000 Subject: [PATCH 6/8] When running all the containers, give a summary at the end Signed-off-by: Pierre-Yves Chibon --- diff --git a/dev/run-tests-container.py b/dev/run-tests-container.py index b9bd36e..55f5648 100644 --- a/dev/run-tests-container.py +++ b/dev/run-tests-container.py @@ -66,10 +66,11 @@ if __name__ == "__main__": "fedora-pip-py3" ] + failed = [] for idx, container_name in enumerate(container_names): if args.skip_build is not False: print("------ Building Container Image -----") - sp.call( + output_code = sp.call( [ "podman", "build", @@ -81,6 +82,9 @@ if __name__ == "__main__": "dev/containers", ] ) + if output_code: + print("Failed building: %s", container_name) + break result_path = "{}/results_{}".format(os.getcwd(), container_files[idx]) if not os.path.exists(result_path): @@ -108,22 +112,33 @@ if __name__ == "__main__": sp.call(command) else: print("--------- Running Test --------------") - sp.call( - [ - "podman", - "run", - "-it", - "--rm", - "--name", - container_name, - "-v", - "{}/results_{}:/pagure/results:z".format( - os.getcwd(), container_files[idx]), - "-e", - "BRANCH={}".format(os.environ.get("BRANCH") or ""), - "-e", - "REPO={}".format(os.environ.get("REPO") or ""), - container_name, - args.test_case, - ] - ) + command = [ + "podman", + "run", + "-it", + "--rm", + "--name", + container_name, + "-v", + "{}/results_{}:/pagure/results:z".format( + os.getcwd(), container_files[idx]), + "-e", + "BRANCH={}".format(os.environ.get("BRANCH") or ""), + "-e", + "REPO={}".format(os.environ.get("REPO") or ""), + container_name, + args.test_case, + ] + + output_code = sp.call(command) + if output_code: + failed.append(container_name) + + if not args.shell: + print("\nSummary:") + if not failed: + print(" ALL TESTS PASSED") + else: + print(" %s TESTS FAILED:" % len(failed)) + for fail in failed: + print(" - %s" % fail) From 95469144c45a100bc3075eb59f82ae966787628f Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 08 2019 13:01:17 +0000 Subject: [PATCH 7/8] Run the pip container in jenkins and exports its artifacts Signed-off-by: Pierre-Yves Chibon --- diff --git a/.cico.pipeline b/.cico.pipeline index 11fc913..0fb747c 100644 --- a/.cico.pipeline +++ b/.cico.pipeline @@ -73,6 +73,7 @@ node('pagure') { stage('Sync Artifacts'){ syncfromduffynode('pagure/results_f29-rpms-py3/') syncfromduffynode('pagure/results_centos7-rpms-py2/') + syncfromduffynode('pagure/results_fedora-pip-py3/') } stage('Deallocate Node'){ @@ -87,6 +88,7 @@ node('pagure') { stage('Archive Artifacts'){ archiveArtifacts artifacts: 'pagure/results_f29-rpms-py3/' archiveArtifacts artifacts: 'pagure/results_centos7-rpms-py2/' + archiveArtifacts artifacts: 'pagure/results_fedora-pip-py3/' } } } diff --git a/run_ci_tests_containers.sh b/run_ci_tests_containers.sh index fe11956..cd941d0 100644 --- a/run_ci_tests_containers.sh +++ b/run_ci_tests_containers.sh @@ -36,3 +36,18 @@ podman run --rm -it --name pagure-c7-rpms-py2 \ -e BRANCH=$BRANCH \ -e REPO=$REPO \ pagure-c7-rpms-py2 + + +podman build --rm -t pagure-fedora-pip-py3 \ + -f dev/containers/fedora-pip-py3 \ + dev/containers + +if [ ! -d `pwd`/results_fedora-pip-py3 ]; then + mkdir `pwd`/results_fedora-pip-py3; +fi + +podman run --rm -it --name pagure-fedora-pip-py3 \ + -v `pwd`/results_fedora-pip-py3:/pagure/results:z \ + -e BRANCH=$BRANCH \ + -e REPO=$REPO \ + pagure-fedora-pip-py3 From 37fdbb0946d2ae95e5c027f7ac3de6cb32e791c9 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 08 2019 13:57:27 +0000 Subject: [PATCH 8/8] Fix the repoSpanner integration tests Signed-off-by: Pierre-Yves Chibon --- diff --git a/tests/test_pagure_repospanner.py b/tests/test_pagure_repospanner.py index 4afd8b1..9fe1abf 100644 --- a/tests/test_pagure_repospanner.py +++ b/tests/test_pagure_repospanner.py @@ -131,13 +131,30 @@ class PagureRepoSpannerTests(tests.Modeltests): if not self.repospanner_binary: raise unittest.SkipTest('repoSpanner not found') - hookrunbin = os.path.join(os.path.dirname(self.repospanner_binary), - 'repohookrunner') - if not os.path.exists(hookrunbin): + hookrunbins = [ + os.path.join( + os.path.dirname(self.repospanner_binary), 'repohookrunner'), + os.path.join('/usr', 'libexec','repohookrunner'), + ] + found = False + for hookrunbin in hookrunbins: + if os.path.exists(hookrunbin): + found = True + break + if not found: raise Exception('repoSpanner found, but repohookrunner not') - repobridgebin = os.path.join(os.path.dirname(self.repospanner_binary), - 'repobridge') - if not os.path.exists(repobridgebin): + + repobridgebins = [ + os.path.join( + os.path.dirname(self.repospanner_binary), 'repobridge'), + os.path.join('/usr', 'libexec','repobridge'), + ] + found = False + for repobridgebin in repobridgebins: + if os.path.exists(repobridgebin): + found = True + break + if not found: raise Exception('repoSpanner found, but repobridge not') self.config_values['repobridge_binary'] = repobridgebin