From 217cdaf7e4e43bc41e5486ea5107e99039bdec1a Mon Sep 17 00:00:00 2001 From: lfierz Date: Wed, 15 May 2024 16:59:29 +0200 Subject: [PATCH 1/7] create default driver github workflow --- .github/workflows/build-and-publish.yml | 13 +++++ .github/workflows/build-docs.yml | 11 ++++ .github/workflows/test.yml | 12 +++++ .gitlab-ci.yml | 69 ------------------------- 4 files changed, 36 insertions(+), 69 deletions(-) create mode 100644 .github/workflows/build-and-publish.yml create mode 100644 .github/workflows/build-docs.yml create mode 100644 .github/workflows/test.yml delete mode 100644 .gitlab-ci.yml diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml new file mode 100644 index 0000000..bfe532f --- /dev/null +++ b/.github/workflows/build-and-publish.yml @@ -0,0 +1,13 @@ +on: + push: + branches: + - master + tags: + - "^[0-9]+.[0-9]+.[0-9]+" + +jobs: + build_and_deploy: + uses: sensirion/.github/.github/workflows/driver.python.pypi_publish.yml@main + secrets: + PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }} + diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml new file mode 100644 index 0000000..4d5f98c --- /dev/null +++ b/.github/workflows/build-docs.yml @@ -0,0 +1,11 @@ +name: Publish Documentation +on: + push: + branches: + - master + tags: + - "^[0-9]+.[0-9]+.[0-9]+" + +jobs: + documentation: + uses: sensirion/.github/.github/workflows/driver.python.documentation.yml@main diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..615fdfb --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,12 @@ +name: Validate and Test Python Package +on: + pull_request: + branches: + - master + push: + branches: + - master + +jobs: + test: + uses: sensirion/.github/.github/workflows/driver.python.test.yml@main diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 8c8f0c2..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,69 +0,0 @@ -include: https://gitlab.sensirion.lokal/Sensirion/Python/ci-config-python/raw/master/gitlab-ci-template-v2.yml - -variables: - PYTEST_ADDOPTS: '-m "not (needs_serialport or needs_tcp)"' - -check_rst_syntax: - extends: .check_rst_syntax_v2 - -check_editorconfig: - extends: .check_editorconfig_v2 - - -py2p7_linux_build: - extends: .py2p7_linux_build_v2 - -py3p6_linux_build: - extends: .py3p6_linux_build_v2 - -py3p8_linux_build: - extends: .py3p8_linux_build_v2 - - -py2p7_32bit_win_build: - extends: .py2p7_32bit_win_docker_build_v2 - -py3p5_64bit_win_build: - extends: .py3p5_64bit_win_docker_build_v2 - -py3p8_64bit_win_build: - extends: .py3p8_64bit_win_docker_build_v2 - - -build_docs: - extends: .build_docs_v2 - script: - - python setup.py install - - pip install -r docs/requirements.txt - - ./ci/set_git_config.sh - - sphinx-versioning build -r "$CI_COMMIT_REF_NAME" -w "$CI_COMMIT_REF_NAME" docs docs/_build/html - - -deploy_staging: - extends: .deploy_staging_v2 - -deploy_stable: - extends: .deploy_stable_v2 - environment: - name: pypi.org - url: https://pypi.org/project/sensirion-shdlc-driver/ - before_script: - - pip install twine~=1.12.1 - script: - - PKG_VERSION=$(python setup.py --version --quiet | tail -n1) - - TAG_VERSION=$(git describe --tags) - - if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then echo "Tag Version ($TAG_VERSION) != Package Version ($PKG_VERSION)" && exit 1; fi - - twine upload dist/* - - -deploy_docs: - stage: deploy - tags: [linux, docker] - image: registry.gitlab.sensirion.lokal/sensirion/docker/docker-python:3.6-18.04-2.7.0 - dependencies: [] - only: [master, tags] - script: - - python setup.py install - - pip install -r docs/requirements.txt - - ./ci/set_git_config.sh - - sphinx-versioning push docs gh-pages . From e35dd02603827ab490e0e1d1aa5321f7e35ed0e5 Mon Sep 17 00:00:00 2001 From: lfierz Date: Wed, 15 May 2024 16:59:30 +0200 Subject: [PATCH 2/7] remove unused ci scripts --- ci/set_git_config.sh | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100755 ci/set_git_config.sh diff --git a/ci/set_git_config.sh b/ci/set_git_config.sh deleted file mode 100755 index 3ed5798..0000000 --- a/ci/set_git_config.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -# set shell settings (see https://sipb.mit.edu/doc/safe-shell/) -set -eufv -o pipefail - -# install ssh private key (set as CI variable in GitLab project settings) -mkdir -p ~/.ssh -echo "$SSH_DEPLOY_KEY" > ~/.ssh/id_rsa -chmod 400 ~/.ssh/id_rsa - -# change remote URL to SSH to allow pushing with SSH -git remote set-url --push origin "git@${CI_SERVER_HOST}:${CI_PROJECT_PATH}.git" - -# set git author -git config --global user.name "GitLab-CI" -git config --global user.email "<>" From 9fd242d1d2c21646181b19b4c357156156fcf9ad Mon Sep 17 00:00:00 2001 From: lfierz Date: Wed, 15 May 2024 16:59:31 +0200 Subject: [PATCH 3/7] use python 3.8 for docs build --- .github/workflows/build-docs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 4d5f98c..e922fcd 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -9,3 +9,5 @@ on: jobs: documentation: uses: sensirion/.github/.github/workflows/driver.python.documentation.yml@main + with: + build-python-version: 3.8 From 79e91deb0898f04b764b941c416b93cc7590b73c Mon Sep 17 00:00:00 2001 From: lfierz Date: Wed, 15 May 2024 17:49:14 +0200 Subject: [PATCH 4/7] fix test syntax for flake8 version 6 --- tests/commands/baudrate/test_get_baudrate.py | 2 +- tests/commands/error_state/test_get_error_state.py | 4 ++-- tests/commands/reply_delay/test_get_reply_delay.py | 2 +- tests/commands/slave_address/test_get_slave_address.py | 2 +- tests/commands/system_up_time/test_get_system_up_time.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/commands/baudrate/test_get_baudrate.py b/tests/commands/baudrate/test_get_baudrate.py index a244a9d..7cfa96f 100644 --- a/tests/commands/baudrate/test_get_baudrate.py +++ b/tests/commands/baudrate/test_get_baudrate.py @@ -73,5 +73,5 @@ def test_interpret_response(input, expected_baudrate): cmd = ShdlcCmdGetBaudrate() cmd.check_response_length(input) address = cmd.interpret_response(input) - assert type(address) == type(expected_baudrate) + assert type(address) is type(expected_baudrate) assert address == expected_baudrate diff --git a/tests/commands/error_state/test_get_error_state.py b/tests/commands/error_state/test_get_error_state.py index 71a9f5a..aeaa9e0 100644 --- a/tests/commands/error_state/test_get_error_state.py +++ b/tests/commands/error_state/test_get_error_state.py @@ -77,7 +77,7 @@ def test_interpret_response(input, expected_state, expected_last_error): cmd = ShdlcCmdGetErrorState(clear=False) cmd.check_response_length(input) state, last_error = cmd.interpret_response(input) - assert type(state) == type(expected_state) - assert type(last_error) == type(expected_last_error) + assert type(state) is type(expected_state) + assert type(last_error) is type(expected_last_error) assert state == expected_state assert last_error == expected_last_error diff --git a/tests/commands/reply_delay/test_get_reply_delay.py b/tests/commands/reply_delay/test_get_reply_delay.py index 480e646..5791ebc 100644 --- a/tests/commands/reply_delay/test_get_reply_delay.py +++ b/tests/commands/reply_delay/test_get_reply_delay.py @@ -73,5 +73,5 @@ def test_interpret_response(input, expected_address): cmd = ShdlcCmdGetReplyDelay() cmd.check_response_length(input) address = cmd.interpret_response(input) - assert type(address) == type(expected_address) + assert type(address) is type(expected_address) assert address == expected_address diff --git a/tests/commands/slave_address/test_get_slave_address.py b/tests/commands/slave_address/test_get_slave_address.py index c3b827d..d04671e 100644 --- a/tests/commands/slave_address/test_get_slave_address.py +++ b/tests/commands/slave_address/test_get_slave_address.py @@ -74,5 +74,5 @@ def test_interpret_response(input, expected_address): cmd = ShdlcCmdGetSlaveAddress() cmd.check_response_length(input) address = cmd.interpret_response(input) - assert type(address) == type(expected_address) + assert type(address) is type(expected_address) assert address == expected_address diff --git a/tests/commands/system_up_time/test_get_system_up_time.py b/tests/commands/system_up_time/test_get_system_up_time.py index d7c960b..78c946f 100644 --- a/tests/commands/system_up_time/test_get_system_up_time.py +++ b/tests/commands/system_up_time/test_get_system_up_time.py @@ -74,5 +74,5 @@ def test_interpret_response(input, expected_time): cmd = ShdlcCmdGetSystemUpTime() cmd.check_response_length(input) time = cmd.interpret_response(input) - assert type(time) == type(expected_time) + assert type(time) is type(expected_time) assert time == expected_time From abbcb8c19b56119cb02fbbe29870ad8cca634b35 Mon Sep 17 00:00:00 2001 From: lfierz Date: Wed, 15 May 2024 17:55:33 +0200 Subject: [PATCH 5/7] set hw test flag for ci --- .github/workflows/test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 615fdfb..b3b3d71 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,3 +10,7 @@ on: jobs: test: uses: sensirion/.github/.github/workflows/driver.python.test.yml@main + with: + hw-test-flag: (needs_serialport or needs_tcp) + + From a2429e38f0044506b970d6e9ff3b5c6a0e9c0488 Mon Sep 17 00:00:00 2001 From: lfierz Date: Thu, 16 May 2024 08:40:57 +0200 Subject: [PATCH 6/7] update pytest version such that tests run on python 3.10 and 3.11 --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 0d67c4a..56a36bd 100644 --- a/setup.py +++ b/setup.py @@ -49,8 +49,8 @@ 'flake8~=3.7.8', 'intelhex~=2.0', # from the "fwupdate" extra 'mock~=3.0.0', - 'pytest~=4.6.11', - 'pytest-cov~=2.12.1', + 'pytest~=6.2.5', + 'pytest-cov~=3.0.0', ] }, classifiers=[ From 20daa8b7e8d8731537efad9363804bea129f9dba Mon Sep 17 00:00:00 2001 From: lfierz Date: Thu, 16 May 2024 08:41:23 +0200 Subject: [PATCH 7/7] build docs with python 3.6 such that it runs with used sphinx version --- .github/workflows/build-docs.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index e922fcd..26a2c8b 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -10,4 +10,5 @@ jobs: documentation: uses: sensirion/.github/.github/workflows/driver.python.documentation.yml@main with: - build-python-version: 3.8 + run-environment: "ubuntu-20.04" + build-python-version: 3.6