Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automatic tests with Github Actions #703

Merged
merged 39 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
4919fbc
Run travis.yml workflow
justin-h-loi Jul 31, 2023
811e1a5
Changing file path of .travis workflow
justin-h-loi Aug 1, 2023
26e98a7
Added converted git action version of travis.yml
justin-h-loi Aug 1, 2023
f917566
.travis.yml build fix
justin-h-loi Aug 1, 2023
3a2efff
Directory fix in .travis.yml action
justin-h-loi Aug 1, 2023
8ec9dc8
Permissions fix in .travis.yml action
justin-h-loi Aug 1, 2023
f1343c6
Setup virtualenv inside builds in .travis.yml action
justin-h-loi Aug 1, 2023
f44b045
Add missing virtualenv install for builds in .travis.yml action
justin-h-loi Aug 1, 2023
fb860ca
Backtrack to try using sudo instead for setup in .travis.yml action
justin-h-loi Aug 1, 2023
815dc8a
File permissions for run.sh in .travis.yml action
justin-h-loi Aug 1, 2023
ada28ec
Folder permissions for run.sh in .travis.yml action
justin-h-loi Aug 1, 2023
9371f65
Merge branch 'OpenKMIP:master' into master
justin-h-loi Aug 1, 2023
d4ecbbf
Remove setup.py in .travis setup
justin-h-loi Aug 1, 2023
58f92e7
code reduction
justin-h-loi Aug 1, 2023
23c72dd
Changing ubuntu image versions
justin-h-loi Aug 1, 2023
6b39d88
Changing python versions
justin-h-loi Aug 1, 2023
6ec719c
Adding test number conditions
justin-h-loi Aug 1, 2023
2250844
Reformat test number conditions
justin-h-loi Aug 1, 2023
39aea3d
test number conditions
justin-h-loi Aug 1, 2023
b271890
test number conditions
justin-h-loi Aug 1, 2023
6fce192
test reduction
justin-h-loi Aug 1, 2023
5f56040
Remove old installs and attempt at doc test fix
justin-h-loi Aug 8, 2023
04b3dc4
tox passenv change
justin-h-loi Aug 8, 2023
6333b69
Extending flake8 test max line length
justin-h-loi Aug 8, 2023
1a3b3bd
Merge branch 'master' of https://github.com/OpenKMIP/PyKMIP
justin-h-loi Aug 15, 2023
34171a4
Make unit tests use default config
justin-h-loi Aug 15, 2023
e9e3229
pep8 fixes
justin-h-loi Aug 15, 2023
4da5931
alternate config unit test fix
justin-h-loi Aug 15, 2023
89c9bde
Adding integration tests to git actions
justin-h-loi Aug 22, 2023
510b72a
Removing setup.py install for test
justin-h-loi Aug 22, 2023
20df5e5
Readding setup.py and adding permissions to /usr/local/lib/
justin-h-loi Aug 22, 2023
32b1b6b
Update git actions to node16 runtime
justin-h-loi Aug 22, 2023
3de97b8
Adding ubuntu20 and extra python versions to git actions
justin-h-loi Aug 22, 2023
10146bb
(tox.ini): Forgot to add python versions to tox envlist
justin-h-loi Aug 22, 2023
f78d023
Test fix
justin-h-loi Aug 22, 2023
5b1ea19
Fix to include integration tests for py builds
justin-h-loi Aug 22, 2023
c4fe915
Actions file name change and fixes
justin-h-loi Aug 29, 2023
d4972cd
Fix code syntax and docs
justin-h-loi Aug 29, 2023
840bd6a
Removing bandit/pyaml version requirements
justin-h-loi Aug 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "tox.yml"

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ${{ matrix.os }}
env:
TOXENV: ${{ matrix.test }}
RUN_INTEGRATION_TESTS: ${{ matrix.test_number}}
steps:
- uses: actions/checkout@v3
- run: pip install "tox"
- run: pip install bandit
- run: pip install codecov
- run: pip install slugs
- run: sudo chmod -R 777 /usr/local/lib/
- run: python3 setup.py install
- run: ./.travis/run.sh
- run: codecov
strategy:
matrix:
test: ["pep8", "bandit", "docs"]
os: [ubuntu-22.04,ubuntu-20.04]
include:
- test: "py38"
test_number: "0"
os: ubuntu-20.04
- test: "py38"
test_number: "1"
os: ubuntu-20.04
- test: "py310"
test_number: "0"
os: ubuntu-22.04
- test: "py310"
test_number: "1"
os: ubuntu-22.04
4 changes: 4 additions & 0 deletions .travis/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
set -e
set -x

