diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 07d419a..802432f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -19,8 +19,11 @@ jobs: lint-checks: needs: pre_job - name: Make requirements and lint check on Python3.6 - runs-on: ubuntu-18.04 + name: Make requirements and lint checks + runs-on: ubuntu-22.04 + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11"] steps: - name: Checkout st2tests repository uses: actions/checkout@v2 @@ -28,10 +31,10 @@ jobs: uses: actions/checkout@v2 with: repository: "StackStorm/st2" - - name: Set up Python3.6 - uses: actions/setup-python@v2 + - name: "Set up Python ${{ matrix.python-version }}" + uses: actions/setup-python@v4 with: - python-version: '3.6.13' + python-version: "${{ matrix.python-version }}" - name: Install apt dependencies run: | sudo apt install -y libldap2-dev libsasl2-dev diff --git a/Makefile b/Makefile index e5ef30b..05cafc1 100644 --- a/Makefile +++ b/Makefile @@ -14,9 +14,9 @@ space_char += comma := , COMPONENT_PYTHONPATH = $(subst $(space_char),:,$(realpath $(COMPONENTS))) -PYTHON_TARGET := 3.6 - -REQUIREMENTS := test-requirements.txt requirements.txt +# Extract the Python major/minor version to target the correct test requirements file. +PYTHON_VERSION := $(shell python3 --version | sed -r 's/.*([[0-9]+\.[0-9]+)\.[0-9]+.*/\1/g') +REQUIREMENTS := test-requirements-$(PYTHON_VERSION).txt requirements.txt # Grab the version of pip from the Makefile in the st2 repository # # 1. Grab the st2 branch name from ST2_BRANCH @@ -73,7 +73,7 @@ pylint: requirements .pylint . $(VIRTUALENV_DIR)/bin/activate; pylint -E --rcfile=./lint-configs/python/.pylintrc packs/fixtures/actions/scripts/*/*.py || exit 1; . $(VIRTUALENV_DIR)/bin/activate; pylint -E --rcfile=./lint-configs/python/.pylintrc packs/fixtures/sensors/*.py || exit 1; . $(VIRTUALENV_DIR)/bin/activate; pylint -E --rcfile=./lint-configs/python/.pylintrc packs/asserts/actions/*.py || exit 1; - + .PHONY: flake8 flake8: requirements .flake8 @@ -107,8 +107,8 @@ requirements: virtualenv # Install requirements for req in $(REQUIREMENTS); do \ - echo "Installing $$req..." ; \ - $(VIRTUALENV_DIR)/bin/pip install $(PIP_OPTIONS) -r $$req ; \ + echo "Installing $$req..." ; \ + $(VIRTUALENV_DIR)/bin/pip install $(PIP_OPTIONS) -r $$req ; \ done .PHONY: virtualenv @@ -117,7 +117,7 @@ $(VIRTUALENV_DIR)/bin/activate: @echo @echo "==================== virtualenv ====================" @echo - test -d $(VIRTUALENV_DIR) || virtualenv $(VIRTUALENV_DIR) + test -d $(VIRTUALENV_DIR) || python3 -m venv $(VIRTUALENV_DIR) # Setup PYTHONPATH in bash activate script... echo '' >> $(VIRTUALENV_DIR)/bin/activate @@ -140,3 +140,17 @@ $(VIRTUALENV_DIR)/bin/activate: echo ' functions -e old_deactivate' >> $(VIRTUALENV_DIR)/bin/activate.fish echo 'end' >> $(VIRTUALENV_DIR)/bin/activate.fish touch $(VIRTUALENV_DIR)/bin/activate.fish + +.PHONY: piptools +piptools: virtualenv + @echo + @echo "================== Install pip-tools ====================" + @echo + "$(VIRTUALENV_DIR)/bin/pip" install pip-tools + +.PHONY: generate_requirements +generate_requirements: piptools + @echo + @echo "================== Generate requirements file ====================" + @echo + "$(VIRTUALENV_DIR)/bin/pip-compile" --output-file=$(ROOT_DIR)/test-requirements-$(PYTHON_VERSION).txt $(ROOT_DIR)/test-requirements.in diff --git a/README.md b/README.md index 942ced8..e944863 100644 --- a/README.md +++ b/README.md @@ -36,3 +36,9 @@ For example: git subtree pull --prefix test_helpers/bats-assert https://github.com/ztombol/bats-assert.git master --squash git subtree pull --prefix test_helpers/bats-support https://github.com/ztombol/bats-support.git master --squash ``` + +## Supported Python versions + +StackStorm supports mulitple versions of python across numerous GNU/Linux distributions. To define python dependencies in a +reproducible fashion, the `pip-compile` tool is used to resolve dependencies from the `requirements.in` file. The requirements +are kept up to date with the `st2` repository and should be regenerated when requirements are updated. diff --git a/test-requirements-3.10.txt b/test-requirements-3.10.txt new file mode 100644 index 0000000..e572173 --- /dev/null +++ b/test-requirements-3.10.txt @@ -0,0 +1,82 @@ +# +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: +# +# pip-compile --output-file=/root/workspace/st2tests/test-requirements-3.10.txt /root/workspace/st2tests/test-requirements.in +# +aiohappyeyeballs==2.6.1 + # via aiohttp +aiohttp==3.12.15 + # via slackclient +aiosignal==1.4.0 + # via aiohttp +astroid==3.1.0 + # via pylint +async-timeout==5.0.1 + # via aiohttp +attrs==25.3.0 + # via + # aiohttp + # pytest +dill==0.4.0 + # via pylint +flake8==7.0.0 + # via -r /root/workspace/st2tests/test-requirements.in +frozenlist==1.7.0 + # via + # aiohttp + # aiosignal +idna==3.10 + # via yarl +iniconfig==2.1.0 + # via pytest +isort==5.13.2 + # via pylint +mccabe==0.7.0 + # via + # flake8 + # pylint +multidict==6.6.4 + # via + # aiohttp + # yarl +packaging==25.0 + # via pytest +platformdirs==4.3.8 + # via pylint +pluggy==1.6.0 + # via pytest +propcache==0.3.2 + # via + # aiohttp + # yarl +py==1.11.0 + # via pytest +pycodestyle==2.11.1 + # via flake8 +pyflakes==3.2.0 + # via flake8 +pylint==3.1.1 + # via -r /root/workspace/st2tests/test-requirements.in +pytest==7.0.1 + # via -r /root/workspace/st2tests/test-requirements.in +slackclient==2.9.4 + # via -r /root/workspace/st2tests/test-requirements.in +tomli==2.2.1 + # via + # pylint + # pytest +tomlkit==0.13.3 + # via pylint +typing-extensions==4.14.1 + # via + # aiosignal + # astroid + # multidict +wheel==0.45.1 + # via -r /root/workspace/st2tests/test-requirements.in +yarl==1.20.1 + # via aiohttp + +# The following packages are considered to be unsafe in a requirements file: +# setuptools diff --git a/test-requirements-3.11.txt b/test-requirements-3.11.txt new file mode 100644 index 0000000..cc0721e --- /dev/null +++ b/test-requirements-3.11.txt @@ -0,0 +1,75 @@ +# +# This file is autogenerated by pip-compile with Python 3.11 +# by the following command: +# +# pip-compile --output-file=/root/workspace/st2tests/test-requirements-3.11.txt /root/workspace/st2tests/test-requirements.in +# +aiohappyeyeballs==2.6.1 + # via aiohttp +aiohttp==3.12.15 + # via slackclient +aiosignal==1.4.0 + # via aiohttp +astroid==3.1.0 + # via pylint +attrs==25.3.0 + # via + # aiohttp + # pytest +dill==0.4.0 + # via pylint +flake8==7.0.0 + # via -r /root/workspace/st2tests/test-requirements.in +frozenlist==1.7.0 + # via + # aiohttp + # aiosignal +idna==3.10 + # via yarl +iniconfig==2.1.0 + # via pytest +isort==5.13.2 + # via pylint +mccabe==0.7.0 + # via + # flake8 + # pylint +multidict==6.6.4 + # via + # aiohttp + # yarl +packaging==25.0 + # via pytest +platformdirs==4.3.8 + # via pylint +pluggy==1.6.0 + # via pytest +propcache==0.3.2 + # via + # aiohttp + # yarl +py==1.11.0 + # via pytest +pycodestyle==2.11.1 + # via flake8 +pyflakes==3.2.0 + # via flake8 +pylint==3.1.1 + # via -r /root/workspace/st2tests/test-requirements.in +pytest==7.0.1 + # via -r /root/workspace/st2tests/test-requirements.in +slackclient==2.9.4 + # via -r /root/workspace/st2tests/test-requirements.in +tomli==2.2.1 + # via pytest +tomlkit==0.13.3 + # via pylint +typing-extensions==4.14.1 + # via aiosignal +wheel==0.45.1 + # via -r /root/workspace/st2tests/test-requirements.in +yarl==1.20.1 + # via aiohttp + +# The following packages are considered to be unsafe in a requirements file: +# setuptools diff --git a/test-requirements-3.8.txt b/test-requirements-3.8.txt new file mode 100644 index 0000000..e2484f9 --- /dev/null +++ b/test-requirements-3.8.txt @@ -0,0 +1,80 @@ +# +# This file is autogenerated by pip-compile with Python 3.8 +# by the following command: +# +# pip-compile --output-file=/root/workspace/st2tests/test-requirements-3.8.txt /root/workspace/st2tests/test-requirements.in +# +aiohappyeyeballs==2.4.4 + # via aiohttp +aiohttp==3.10.11 + # via slackclient +aiosignal==1.3.1 + # via aiohttp +astroid==3.1.0 + # via pylint +async-timeout==5.0.1 + # via aiohttp +attrs==25.3.0 + # via + # aiohttp + # pytest +dill==0.4.0 + # via pylint +flake8==7.0.0 + # via -r /root/workspace/st2tests/test-requirements.in +frozenlist==1.5.0 + # via + # aiohttp + # aiosignal +idna==3.10 + # via yarl +iniconfig==2.1.0 + # via pytest +isort==5.13.2 + # via pylint +mccabe==0.7.0 + # via + # flake8 + # pylint +multidict==6.1.0 + # via + # aiohttp + # yarl +packaging==25.0 + # via pytest +platformdirs==4.3.6 + # via pylint +pluggy==1.5.0 + # via pytest +propcache==0.2.0 + # via yarl +py==1.11.0 + # via pytest +pycodestyle==2.11.1 + # via flake8 +pyflakes==3.2.0 + # via flake8 +pylint==3.1.1 + # via -r /root/workspace/st2tests/test-requirements.in +pytest==7.0.1 + # via -r /root/workspace/st2tests/test-requirements.in +slackclient==2.9.4 + # via -r /root/workspace/st2tests/test-requirements.in +tomli==2.2.1 + # via + # pylint + # pytest +tomlkit==0.13.3 + # via pylint +typing-extensions==4.13.2 + # via + # astroid + # multidict + # pylint +wheel==0.45.1 + # via -r /root/workspace/st2tests/test-requirements.in +yarl==1.15.2 + # via aiohttp + +# The following packages are considered to be unsafe in a requirements file: +# setuptools diff --git a/test-requirements-3.9.txt b/test-requirements-3.9.txt new file mode 100644 index 0000000..784dc5c --- /dev/null +++ b/test-requirements-3.9.txt @@ -0,0 +1,83 @@ +# +# This file is autogenerated by pip-compile with Python 3.9 +# by the following command: +# +# pip-compile --output-file=/root/workspace/st2tests/test-requirements-3.9.txt /root/workspace/st2tests/test-requirements.in +# +aiohappyeyeballs==2.6.1 + # via aiohttp +aiohttp==3.12.15 + # via slackclient +aiosignal==1.4.0 + # via aiohttp +astroid==3.1.0 + # via pylint +async-timeout==5.0.1 + # via aiohttp +attrs==25.3.0 + # via + # aiohttp + # pytest +dill==0.4.0 + # via pylint +flake8==7.0.0 + # via -r /root/workspace/st2tests/test-requirements.in +frozenlist==1.7.0 + # via + # aiohttp + # aiosignal +idna==3.10 + # via yarl +iniconfig==2.1.0 + # via pytest +isort==5.13.2 + # via pylint +mccabe==0.7.0 + # via + # flake8 + # pylint +multidict==6.6.4 + # via + # aiohttp + # yarl +packaging==25.0 + # via pytest +platformdirs==4.3.8 + # via pylint +pluggy==1.6.0 + # via pytest +propcache==0.3.2 + # via + # aiohttp + # yarl +py==1.11.0 + # via pytest +pycodestyle==2.11.1 + # via flake8 +pyflakes==3.2.0 + # via flake8 +pylint==3.1.1 + # via -r /root/workspace/st2tests/test-requirements.in +pytest==7.0.1 + # via -r /root/workspace/st2tests/test-requirements.in +slackclient==2.9.4 + # via -r /root/workspace/st2tests/test-requirements.in +tomli==2.2.1 + # via + # pylint + # pytest +tomlkit==0.13.3 + # via pylint +typing-extensions==4.14.1 + # via + # aiosignal + # astroid + # multidict + # pylint +wheel==0.45.1 + # via -r /root/workspace/st2tests/test-requirements.in +yarl==1.20.1 + # via aiohttp + +# The following packages are considered to be unsafe in a requirements file: +# setuptools diff --git a/test-requirements.in b/test-requirements.in index ea5a622..5d57b19 100644 --- a/test-requirements.in +++ b/test-requirements.in @@ -1,6 +1,6 @@ -configparser==5.0.2 -enum34==1.1.10 -flake8==3.8.4 -pylint==2.7.2 -slackclient==2.9.3 -wheel==0.36.2 +flake8==7.0.0 +pylint==3.1.1 +pytest==7.0.1 +slackclient +wheel==0.45.1 +setuptools==75.3.2 diff --git a/test-requirements.txt b/test-requirements.txt deleted file mode 100644 index e71ba82..0000000 --- a/test-requirements.txt +++ /dev/null @@ -1,67 +0,0 @@ -# -# This file is autogenerated by pip-compile -# To update, run: -# -# pip-compile --output-file=test-requirements.txt test-requirements.in -# -aiohttp==3.7.4 - # via slackclient -astroid==2.5.1 - # via pylint -async-timeout==3.0.1 - # via aiohttp -attrs==20.3.0 - # via aiohttp -chardet==3.0.4 - # via aiohttp -configparser==5.0.2 - # via -r test-requirements.in -enum34==1.1.10 - # via -r test-requirements.in -flake8==3.8.4 - # via -r test-requirements.in -idna-ssl==1.1.0 - # via aiohttp -idna==3.1 - # via - # idna-ssl - # yarl -importlib-metadata==3.7.0 - # via flake8 -isort==5.7.0 - # via pylint -lazy-object-proxy==1.5.2 - # via astroid -mccabe==0.6.1 - # via - # flake8 - # pylint -multidict==5.1.0 - # via - # aiohttp - # yarl -pycodestyle==2.6.0 - # via flake8 -pyflakes==2.2.0 - # via flake8 -pylint==2.7.2 - # via -r test-requirements.in -slackclient==2.9.3 - # via -r test-requirements.in -toml==0.10.2 - # via pylint -typed-ast==1.4.2 - # via astroid -typing-extensions==3.7.4.3 - # via - # aiohttp - # importlib-metadata - # yarl -wheel==0.36.2 - # via -r test-requirements.in -wrapt==1.12.1 - # via astroid -yarl==1.6.3 - # via aiohttp -zipp==3.4.0 - # via importlib-metadata