Skip to content

Commit

Permalink
Archive Python prototype scheduler
Browse files Browse the repository at this point in the history
Also remove it from the CI.
  • Loading branch information
jherbel committed Oct 12, 2023
1 parent 610122e commit 41ecb10
Show file tree
Hide file tree
Showing 21 changed files with 252 additions and 87 deletions.
18 changes: 0 additions & 18 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,13 @@ 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

steps:
- 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

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
112 changes: 112 additions & 0 deletions archive/v2/robotmk/ci
Original file line number Diff line number Diff line change
@@ -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 "$?"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
42 changes: 42 additions & 0 deletions archive/v2/robotmk/setup
Original file line number Diff line number Diff line change
@@ -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
94 changes: 94 additions & 0 deletions archive/v2/tests/rebot.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<robot generator="Rebot 6.1.1 (Python 3.11.4 on win32)" generated="20230901 02:47:13.056" rpa="false" schemaversion="4">
<suite id="s1" name="Tasks &amp; Tasks">
<suite id="s1-s1" name="Tasks" source="C:\robotmk\v2\data\retry_suite\tasks.robot">
<kw name="Setup" library="math" type="SETUP">
<msg timestamp="20230901 02:47:09.299" level="INFO">Setting up...</msg>
<status status="PASS" starttime="20230901 02:47:09.299" endtime="20230901 02:47:09.299"/>
</kw>
<test id="s1-s1-t1" name="Addition 1" line="17">
<kw name="Add" library="math">
<var>${result}</var>
<arg>${20}</arg>
<arg>${15}</arg>
<msg timestamp="20230901 02:47:09.299" level="INFO">${result} = 35</msg>
<status status="PASS" starttime="20230901 02:47:09.299" endtime="20230901 02:47:09.299"/>
</kw>
<kw name="Should Be Equal As Integers" library="BuiltIn">
<arg>${result}</arg>
<arg>${35}</arg>
<doc>Fails if objects are unequal after converting them to integers.</doc>
<status status="PASS" starttime="20230901 02:47:09.299" endtime="20230901 02:47:09.299"/>
</kw>
<status status="NOT RUN" starttime="20230901 02:47:09.299" endtime="20230901 02:47:09.299"/>
</test>
<test id="s1-s1-t2" name="Addition 2" line="21">
<kw name="Add" library="math">
<var>${result}</var>
<arg>${1}</arg>
<arg>${2}</arg>
<msg timestamp="20230901 02:47:09.299" level="INFO">${result} = 3</msg>
<status status="PASS" starttime="20230901 02:47:09.299" endtime="20230901 02:47:09.299"/>
</kw>
<kw name="Should Be Equal As Integers" library="BuiltIn">
<arg>${result}</arg>
<arg>${expected_result_2}</arg>
<doc>Fails if objects are unequal after converting them to integers.</doc>
<msg timestamp="20230901 02:47:09.299" level="INFO">Argument types are:
&lt;class 'int'&gt;
&lt;class 'str'&gt;</msg>
<msg timestamp="20230901 02:47:09.299" level="FAIL">3 != 4</msg>
<status status="FAIL" starttime="20230901 02:47:09.299" endtime="20230901 02:47:09.299"/>
</kw>
<status status="FAIL" starttime="20230901 02:47:09.299" endtime="20230901 02:47:09.299">3 != 4</status>
</test>
<kw name="Teardown" library="math" type="TEARDOWN">
<msg timestamp="20230901 02:47:09.299" level="INFO">Tearing down...</msg>
<status status="PASS" starttime="20230901 02:47:09.299" endtime="20230901 02:47:09.299"/>
</kw>
<doc>Test file for configuring RobotFramework</doc>
<status status="FAIL" starttime="20230901 02:47:09.220" endtime="20230901 02:47:09.299"/>
</suite>
<suite id="s1-s2" name="Tasks" source="C:\robotmk\v2\data\retry_suite\tasks.robot">
<kw name="Setup" library="math" type="SETUP">
<msg timestamp="20230901 02:47:12.808" level="INFO">Setting up...</msg>
<status status="PASS" starttime="20230901 02:47:12.807" endtime="20230901 02:47:12.808"/>
</kw>
<test id="s1-s2-t1" name="Addition 2" line="21">
<kw name="Add" library="math">
<var>${result}</var>
<arg>${1}</arg>
<arg>${2}</arg>
<msg timestamp="20230901 02:47:12.808" level="INFO">${result} = 3</msg>
<status status="PASS" starttime="20230901 02:47:12.808" endtime="20230901 02:47:12.808"/>
</kw>
<kw name="Should Be Equal As Integers" library="BuiltIn">
<arg>${result}</arg>
<arg>${expected_result_2}</arg>
<doc>Fails if objects are unequal after converting them to integers.</doc>
<status status="PASS" starttime="20230901 02:47:12.808" endtime="20230901 02:47:12.808"/>
</kw>
<status status="PASS" starttime="20230901 02:47:12.808" endtime="20230901 02:47:12.808"/>
</test>
<kw name="Teardown" library="math" type="TEARDOWN">
<msg timestamp="20230901 02:47:12.808" level="INFO">Tearing down...</msg>
<status status="PASS" starttime="20230901 02:47:12.808" endtime="20230901 02:47:12.808"/>
</kw>
<doc>Test file for configuring RobotFramework</doc>
<status status="PASS" starttime="20230901 02:47:12.723" endtime="20230901 02:47:12.808"/>
</suite>
<status status="FAIL" starttime="N/A" endtime="N/A" elapsedtime="164"/>
</suite>
<statistics>
<total>
<stat pass="2" fail="1" skip="0">All Tests</stat>
</total>
<tag></tag>
<suite>
<stat pass="2" fail="1" skip="0" id="s1" name="Tasks &amp; Tasks">Tasks &amp; Tasks</stat>
<stat pass="1" fail="1" skip="0" id="s1-s1" name="Tasks">Tasks &amp; Tasks.Tasks</stat>
<stat pass="1" fail="0" skip="0" id="s1-s2" name="Tasks">Tasks &amp; Tasks.Tasks</stat>
</suite>
</statistics>
<errors></errors>
</robot>
File renamed without changes.
File renamed without changes.
52 changes: 2 additions & 50 deletions ci
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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="$?"
Expand All @@ -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 + $? ))"
;;

*)
Expand Down
21 changes: 2 additions & 19 deletions setup
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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

0 comments on commit 41ecb10

Please sign in to comment.