Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.devtools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.devtools
Commits
5f485eb6
Commit
5f485eb6
authored
4 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
[scripts.ci] Fix package privacy tests on nightlies; Add integration tests for this new feature
parent
0ec480b6
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!221
Fix package privacy tests on nightlies
Pipeline
#51303
failed
4 years ago
Stage: build
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
bob/devtools/ci.py
+37
-0
37 additions, 0 deletions
bob/devtools/ci.py
bob/devtools/scripts/ci.py
+5
-3
5 additions, 3 deletions
bob/devtools/scripts/ci.py
bob/devtools/test_ci.py
+11
-0
11 additions, 0 deletions
bob/devtools/test_ci.py
conda/meta.yaml
+3
-0
3 additions, 0 deletions
conda/meta.yaml
with
56 additions
and
3 deletions
bob/devtools/ci.py
+
37
−
0
View file @
5f485eb6
...
...
@@ -40,6 +40,43 @@ def is_master(refname, tag, repodir):
return
refname
==
"
master
"
def
is_private
(
baseurl
,
package
):
"""
Tells if a given package (with a namespace) is public or private
This function checks if a fully qualified package in the format
``<namespace>/<name>`` is publicly accessible. It does this by trying to
access ``info/refs?service=git-upload-pack`` from the package in question.
This method does **not** rely on the fact the user has access to Gitlab.
.. warning::
This method only works for fully qualified package names (i.e.,
containing at least one forward-slash ``/``).
Args:
baseurl: The base URL for the gitlab service to consult
package: Fully qualified (i.e., with a namespace) package name. For
example: ``bob/bob.extension``.
Returns: a boolean, indicating if the package is private (``True``) or not
(``False``).
"""
from
urllib.error
import
HTTPError
from
urllib.request
import
urlopen
private
=
True
try
:
r
=
urlopen
(
baseurl
+
"
/
"
+
package
+
"
/info/refs?service=git-upload-pack
"
)
private
=
r
.
getcode
()
!=
200
except
HTTPError
as
e
:
private
=
e
.
getcode
()
==
401
return
private
def
is_stable
(
package
,
refname
,
tag
,
repodir
):
"""
Determines if the package being published is stable.
...
...
This diff is collapsed.
Click to expand it.
bob/devtools/scripts/ci.py
+
5
−
3
View file @
5f485eb6
...
...
@@ -14,6 +14,7 @@ from click_plugins import with_plugins
from
..build
import
comment_cleanup
from
..build
import
load_order_file
from
..ci
import
cleanup
from
..ci
import
is_private
from
..ci
import
read_packages
from
..ci
import
select_conda_build_config
from
..ci
import
select_conda_recipe_append
...
...
@@ -667,8 +668,6 @@ def nightlies(ctx, order, dry_run):
token
=
os
.
environ
[
"
CI_JOB_TOKEN
"
]
from
urllib.request
import
urlopen
import
git
from
.build
import
build
...
...
@@ -698,7 +697,10 @@ def nightlies(ctx, order, dry_run):
)
# determine package visibility
private
=
urlopen
(
"
https://gitlab.idiap.ch/%s
"
%
package
).
getcode
()
!=
200
private
=
is_private
(
"
https://gitlab.idiap.ch
"
,
package
)
private_str
=
"
PRIVATE
"
if
private
else
"
PUBLIC
"
logger
.
info
(
'
Package
"
%s
"
is %s
'
,
package
,
private_str
)
stable
=
"
STABLE
"
in
os
.
environ
# Use custom variants and append files if available on recipe-dir
...
...
This diff is collapsed.
Click to expand it.
bob/devtools/test_ci.py
0 → 100644
+
11
−
0
View file @
5f485eb6
#!/usr/bin/env python
# coding=utf-8
from
.ci
import
is_private
def
test_is_private
():
base_url
=
"
https://gitlab.idiap.ch
"
assert
not
is_private
(
base_url
,
"
bob/bob.extension
"
)
assert
is_private
(
base_url
,
"
bob/private
"
)
This diff is collapsed.
Click to expand it.
conda/meta.yaml
+
3
−
0
View file @
5f485eb6
...
...
@@ -55,6 +55,8 @@ requirements:
test
:
requires
:
-
sphinx_rtd_theme
-
pytest
-
pytest-cov
imports
:
-
{{
name
}}
commands
:
...
...
@@ -113,6 +115,7 @@ test:
-
bdt sphinx --help
-
bdt sphinx migrate-autodoc-flags --help
-
bdt gitlab alt-nightlies --help
-
pytest --capture=no --verbose --cov {{ name }} --cov-report term-missing --cov-report html:{{ project_dir }}/sphinx/coverage --cov-report xml:{{ project_dir }}/coverage.xml --pyargs {{ name }}
-
sphinx-build -aEW ${PREFIX}/share/doc/{{ name }}/doc sphinx
{
%
if not os.path.exists('sphinx') %
}
-
if [ -n "${CI_PROJECT_DIR}" ]; then mv sphinx "${CI_PROJECT_DIR}/"; fi
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment