blob: ce978e61224a8253dce03427f4a2b58b23154634 [file] [log] [blame]
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
[tox]
skipsdist = true
toxworkdir = {toxinidir}/build/.tox
envlist = test
# This is the default test environment; see
# https://tox.readthedocs.io/en/latest/config.html#generating-environments-conditional-settings
# for how we use it for multiple environments; at the moment, these are:
#
# <no env specified>: run noisy linting and tests
# ci: As above, but with settings suitable for jenkins
# lint: run quiet linting and stop
[testenv]
skip_install = true
allowlist_externals =
poetryw
mkdir
passenv =
SSH_AUTH_SOCK
setenv =
BUILD_DIR = {toxinidir}/build/{envname}
RUFF_OPTS =
FLAKE8_OPTS = --count --show-source --statistics
AUTOFLAKE_OPTS = --exclude build --recursive --remove-all-unused-imports
POETRY_OPTS = -v
PYTEST_OPTS =
# Linting should be quiet and fast
lint: RUFF_OPTS = --quiet
lint: FLAKE8_OPTS =
lint: POETRY_OPTS = --quiet --no-root
commands_pre =
./poetryw install {env:POETRY_OPTS}
commands =
ruff check {env:RUFF_OPTS} --diff .
autoflake {env:AUTOFLAKE_OPTS} --check .
isort --check --diff .
flake8 {env:FLAKE8_OPTS}
pre-commit run --all-files --hook-stage pre-push insert-license
!lint: mkdir -p {env:BUILD_DIR}
!lint: pytest --verbose {env:PYTEST_OPTS} {posargs} tests
# The format environment should fix any errors detected by the lint
# environment
[testenv:format]
commands =
ruff check --fix .
autoflake {env:AUTOFLAKE_OPTS} --in-place .
isort .
pre-commit run --all-files --hook-stage pre-push insert-license
# docker-build and docker-push environments; docker-push requires
# RELEASE_VERSION (x.y.z), DOCKER_REGISTRY, DOCKER_REGISTRY_CREDS_USR and
# DOCKER_REGISTR_CREDS_PSW to be set
[testenv:docker-{build,push}]
skip_install = true
allowlist_externals =
docker
passenv =
SSH_AUTH_SOCK
RELEASE_VERSION
DOCKER_REGISTRY
DOCKER_REGISTRY_CREDS_USR
DOCKER_REGISTRY_CREDS_PSW
setenv =
DOCKER_BUILDKIT=1
DOCKER_PROJECT=apache/otava
commands =
docker buildx build --tag {env:DOCKER_PROJECT}:latest --ssh=default .
push: docker image tag {env:DOCKER_PROJECT}:latest {env:DOCKER_PROJECT}:{env:RELEASE_VERSION}
push: docker image tag {env:DOCKER_PROJECT}:{env:RELEASE_VERSION} {env:DOCKER_REGISTRY}/{env:DOCKER_PROJECT}:{env:RELEASE_VERSION}
push: docker image tag {env:DOCKER_PROJECT}:latest {env:DOCKER_REGISTRY}/{env:DOCKER_PROJECT}:latest
push: docker login -u {env:DOCKER_REGISTRY_CREDS_USR} -p {env:DOCKER_REGISTRY_CREDS_PSW} {env:DOCKER_REGISTRY}
push: docker image push {env:DOCKER_REGISTRY}/{env:DOCKER_PROJECT}:{env:RELEASE_VERSION}
push: docker image push {env:DOCKER_REGISTRY}/{env:DOCKER_PROJECT}:latest
[pytest]
# Ensure we do not include BUILD_DIR by explicitly specifying where to search for tests
testpaths =
tests
[flake8]
extend_exclude = build
extend_ignore =
# Black compatibility; see https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#flake8
E203
# Let black determine whether a line is too long
E501