From 41ecb104193473ee14ebaeae45c0bbb91a33ca5c Mon Sep 17 00:00:00 2001 From: Joerg Herbel Date: Thu, 12 Oct 2023 10:23:54 +0200 Subject: [PATCH] Archive Python prototype scheduler Also remove it from the CI. --- .github/workflows/ci.yaml | 18 --- {v2 => archive/v2}/robotmk/__init__.py | 0 {v2 => archive/v2}/robotmk/__main__.py | 0 {v2 => archive/v2}/robotmk/api.py | 0 {v2 => archive/v2}/robotmk/attempt.py | 0 archive/v2/robotmk/ci | 112 ++++++++++++++++++ {v2 => archive/v2}/robotmk/cli.py | 0 {v2 => archive/v2}/robotmk/config.py | 0 {v2 => archive/v2}/robotmk/environment.py | 0 {v2 => archive/v2}/robotmk/parse_xml.py | 0 poetry.lock => archive/v2/robotmk/poetry.lock | 0 {v2 => archive/v2}/robotmk/py.typed | 0 .../v2/robotmk/pyproject.toml | 0 {v2 => archive/v2}/robotmk/scheduling.py | 0 {v2 => archive/v2}/robotmk/session.py | 0 archive/v2/robotmk/setup | 42 +++++++ archive/v2/tests/rebot.xml | 94 +++++++++++++++ {v2 => archive/v2}/tests/test_attempts.py | 0 {v2 => archive/v2}/tests/test_parse_xml.py | 0 ci | 52 +------- setup | 21 +--- 21 files changed, 252 insertions(+), 87 deletions(-) rename {v2 => archive/v2}/robotmk/__init__.py (100%) rename {v2 => archive/v2}/robotmk/__main__.py (100%) rename {v2 => archive/v2}/robotmk/api.py (100%) rename {v2 => archive/v2}/robotmk/attempt.py (100%) create mode 100755 archive/v2/robotmk/ci rename {v2 => archive/v2}/robotmk/cli.py (100%) rename {v2 => archive/v2}/robotmk/config.py (100%) rename {v2 => archive/v2}/robotmk/environment.py (100%) rename {v2 => archive/v2}/robotmk/parse_xml.py (100%) rename poetry.lock => archive/v2/robotmk/poetry.lock (100%) rename {v2 => archive/v2}/robotmk/py.typed (100%) rename pyproject.toml => archive/v2/robotmk/pyproject.toml (100%) rename {v2 => archive/v2}/robotmk/scheduling.py (100%) rename {v2 => archive/v2}/robotmk/session.py (100%) create mode 100755 archive/v2/robotmk/setup create mode 100644 archive/v2/tests/rebot.xml rename {v2 => archive/v2}/tests/test_attempts.py (100%) rename {v2 => archive/v2}/tests/test_parse_xml.py (100%) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8ca8dd51..37d9cc1f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,16 +15,6 @@ jobs: step: cargo-clippy - name: Rust tests step: cargo-test - - name: Python formatting - step: black-check-all - - name: Python import sorting - step: isort-check-all - - name: Python type checking - step: mypy-check-all - - name: Python linting - step: pylint-check-all - - name: Python unit tests - step: pytest-check-all - name: Powershell static analysis step: PSScriptAnalyzer-check-all @@ -32,14 +22,6 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version-file: "pyproject.toml" - - - name: Setup Poetry - run: python3 -m pip install poetry - - name: Setup environment run: ./setup diff --git a/v2/robotmk/__init__.py b/archive/v2/robotmk/__init__.py similarity index 100% rename from v2/robotmk/__init__.py rename to archive/v2/robotmk/__init__.py diff --git a/v2/robotmk/__main__.py b/archive/v2/robotmk/__main__.py similarity index 100% rename from v2/robotmk/__main__.py rename to archive/v2/robotmk/__main__.py diff --git a/v2/robotmk/api.py b/archive/v2/robotmk/api.py similarity index 100% rename from v2/robotmk/api.py rename to archive/v2/robotmk/api.py diff --git a/v2/robotmk/attempt.py b/archive/v2/robotmk/attempt.py similarity index 100% rename from v2/robotmk/attempt.py rename to archive/v2/robotmk/attempt.py diff --git a/archive/v2/robotmk/ci b/archive/v2/robotmk/ci new file mode 100755 index 00000000..5ad007cc --- /dev/null +++ b/archive/v2/robotmk/ci @@ -0,0 +1,112 @@ +#!/bin/bash + +main() { + topdir="$(git rev-parse --show-toplevel)" + self="${topdir}/ci" + cargo_toml_path="${topdir}/v2/rust/Cargo.toml" + pyproject_toml_path="${topdir}/pyproject.toml" + v2_dir="${topdir}/v2" + v2_src="${v2_dir}/robotmk" + v2_tests="${v2_dir}/tests" + checkmk_extensions_dir="${topdir}/checkmk_extensions" + mode="${1}" + shift + + case "${mode}" in + 'cargo-fmt-check') + cargo fmt --manifest-path "${cargo_toml_path}" -- --check + ;; + + 'cargo-clippy') + cargo clippy --manifest-path "${cargo_toml_path}" --all-targets -- --deny warnings + ;; + + 'cargo-test') + cargo test --manifest-path "${cargo_toml_path}" --all-targets + ;; + + 'black') + poetry run black --config "${pyproject_toml_path}" "$@" + ;; + + 'black-check-all') + "${self}" black --check "${v2_src}" "${v2_tests}" + ;; + + 'isort') + poetry run isort --settings-path "${pyproject_toml_path}" "$@" + ;; + + 'isort-check-all') + "${self}" isort --check-only "${v2_src}" "${v2_tests}" + ;; + + 'mypy') + poetry run mypy --config-file "${pyproject_toml_path}" "$@" + ;; + + 'mypy-check-all') + "${self}" mypy "${v2_src}" "${v2_tests}" + ;; + + 'pylint') + poetry run pylint --rcfile "${pyproject_toml_path}" "$@" + ;; + + 'pylint-check-all') + "${self}" pylint --recursive true "${v2_src}" "${v2_tests}" + ;; + + 'pytest') + poetry run pytest --rootdir "${topdir}" "$@" + ;; + + 'pytest-check-all') + "${self}" pytest "${v2_tests}" + ;; + + 'PSScriptAnalyzer-check-all') + pwsh_output=$(pwsh -Command "Invoke-ScriptAnalyzer -Settings ${topdir}/PSScriptAnalyzerSettings.psd1 -Path ${checkmk_extensions_dir} -Recurse") + pwsh_exitcode="$?" + if [ "${pwsh_exitcode}" -eq 0 ]; then { + if [ -z "${pwsh_output}" ]; then { + echo "No static Powershell issues found" + return 0 + } else { + echo "${pwsh_output}" + return 1 + } + fi + } else { + echo "${pwsh_output}" + return "${pwsh_exitcode}" + } + fi + ;; + + 'check-all') + exit_code=0 + for rust_step in fmt-check clippy test + do + "${self}" "cargo-${rust_step}" + exit_code=$(( exit_code + $? )) + done + for tool in black isort mypy pylint pytest PSScriptAnalyzer + do + "${self}" "${tool}-check-all" + exit_code=$(( exit_code + $? )) + done + return "${exit_code}" + ;; + + *) + echo "Unknown mode: ${mode}" 1>&2 + return 1 + ;; + esac + + return "$?" +} + +main "$@" +exit "$?" diff --git a/v2/robotmk/cli.py b/archive/v2/robotmk/cli.py similarity index 100% rename from v2/robotmk/cli.py rename to archive/v2/robotmk/cli.py diff --git a/v2/robotmk/config.py b/archive/v2/robotmk/config.py similarity index 100% rename from v2/robotmk/config.py rename to archive/v2/robotmk/config.py diff --git a/v2/robotmk/environment.py b/archive/v2/robotmk/environment.py similarity index 100% rename from v2/robotmk/environment.py rename to archive/v2/robotmk/environment.py diff --git a/v2/robotmk/parse_xml.py b/archive/v2/robotmk/parse_xml.py similarity index 100% rename from v2/robotmk/parse_xml.py rename to archive/v2/robotmk/parse_xml.py diff --git a/poetry.lock b/archive/v2/robotmk/poetry.lock similarity index 100% rename from poetry.lock rename to archive/v2/robotmk/poetry.lock diff --git a/v2/robotmk/py.typed b/archive/v2/robotmk/py.typed similarity index 100% rename from v2/robotmk/py.typed rename to archive/v2/robotmk/py.typed diff --git a/pyproject.toml b/archive/v2/robotmk/pyproject.toml similarity index 100% rename from pyproject.toml rename to archive/v2/robotmk/pyproject.toml diff --git a/v2/robotmk/scheduling.py b/archive/v2/robotmk/scheduling.py similarity index 100% rename from v2/robotmk/scheduling.py rename to archive/v2/robotmk/scheduling.py diff --git a/v2/robotmk/session.py b/archive/v2/robotmk/session.py similarity index 100% rename from v2/robotmk/session.py rename to archive/v2/robotmk/session.py diff --git a/archive/v2/robotmk/setup b/archive/v2/robotmk/setup new file mode 100755 index 00000000..35cd1974 --- /dev/null +++ b/archive/v2/robotmk/setup @@ -0,0 +1,42 @@ +#!/bin/bash + +set -e + +main() { + setup_rust + + setup_python_environment "${PYTHON_VERSION}" + + setup_powershell + + git config core.hooksPath .githooks +} + +setup_python_environment() { + check_poetry_executable + export POETRY_VIRTUALENVS_IN_PROJECT=true + poetry install --with dev +} + +check_poetry_executable() { + command -v poetry > /dev/null || { + echo "poetry executable not found, aborting. Installing poetry is non-trivial, please do it manually." + exit 1 + } +} + +setup_powershell() { + sudo apt-get install wget apt-transport-https software-properties-common + wget -q "https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb" + sudo dpkg -i packages-microsoft-prod.deb + rm packages-microsoft-prod.deb + sudo apt-get update + sudo apt-get install powershell + pwsh -Command "Install-Module -Name PSScriptAnalyzer" +} + +setup_rust() { + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s - -y +} + +main diff --git a/archive/v2/tests/rebot.xml b/archive/v2/tests/rebot.xml new file mode 100644 index 00000000..cfe58344 --- /dev/null +++ b/archive/v2/tests/rebot.xml @@ -0,0 +1,94 @@ + + + + + + Setting up... + + + + + ${result} + ${20} + ${15} + ${result} = 35 + + + + ${result} + ${35} + Fails if objects are unequal after converting them to integers. + + + + + + + ${result} + ${1} + ${2} + ${result} = 3 + + + + ${result} + ${expected_result_2} + Fails if objects are unequal after converting them to integers. + Argument types are: +<class 'int'> +<class 'str'> + 3 != 4 + + + 3 != 4 + + + Tearing down... + + + Test file for configuring RobotFramework + + + + + Setting up... + + + + + ${result} + ${1} + ${2} + ${result} = 3 + + + + ${result} + ${expected_result_2} + Fails if objects are unequal after converting them to integers. + + + + + + Tearing down... + + + Test file for configuring RobotFramework + + + + + + + All Tests + + + + Tasks & Tasks + Tasks & Tasks.Tasks + Tasks & Tasks.Tasks + + + + diff --git a/v2/tests/test_attempts.py b/archive/v2/tests/test_attempts.py similarity index 100% rename from v2/tests/test_attempts.py rename to archive/v2/tests/test_attempts.py diff --git a/v2/tests/test_parse_xml.py b/archive/v2/tests/test_parse_xml.py similarity index 100% rename from v2/tests/test_parse_xml.py rename to archive/v2/tests/test_parse_xml.py diff --git a/ci b/ci index 5ad007cc..787d0fa2 100755 --- a/ci +++ b/ci @@ -4,10 +4,6 @@ main() { topdir="$(git rev-parse --show-toplevel)" self="${topdir}/ci" cargo_toml_path="${topdir}/v2/rust/Cargo.toml" - pyproject_toml_path="${topdir}/pyproject.toml" - v2_dir="${topdir}/v2" - v2_src="${v2_dir}/robotmk" - v2_tests="${v2_dir}/tests" checkmk_extensions_dir="${topdir}/checkmk_extensions" mode="${1}" shift @@ -25,46 +21,6 @@ main() { cargo test --manifest-path "${cargo_toml_path}" --all-targets ;; - 'black') - poetry run black --config "${pyproject_toml_path}" "$@" - ;; - - 'black-check-all') - "${self}" black --check "${v2_src}" "${v2_tests}" - ;; - - 'isort') - poetry run isort --settings-path "${pyproject_toml_path}" "$@" - ;; - - 'isort-check-all') - "${self}" isort --check-only "${v2_src}" "${v2_tests}" - ;; - - 'mypy') - poetry run mypy --config-file "${pyproject_toml_path}" "$@" - ;; - - 'mypy-check-all') - "${self}" mypy "${v2_src}" "${v2_tests}" - ;; - - 'pylint') - poetry run pylint --rcfile "${pyproject_toml_path}" "$@" - ;; - - 'pylint-check-all') - "${self}" pylint --recursive true "${v2_src}" "${v2_tests}" - ;; - - 'pytest') - poetry run pytest --rootdir "${topdir}" "$@" - ;; - - 'pytest-check-all') - "${self}" pytest "${v2_tests}" - ;; - 'PSScriptAnalyzer-check-all') pwsh_output=$(pwsh -Command "Invoke-ScriptAnalyzer -Settings ${topdir}/PSScriptAnalyzerSettings.psd1 -Path ${checkmk_extensions_dir} -Recurse") pwsh_exitcode="$?" @@ -91,12 +47,8 @@ main() { "${self}" "cargo-${rust_step}" exit_code=$(( exit_code + $? )) done - for tool in black isort mypy pylint pytest PSScriptAnalyzer - do - "${self}" "${tool}-check-all" - exit_code=$(( exit_code + $? )) - done - return "${exit_code}" + "${self}" "PSScriptAnalyzer-check-all" + return "$(( exit_code + $? ))" ;; *) diff --git a/setup b/setup index 35cd1974..696a740f 100755 --- a/setup +++ b/setup @@ -4,25 +4,12 @@ set -e main() { setup_rust - - setup_python_environment "${PYTHON_VERSION}" - setup_powershell - git config core.hooksPath .githooks } -setup_python_environment() { - check_poetry_executable - export POETRY_VIRTUALENVS_IN_PROJECT=true - poetry install --with dev -} - -check_poetry_executable() { - command -v poetry > /dev/null || { - echo "poetry executable not found, aborting. Installing poetry is non-trivial, please do it manually." - exit 1 - } +setup_rust() { + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s - -y } setup_powershell() { @@ -35,8 +22,4 @@ setup_powershell() { pwsh -Command "Install-Module -Name PSScriptAnalyzer" } -setup_rust() { - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s - -y -} - main