-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tox with pep8,pylint and bashate
Tests all python scripts and starts adding coverage for bash scripts.
- Loading branch information
Showing
12 changed files
with
257 additions
and
106 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# This is a templated file and must be kept up-to-date with the original | ||
# from upstream at https://github.com/canonical/se-tooling-ci-common. | ||
name: Run Tests | ||
on: | ||
- push | ||
- pull_request | ||
- workflow_dispatch | ||
|
||
jobs: | ||
test: | ||
strategy: | ||
matrix: | ||
python-version: ['3.8', '3.10', '3.12'] | ||
os: [ubuntu-24.04, ubuntu-22.04, ubuntu-20.04] | ||
exclude: | ||
- os: ubuntu-20.04 | ||
python-version: '3.10' | ||
- os: ubuntu-20.04 | ||
python-version: '3.12' | ||
- os: ubuntu-22.04 | ||
python-version: '3.8' | ||
- os: ubuntu-22.04 | ||
python-version: '3.12' | ||
- os: ubuntu-24.04 | ||
python-version: '3.8' | ||
- os: ubuntu-24.04 | ||
python-version: '3.10' | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r gh-test-requirements.txt | ||
- name: Run pylint | ||
run: tox -e pylint | ||
if: matrix.python-version == '3.10' | ||
- name: Run pep8 | ||
run: tox -e pep8 | ||
if: matrix.python-version == '3.10' | ||
- name: Run bashate | ||
run: tox -e bashate | ||
if: matrix.python-version == '3.10' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tox<4.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,45 @@ | ||
# Get names of test targets that OSCI would run for the given charm. Should be | ||
# run from within the charm root. | ||
# | ||
# Outputs space seperated list of target names. | ||
# | ||
""" | ||
Get names of test targets that OSCI would run for the given charm. Should be | ||
run from within the charm root. | ||
Outputs space separated list of target names. | ||
""" | ||
import os | ||
|
||
import yaml | ||
|
||
CLASSIC_TESTS_YAML = 'tests/tests.yaml' | ||
REACTIVE_TESTS_YAML = os.path.join('src', CLASSIC_TESTS_YAML) | ||
|
||
def extract_values(bundle_list): | ||
|
||
def extract_targets(bundle_list): | ||
""" | ||
Targets are provided as strings or dicts where the target name is the | ||
value so this accounts for both formats. | ||
""" | ||
extracted = [] | ||
for item in bundle_list: | ||
if isinstance(item, dict): | ||
extracted.append(list(item.values())[0]) | ||
else: | ||
extracted.append(item) | ||
|
||
return extracted | ||
|
||
if os.path.exists(REACTIVE_TESTS_YAML): | ||
bundles = yaml.safe_load(open(REACTIVE_TESTS_YAML)) | ||
else: | ||
bundles = yaml.safe_load(open(CLASSIC_TESTS_YAML)) | ||
|
||
smoke_bundles = extract_values(bundles['smoke_bundles']) | ||
gate_bundles = extract_values(bundles['gate_bundles']) | ||
dev_bundles = extract_values(bundles['dev_bundles']) | ||
if __name__ == "__main__": | ||
if os.path.exists(REACTIVE_TESTS_YAML): | ||
TESTS_FILE = REACTIVE_TESTS_YAML | ||
else: | ||
TESTS_FILE = CLASSIC_TESTS_YAML | ||
|
||
with open(TESTS_FILE, encoding='utf-8') as fd: | ||
bundles = yaml.safe_load(fd) | ||
|
||
smoke_bundles = extract_targets(bundles['smoke_bundles']) | ||
gate_bundles = extract_targets(bundles['gate_bundles']) | ||
dev_bundles = extract_targets(bundles['dev_bundles']) | ||
|
||
targets = set(smoke_bundles + gate_bundles + dev_bundles) | ||
targets = set(smoke_bundles + gate_bundles + dev_bundles) | ||
|
||
print(' '.join(sorted(targets))) | ||
print(' '.join(sorted(targets))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# This is a templated file and must be kept up-to-date with the original | ||
# from upstream at https://github.com/canonical/se-tooling-ci-common. | ||
[MAIN] | ||
jobs=0 | ||
ignore=.git | ||
|
||
# List of plugins (as comma separated values of python module names) to load, | ||
# usually to register additional checkers. | ||
load-plugins=pylint.extensions.no_self_use | ||
|
||
# When enabled, pylint would attempt to guess common misconfiguration and emit | ||
# user-friendly hints instead of false-positive error messages. | ||
suggestion-mode=yes | ||
|
||
[FORMAT] | ||
max-line-length=79 | ||
# Allow doctrings containing long urls | ||
ignore-long-lines=^\s+.+<?https?://\S+>?$ | ||
|
||
[REPORTS] | ||
#reports=yes | ||
score=yes | ||
|
||
[MESSAGES CONTROL] | ||
disable= | ||
|
||
[DESIGN] | ||
min-public-methods=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pyyaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# This is a templated file and must be kept up-to-date with the original | ||
# from upstream at https://github.com/canonical/se-tooling-ci-common. | ||
bashate | ||
flake8==6.1.0 | ||
flake8-import-order==0.18.2 | ||
pylint==3.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# pylint: disable=invalid-name | ||
""" | ||
Get Juju Bundle or Overlay Applications. | ||
""" | ||
import sys | ||
import yaml | ||
|
||
application_list = set() | ||
import yaml | ||
|
||
for filename in sys.argv[1:]: | ||
with open(filename, 'r') as f: | ||
data = yaml.load_all(f, Loader=yaml.SafeLoader) | ||
for d in data: | ||
if 'applications' in d: | ||
application_list.update(d['applications'].keys()) | ||
print('\n'.join(application_list)) | ||
if __name__ == "__main__": | ||
application_list = set() | ||
for filename in sys.argv[1:]: | ||
with open(filename, 'r', encoding='utf-8') as f: | ||
data = yaml.load_all(f, Loader=yaml.SafeLoader) | ||
for d in data: | ||
if 'applications' in d: | ||
application_list.update(d['applications'].keys()) | ||
print('\n'.join(application_list)) |
Oops, something went wrong.