Skip to content

Commit b5cb6e5

Browse files
committed
Add basic sanity checks and CI
Signed-off-by: Jordan Borean <[email protected]>
1 parent 9233801 commit b5cb6e5

File tree

8 files changed

+450
-295
lines changed

8 files changed

+450
-295
lines changed

.github/workflows/ci.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Test k5test
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths-ignore:
7+
- CODE_OF_CONDUCT.md
8+
- K5TEST-LICENSE.txt
9+
- LICENSE.txt
10+
- README.md
11+
12+
pull_request:
13+
branches:
14+
- main
15+
paths-ignore:
16+
- CODE_OF_CONDUCT.md
17+
- K5TEST-LICENSE.txt
18+
- LICENSE.txt
19+
- README.md
20+
21+
release:
22+
types:
23+
- published
24+
25+
schedule:
26+
- cron: 0 9 * * *
27+
28+
jobs:
29+
test:
30+
name: test
31+
runs-on: ubuntu-latest
32+
33+
steps:
34+
- uses: actions/checkout@v2
35+
36+
- uses: actions/setup-python@v2
37+
38+
- name: Test
39+
run: |
40+
echo "::group::Installing Python Requirements"
41+
42+
python -m pip install --upgrade pip setuptools wheel
43+
python -m pip install --requirement requirements-dev.txt
44+
python -m pip install .
45+
46+
echo "::endgroup::"
47+
48+
echo "::group::Running Sanity Checks"
49+
50+
python -m black . --check
51+
python -m isort . --check-only
52+
53+
echo "::endgroup::"
54+
55+
publish:
56+
name: publish
57+
needs:
58+
- test
59+
60+
runs-on: ubuntu-latest
61+
steps:
62+
- uses: actions/checkout@v2
63+
64+
- uses: actions/setup-python@v2
65+
66+
- name: Build sdist and wheel
67+
run: |
68+
python -m pip install --upgrade pip setuptools wheel
69+
python setup.py bdist_wheel --universal
70+
python setup.py sdist
71+
72+
- name: Capture sdist and wheel
73+
uses: actions/upload-artifact@v2
74+
with:
75+
name: k5test
76+
path: dist/*
77+
78+
- name: Publish
79+
if: startsWith(github.ref, 'refs/tags/v')
80+
uses: pypa/gh-action-pypi-publish@release/v1
81+
with:
82+
user: __token__
83+
password: ${{ secrets.PYPI_API_TOKEN }}

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
repos:
2+
- repo: https://github.com/psf/black
3+
rev: 21.9b0
4+
hooks:
5+
- id: black
6+
7+
- repo: https://github.com/PyCQA/isort
8+
rev: 5.9.3
9+
hooks:
10+
- id: isort

k5test/_utils.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import os
2-
import sys
32
import subprocess
3+
import sys
44

55

66
# general use
77
def get_output(*args, **kwargs):
88
res = subprocess.check_output(*args, shell=True, **kwargs)
9-
decoded = res.decode('utf-8')
9+
decoded = res.decode("utf-8")
1010
return decoded.strip()
1111

1212

@@ -27,7 +27,7 @@ def import_gssapi_extension(name):
2727
"""
2828

2929
try:
30-
path = 'gssapi.raw.ext_{0}'.format(name)
30+
path = "gssapi.raw.ext_{0}".format(name)
3131
__import__(path)
3232
return sys.modules[path]
3333
except ImportError:
@@ -44,33 +44,31 @@ def find_plugin_dir():
4444
return _PLUGIN_DIR
4545

4646
# if we've set a LD_LIBRARY_PATH, use that first
47-
ld_path_raw = os.environ.get('LD_LIBRARY_PATH')
47+
ld_path_raw = os.environ.get("LD_LIBRARY_PATH")
4848
if ld_path_raw is not None:
4949
# first, try assuming it's just a normal install
5050

51-
ld_paths = [path for path in ld_path_raw.split(':') if path]
51+
ld_paths = [path for path in ld_path_raw.split(":") if path]
5252

5353
for ld_path in ld_paths:
5454
if not os.path.exists(ld_path):
5555
continue
5656

57-
_PLUGIN_DIR = _decide_plugin_dir(
58-
_find_plugin_dirs_installed(ld_path))
57+
_PLUGIN_DIR = _decide_plugin_dir(_find_plugin_dirs_installed(ld_path))
5958
if _PLUGIN_DIR is None:
60-
_PLUGIN_DIR = _decide_plugin_dir(
61-
_find_plugin_dirs_src(ld_path))
59+
_PLUGIN_DIR = _decide_plugin_dir(_find_plugin_dirs_src(ld_path))
6260

6361
if _PLUGIN_DIR is not None:
6462
break
6563

6664
# if there was no LD_LIBRARY_PATH, or the above failed
6765
if _PLUGIN_DIR is None:
68-
lib_dir = os.path.join(get_output('krb5-config --prefix'), 'lib64')
66+
lib_dir = os.path.join(get_output("krb5-config --prefix"), "lib64")
6967
_PLUGIN_DIR = _decide_plugin_dir(_find_plugin_dirs_installed(lib_dir))
7068

7169
# /usr/lib64 seems only to be distinct on Fedora/RHEL/Centos family
7270
if _PLUGIN_DIR is None:
73-
lib_dir = os.path.join(get_output('krb5-config --prefix'), 'lib')
71+
lib_dir = os.path.join(get_output("krb5-config --prefix"), "lib")
7472
_PLUGIN_DIR = _decide_plugin_dir(_find_plugin_dirs_installed(lib_dir))
7573

7674
if _PLUGIN_DIR is not None:
@@ -97,23 +95,25 @@ def _decide_plugin_dir(dirs):
9795

9896
def _find_plugin_dirs_installed(search_path):
9997
try:
100-
options_raw = get_output('find %s/ -type d \( ! -executable -o ! -readable \) '
101-
'-prune -o '
102-
'-type d -path "*/krb5/plugins" -print' % search_path,
103-
stderr=subprocess.STDOUT)
98+
options_raw = get_output(
99+
"find %s/ -type d \( ! -executable -o ! -readable \) "
100+
"-prune -o "
101+
'-type d -path "*/krb5/plugins" -print' % search_path,
102+
stderr=subprocess.STDOUT,
103+
)
104104
except subprocess.CalledProcessError:
105105
options_raw = None
106106

107107
if options_raw:
108-
return options_raw.split('\n')
108+
return options_raw.split("\n")
109109
else:
110110
return None
111111

112112

113113
def _find_plugin_dirs_src(search_path):
114-
options_raw = get_output('find %s/../ -type d -name plugins' % search_path)
114+
options_raw = get_output("find %s/../ -type d -name plugins" % search_path)
115115

116116
if options_raw:
117-
return options_raw.split('\n')
117+
return options_raw.split("\n")
118118
else:
119119
return None

0 commit comments

Comments
 (0)