diff --git a/.circleci/config.yml b/.circleci/config.yml index 1df5f8f80d6cc..62554531bd918 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -99,7 +99,7 @@ jobs: SQS_PROVIDER: "elasticmq" TEST_PATH: "tests/integration/test_sns.py -k test_publish_sqs_from_sns_with_xray_propagation" PYTEST_ARGS: "--junitxml=target/reports/elasticmq.xml -o junit_suite_name='elasticmq'" - command: make test + command: make test - store_test_results: path: target/reports/ @@ -128,7 +128,14 @@ jobs: [[ "$cid" != "" ]] || { echo "could not create build container"; exit 1; } docker cp ${cid}:/opt/code/localstack/target/test-report.xml target/reports || true - docker cp ${cid}:/opt/code/localstack/.coverage target/ || true + docker cp ${cid}:/opt/code/localstack/.coverage ./ || true + when: always + - run: + name: Report coverage statistics + command: | + source .venv/bin/activate + coverage report || true + coveralls || true when: always - run: command: | @@ -147,6 +154,8 @@ jobs: machine: image: ubuntu-2004:202101-01 working_directory: /tmp/workspace/repo + environment: + COVERALLS_REPO_TOKEN: D9Tg4c2TGmHUBQIWbixm9NtIosNUDJeRo steps: - attach_workspace: at: /tmp/workspace @@ -157,6 +166,7 @@ jobs: name: Push docker image command: make docker-push-master + workflows: main: jobs: diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000000000..4edd7b1a20b22 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,2 @@ +[run] +relative_files = True diff --git a/.coveralls.yml b/.coveralls.yml index 31b64e137d0cc..8769460ed0047 100644 --- a/.coveralls.yml +++ b/.coveralls.yml @@ -1,2 +1,2 @@ -service_name: travis-ci +service_name: circleci repo_token: D9Tg4c2TGmHUBQIWbixm9NtIosNUDJeRo diff --git a/Dockerfile b/Dockerfile index 2fb022a16cd6e..f0bb16c1981af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -95,11 +95,12 @@ RUN ES_BASE_DIR=localstack/infra/elasticsearch; \ # run tests (to verify the build before pushing the image) ADD tests/ tests/ +ADD .coveragerc ./ # fixes a dependency issue with pytest and python3.7 https://github.com/pytest-dev/pytest/issues/5594 RUN pip uninstall -y argparse RUN LAMBDA_EXECUTOR=local \ PYTEST_ARGS='--junitxml=target/test-report.xml' \ - make test + make test-coverage # clean up temporary files created during test execution RUN apk del --purge git cmake gcc musl-dev libc-dev; \ diff --git a/Makefile b/Makefile index 62a96e5c882bc..be9daa7bb9f70 100644 --- a/Makefile +++ b/Makefile @@ -149,6 +149,12 @@ test: make lint && \ ($(VENV_RUN); DEBUG=$(DEBUG) pytest --durations=10 --log-cli-level=$(PYTEST_LOGLEVEL) -s $(PYTEST_ARGS) $(TEST_PATH)) +test-coverage: + ($(VENV_RUN); coverage --version; \ + DEBUG=$(DEBUG) \ + coverage run --source=localstack/ --omit=localstack/infra/,localstack/node_modules/ \ + -m pytest --durations=10 --log-cli-level=$(PYTEST_LOGLEVEL) -s $(PYTEST_ARGS) $(TEST_PATH)) + test-docker: ENTRYPOINT="--entrypoint=" CMD="make test" make docker-run @@ -196,4 +202,4 @@ clean: ## Clean up (npm dependencies, downloaded infrastructure code rm -rf $(VENV_DIR) rm -f localstack/utils/kinesis/java/com/atlassian/*.class -.PHONY: usage compile clean install web install-web infra test +.PHONY: usage compile clean install web install-web infra test test-coverage diff --git a/requirements.txt b/requirements.txt index 0290ae6bd98d2..87a16ce0eaeac 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,7 +18,9 @@ boto3>=1.14.33 #basic-lib botocore>=1.12.13 cachetools>=3.1.1,<4.0.0 cbor2>=5.2.0 -#coverage>=5.2.1 +# coverage version should be synced with bin/Dockerfile.base +coverage>=5.5 +coveralls==3.1.0 crontab>=0.22.6 # pin version to avoid Rust build issues: https://github.com/pyca/cryptography/issues/5771 cryptography<3.4 @@ -43,9 +45,7 @@ psutil>=5.4.8,<6.0.0 pympler>=0.6 pyopenssl==17.5.0 pytest==6.2.4 -#pytest-cov==2.12.1 pytest-rerunfailures==10.0 -#python-coveralls>=2.9.1 pyyaml>=5.1 #basic-lib Quart>=0.6.15 requests>=2.20.0 #basic-lib