Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python: Add pytest and coverage #15888

Merged
merged 32 commits into from
Apr 11, 2021
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .azure-pipelines/pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,28 @@ stages:
# not all have fixes so improve condition/handling
condition: failed()

- job: tooling
dependsOn: []
pool:
vmImage: "ubuntu-18.04"
steps:
- script: ci/run_envoy_docker.sh 'ci/do_ci.sh tooling'
workingDirectory: $(Build.SourcesDirectory)
env:
ENVOY_DOCKER_BUILD_DIR: $(Build.StagingDirectory)
BAZEL_REMOTE_CACHE: grpcs://remotebuildexecution.googleapis.com
BAZEL_REMOTE_INSTANCE: projects/envoy-ci/instances/default_instance
GCP_SERVICE_ACCOUNT_KEY: $(GcpServiceAccountKey)
displayName: "Run tooling checks"

- script: |
ci/run_envoy_docker.sh 'ci/upload_gcs_artifact.sh /source/generated/tooling tooling'
displayName: "Upload tooling coverage to GCS"
env:
ENVOY_DOCKER_BUILD_DIR: $(Build.StagingDirectory)
GCP_SERVICE_ACCOUNT_KEY: $(GcpServiceAccountKey)
GCS_ARTIFACT_BUCKET: $(GcsArtifactBucket)

- job: format
dependsOn: ["format_pre"]
pool:
Expand Down
10 changes: 10 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[run]
omit =
tools/*

[report]
exclude_lines =
pragma: no cover
raise NotImplementedError
pass
if __name__ == .__main__.:
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,8 @@ updates:
directory: "/configs"
schedule:
interval: "daily"

- package-ecosystem: "pip"
directory: "/tools/testing"
schedule:
interval: "daily"
2 changes: 2 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ exports_files([
"VERSION",
"API_VERSION",
".clang-format",
"pytest.ini",
".coveragerc",
])

# These two definitions exist to help reduce Envoy upstream core code depending on extensions.
Expand Down
12 changes: 12 additions & 0 deletions bazel/repositories_extra.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ load("@proxy_wasm_cpp_host//bazel/cargo:crates.bzl", "proxy_wasm_cpp_host_fetch_
def _python_deps():
py_repositories()

# REMOVE!!!
pip_install(
name = "sometools_pip3",
requirements = "@envoy//tools/sometools:requirements.txt",
extra_pip_args = ["--require-hashes"],
)

pip_install(
name = "config_validation_pip3",
requirements = "@envoy//tools/config_validation:requirements.txt",
Expand Down Expand Up @@ -88,6 +95,11 @@ def _python_deps():
requirements = "@envoy//tools/code_format:requirements.txt",
extra_pip_args = ["--require-hashes"],
)
pip_install(
name = "testing_pip3",
requirements = "@envoy//tools/testing:requirements.txt",
extra_pip_args = ["--require-hashes"],
)
pip_install(
name = "thrift_pip3",
requirements = "@envoy//test/extensions/filters/network/thrift_proxy:requirements.txt",
Expand Down
8 changes: 8 additions & 0 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,14 @@ elif [[ "$CI_TARGET" == "cve_scan" ]]; then
bazel run "${BAZEL_BUILD_OPTIONS[@]}" //tools/dependency:cve_scan_test
bazel run "${BAZEL_BUILD_OPTIONS[@]}" //tools/dependency:cve_scan
exit 0
elif [[ "$CI_TARGET" == "tooling" ]]; then
echo "Run pytest tooling tests..."
htuch marked this conversation as resolved.
Show resolved Hide resolved
bazel run "${BAZEL_BUILD_OPTIONS[@]}" //tools/testing:pytest_python_pytest -- --cov-collect /tmp/.coverage-envoy
bazel run "${BAZEL_BUILD_OPTIONS[@]}" //tools/testing:pytest_python_coverage -- --cov-collect /tmp/.coverage-envoy
bazel run "${BAZEL_BUILD_OPTIONS[@]}" //tools/base:pytest_runner -- --cov-collect /tmp/.coverage-envoy
bazel run "${BAZEL_BUILD_OPTIONS[@]}" //tools/base:pytest_utils -- --cov-collect /tmp/.coverage-envoy
bazel run "${BAZEL_BUILD_OPTIONS[@]}" //tools/testing:python_coverage -- /tmp/.coverage-envoy /source/generated/tooling
exit 0
elif [[ "$CI_TARGET" == "verify_examples" ]]; then
run_ci_verify "*" wasm-cc
exit 0
Expand Down
4 changes: 4 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[pytest]
addopts = -raq --ignore=tools/testing/external/*,__init__.py,testing/conf --color=yes --cov-append -p tools.testing.plugin --cov-config=.coveragerc -vv tools
testpaths =
tests
Loading