pkill -f run_server.py || true
sleep 1

if [[ "${RUN_INTEGRATION_TESTS}" == "1" ]]; then
sudo mkdir -p /etc/pykmip/certs
sudo mkdir -p /etc/pykmip/policies
Expand All @@ -14,6 +17,7 @@ if [[ "${RUN_INTEGRATION_TESTS}" == "1" ]]; then
sudo cp ./.travis/policy.json /etc/pykmip/policies/policy.json
sudo mkdir -p /var/log/pykmip
sudo chmod 777 /var/log/pykmip
sudo chmod -R 777 /etc/pykmip/
python3 ./bin/run_server.py &
tox -e integration -- --config client
elif [[ "${RUN_INTEGRATION_TESTS}" == "2" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = 'en'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand Down
4 changes: 2 additions & 2 deletions kmip/services/server/auth/slugs.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def authenticate(self,
)

try:
response = requests.get(self.users_url.format(user_id))
response = requests.get(self.users_url.format(user_id), timeout=10)
except Exception:
raise exceptions.ConfigurationError(
"A connection could not be established using the SLUGS URL."
Expand All @@ -98,7 +98,7 @@ def authenticate(self,
"Unrecognized user ID: {}".format(user_id)
)

response = requests.get(self.groups_url.format(user_id))
response = requests.get(self.groups_url.format(user_id), timeout=10)
if response.status_code == 404:
raise exceptions.PermissionDenied(
"Group information could not be retrieved for user ID: "
Expand Down
2 changes: 1 addition & 1 deletion kmip/services/server/crypto/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def mac(self, algorithm, key, data):
)
cipher_algorithm = self._symmetric_key_algorithms.get(algorithm)
try:
# ARC4 and other non-block cipher algorithms will raise TypeError exceptions
# ARC4 and other non-block cipher algorithm will raise TypeError
c = cmac.CMAC(cipher_algorithm(key), backend=default_backend())
c.update(data)
mac_data = c.finalize()
Expand Down
3 changes: 2 additions & 1 deletion kmip/services/server/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ def _handle_message_loop(self):
)

try:
if hasattr(self._connection, 'shared_ciphers') and self._connection.shared_ciphers() is not None:
if (hasattr(self._connection, 'shared_ciphers')
and self._connection.shared_ciphers() is not None):
shared_ciphers = self._connection.shared_ciphers()
self._logger.debug(
"Possible session ciphers: {0}".format(len(shared_ciphers))
Expand Down
4 changes: 2 additions & 2 deletions kmip/tests/unit/services/server/auth/test_slugs.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ def test_authenticate(self, mock_get_client_identity, mock_request_get):

mock_get_client_identity.assert_called_once_with("test")
mock_request_get.assert_any_call(
"http://127.0.0.1:8080/test/slugs/users/John Doe"
"http://127.0.0.1:8080/test/slugs/users/John Doe", timeout=10
)
mock_request_get.assert_any_call(
"http://127.0.0.1:8080/test/slugs/users/John Doe/groups"
"http://127.0.0.1:8080/test/slugs/users/John Doe/groups", timeout=10
)
self.assertEqual(('John Doe', ['Group A', 'Group B']), result)

Expand Down
2 changes: 1 addition & 1 deletion kmip/tests/unit/services/test_kmip_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def setUp(self):
self.cred_factory = CredentialFactory()
self.secret_factory = SecretFactory()

self.client = KMIPProxy()
self.client = KMIPProxy(config_file="/dev/null")

KMIP_PORT = 9090
CA_CERTS_PATH = os.path.normpath(os.path.join(os.path.dirname(
Expand Down
4 changes: 2 additions & 2 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ fixtures
mock
slugs
sphinx
PyYAML<=5.2
bandit==1.5.1
PyYAML
bandit
5 changes: 3 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[tox]
envlist = pep8,py27,py34,py35,py36,py37,bandit,docs
envlist = pep8,py38,py310,bandit,docs

[testenv]
passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH
passenv = *

deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
Expand Down Expand Up @@ -48,3 +48,4 @@ commands =

[flake8]
exclude = .git,.tox,dist,rpmbuild,*.egg-info
max-line-length = 88
Loading