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

GitHub actions, component updates (aiohttp, requests) #24

Merged
merged 17 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[flake8]
ignore = E203
exclude = .git,__pycache__,docs/source/conf.py,old,build,dist,systemtest-library/.eggs,venv
max-line-length = 130

39 changes: 39 additions & 0 deletions .github/workflows/installation-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Installation test
on:
push:
paths:
- 'requirements.txt'
- 'pytest.ini'
- '.github/workflows/installation-test.yml'

# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: e2e-'${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true

jobs:
python-install:
strategy:
matrix:
os: ["ubuntu-20.04", "ubuntu-22.04"]
python-ver: ["3.7", "3.8", "3.9", "3.10", "3.11"]
exclude:
- os: ubuntu-22.04
python-ver: 3.6
runs-on: ${{ matrix.os }}
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Install Python ${{ matrix.python-ver}}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-ver}}
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Installation steps on ${{ matrix.os }} w ${{ matrix.python-ver}}
run: |
pip install --upgrade pip
pip install --upgrade cython
pip install -U -r requirements.txt
- name: Run collect only
run: pytest --collect-only
98 changes: 98 additions & 0 deletions .github/workflows/pr-checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: PR-checker
on: push

# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: izuma-system-tests-'${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true

jobs:
static-checks:
runs-on: ubuntu-latest
env:
SUMMARY_FILE: summary.log
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: Clone scripts-internal
uses: actions/checkout@v4
with:
repository: PelionIoT/scripts-internal
token: ${{ secrets.ACCESS_TOKEN }}

# Need to run this 1st, so that the other log files do not cause unnecessary findings
- name: Run misspell
if: always()
run: |
curl -L -o ./install-misspell.sh https://git.io/misspell
sh ./install-misspell.sh
bin/misspell -i mosquitto . >misspell.log
echo "## Summary" >>$SUMMARY_FILE
echo "### misspell" >>$SUMMARY_FILE
cat misspell.log >>$SUMMARY_FILE
bin/misspell -error -i mosquitto .
lines=$(wc -l < "misspell.log")
if [[ $lines -gt 0 ]]; then
echo "Misspell has findings, fail."
echo "TEST_FAIL=true" >> $GITHUB_ENV
exit 1
else
echo "No findings." >>$SUMMARY_FILE
fi

- name: Run pylint (findings may not increase)
run: |
sudo apt-get install pylint
pylint --version
pylint --exit-zero --persistent=n tests/ izuma_systest_lib/ >pylint.log
echo "### pylint" >>$SUMMARY_FILE
pylintstats=$(scripts-internal/ci/more-lines-checker.sh ${{ github.event.repository.default_branch }} ${{ github.ref_name }} "pylint --exit-zero --persistent=n systemtest-library test_cases" | tail -n2)
echo "$pylintstats" >>$SUMMARY_FILE
pylintscore=$(tail -2 pylint.log |head -1)
echo "$pylintscore" >>$SUMMARY_FILE
echo "$pylintstats"
if [[ $pylintstats == *"Oh no"* ]]; then
# More findings than earlier
echo "TEST_FAIL=true" >> $GITHUB_ENV
exit 1
fi
- name: Run flake8
if: always()
run: |
sudo apt-get install flake8
flake8 --version
echo "Starting flake8..."
flake8 --exit-zero --exclude=izuma_systest_lib/.eggs,scripts-internal --max-line-length=130 >flake8.log
echo "### flake8" >>$SUMMARY_FILE
lines=$(wc -l < "flake8.log")
if [[ $lines -gt 0 ]]; then
echo "Flake8 has findings, fail."
echo "TEST_FAIL=true" >> $GITHUB_ENV
exit 1
else
echo "No findings." >>$SUMMARY_FILE
fi

- name: Archive production artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: Findings logs
path: |
*.log
- name: Summary
if: always()
run: cat $SUMMARY_FILE >>$GITHUB_STEP_SUMMARY

- name: Set whole job status based on found fails
if: always()
run: |
if [ "$TEST_FAIL" = "true" ]; then
echo "Some test has failed, fail the job."
exit 1 # You can choose to exit with success (0) to mark this step as successful but skipped.
fi
7 changes: 6 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# Izuma E2E Edge Python Test Suite Change log

## 1.2.2
- Fixed misspellings.
- Updated `aiohttp` to 3.8.6 and `requests` to 2.31.0.
- Minor `pylint` fixes.

## 1.2.1
- Add marker `cpu_notif_test` to CPU resource notification test. This allows you to skip that test with `pytest -m "not cpu_notif_test"`. You can skip that and reboot test with `-m 'not (reboot_test or cpu_notif_test)'`.
- Add marker `reboot_test` to LwM2M test that resets device. This allows you to skip that test with `pytest -m "not reboot_test"`.
- Move `pytest.ini` from `tests`-folder to root, this way to the custom marker gets taken into account.
- Upgrade `pytest` to 7.3.1 and `pytest-html` 3.2.0 to resolve Python 3.10 compatiblity issue.
- Upgrade `pytest` to 7.3.1 and `pytest-html` 3.2.0 to resolve Python 3.10 compatibility issue.
- Add *.xml files to `.gitignore`.

## 1.2.0
Expand Down
2 changes: 1 addition & 1 deletion izuma_systest_lib/cloud/libraries/config_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

class EdgeConfigManagementAPI:
"""
A class that provides edge config managment.
A class that provides edge config management.
https://github.com/PelionIoT/wigwag-cloud-relay-configs/blob/master/swagger.yaml
"""

Expand Down
2 changes: 1 addition & 1 deletion izuma_systest_lib/edge/remote_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, api_key, url):
:param url: Remote terminal url
"""
# Create loop explicitly, Python 3.10 warns, 3.11 stops working..
if self.loop == None:
if self.loop is None:
self.loop = asyncio.new_event_loop()
asyncio.set_event_loop(self.loop)
log.debug(f"RemoteTerminal __init__ self.loop created {self.loop}")
Expand Down
6 changes: 3 additions & 3 deletions izuma_systest_lib/fixtures/edge_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def kube_config_file_path(tc_config_data):
utils.execute_local_command('kubectl config use-context edge-k8s')
log.debug('Temporary kubernetes configuration successfully created and in use')
else:
log.debug('No need to create temporary kubernetes konfiguration')
log.debug('No need to create temporary kubernetes configuration')
yield kube_config_path

# Remove temporary configuration when running outside Jenkins
Expand All @@ -80,7 +80,7 @@ def edge(kube_config_file_path, tc_config_data):
"""
Initializes connection to edge via RaaS or locally (subprocess) based on configuration.
Release connection when not needed anymore
:param kube_config_file_path: Kubernetes konfiguration file path
:param kube_config_file_path: Kubernetes configuration file path
:param tc_config_data: Test case config
:return: resource
"""
Expand All @@ -106,7 +106,7 @@ def kubectl(edge): # pylint: disable=unused-argument
def kaas(kube_config_file_path):
"""
Open connection to the kubernets as a service (KAAS) using kubernets python sdk
:param kube_config_file_path: Kubernetes konfiguration file path
:param kube_config_file_path: Kubernetes configuration file path
:return: api_client
"""
custom_configuration = Configuration()
Expand Down
2 changes: 1 addition & 1 deletion izuma_systest_lib/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def _assert_status(expected_resp, response):
Status code comparison
:param expected_resp: Expected response, one value or list of values
:param response: Request response
:return: Comparision result
:return: Comparison result
"""
if isinstance(expected_resp, list):
return response.status_code in expected_resp
Expand Down
Loading