From 0352e1ed70cac76095735874f4fc79cbf64f2ca2 Mon Sep 17 00:00:00 2001 From: Bjorn Neergaard Date: Sun, 24 Mar 2024 21:12:45 -0600 Subject: [PATCH] ci/cirrus: align with gha In particular, run mypy on FreeBSD in a parallel workflow to pytest. Also modernize how we install/set up Poetry, and improve job names. --- .cirrus.yml | 79 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 24 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 0ca40e5825e..f2c94bd2543 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,35 +1,66 @@ freebsd_instance: image_family: freebsd-14-0 + # Cirrus has a concurrency limit of 8 vCPUs for FreeBSD. Allow executing 4 tasks in parallel. cpu: 2 memory: 4G -test_task: - name: "Tests / FreeBSD / " - only_if: $CIRRUS_TAG == '' - skip: "!changesInclude('.cirrus.yml', 'poetry.lock', 'pyproject.toml', 'src/**.py', 'tests/**')" +env: + # SHELL is not set by default, and we have tests that depend on it. + SHELL: sh + # Force pipx to install to /usr/local/bin (and /opt/pipx for environments). + PIPX_BIN_DIR: /usr/local/bin + PIPX_HOME: /opt/pipx + +tests_task: + only_if: ¬_tag $CIRRUS_TAG == '' env: - # `SHELL` environment variable is not set by default, so we explicitly set it to - # avoid failures on tests that depend on it. - SHELL: sh matrix: - PYTHON: python3.8 + PYTHON_VERSION: 3.8 + PYTHON_PACKAGE: python38 - PYTHON: python3.9 + PYTHON_VERSION: 3.9 + PYTHON_PACKAGE: python39 - PYTHON: python3.10 + PYTHON_VERSION: 3.10 + PYTHON_PACKAGE: python310 - PYTHON: python3.11 - install_prereqs_script: - - V=$(printf '%s' $PYTHON | tr -d '.[:alpha:]') - - pkg install -y python${V} py${V}-sqlite3 - install_poetry_script: - - POETRY_HOME=/opt/poetry - - $PYTHON -m venv $POETRY_HOME - - $POETRY_HOME/bin/pip install --upgrade pip setuptools wheel - - $POETRY_HOME/bin/pip install poetry - - echo "PATH=$POETRY_HOME/bin:$PATH" >> $CIRRUS_ENV - install_and_test_script: - - poetry install - - poetry run pytest --junitxml=junit.xml -v - on_failure: - annotate_failure_artifacts: - path: junit.xml - format: junit - type: text/xml + PYTHON_VERSION: 3.11 + PYTHON_PACKAGE: python311 + bootstrap_poetry_script: + # - mkdir -p /usr/local/etc/pkg/repos && echo 'FreeBSD: { url: \"pkg+http://pkg.freebsd.org/\${ABI}/latest\" }' > /usr/local/etc/pkg/repos/FreeBSD.conf + # - pkg update + # - V=$(printf '%s' "$PY" | tr -d '.') + - pkg install -y "$PYTHON_PACKAGE" #py${V}-sqlite3 # devel/py-pipx + # - pipx install poetry + - python -m ensurepip && python -m pip install pipx + - python -m pipx install poetry + - python -m pipx list + setup_environment_script: + - poetry env use "$PYTHON" + - poetry install --sync + - poetry env info + - poetry show + matrix: + - alias: pytest + name: "Tests / pytest [FreeBSD / Python ${PYTHON_VERSION}]" + skip: "!changesInclude('.cirrus.yml', 'poetry.lock', 'pyproject.toml', 'src/**.py', 'tests/**')" + pytest_script: + - poetry run pytest --integration -v --junitxml=junit.xml + on_failure: + annotate_failure_artifacts: + path: junit.xml + format: junit + type: text/xml + - alias: mypy + name: "Tests / mypy [FreeBSD / Python ${PYTHON_VERSION}]" + skip: "!changesInclude('.cirrus.yml', 'poetry.lock', 'pyproject.toml', 'src/**.py')" + mypy_script: + - poetry run mypy + +status_task: + name: "Tests / Status" + only_if: *not_tag + depends_on: + - pytest + - mypy