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

chore(testing): fail the build if the git tree is dirty #5701

Merged
merged 23 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
9 changes: 5 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ commands:
description: "Install riot"
steps:
# Make sure we install and run riot on Python 3
- run: pip3 install riot==0.17.2
- run: pip3 install riot==0.17.3

save_pip_cache:
description: "Save pip cache directory"
Expand Down Expand Up @@ -145,9 +145,9 @@ commands:
DD_TRACE_AGENT_URL: http://localhost:9126
RIOT_RUN_RECOMPILE_REQS: "<< pipeline.parameters.riot_run_latest >>"
command: |
mv .riot .ddriot
# Sort the hashes to ensure a consistent ordering/division between each node
riot list --hash-only '<<parameters.pattern>>' | sort | circleci tests split | xargs -n 1 -I {} ./scripts/ddtest riot -v run --exitfirst --pass-env -s {} $([[ << pipeline.parameters.coverage >> == false ]] && echo '--no-cov' )
./scripts/check-diff "Changes detected after running riot. Consider deleting changed files, running scripts/compile-and-prune-test-requirements and committing the result."
- unless:
condition:
<< parameters.snapshot >>
Expand All @@ -166,6 +166,7 @@ commands:
command: |
# Sort the hashes to ensure a consistent ordering/division between each node
riot list --hash-only '<<parameters.pattern>>' | sort | circleci tests split | xargs -n 1 -I {} riot -v run --exitfirst --pass-env -s {} $([[ << pipeline.parameters.coverage >> == false ]] && echo '--no-cov' )
./scripts/check-diff "Changes detected after running riot. Consider deleting changed files, running scripts/compile-and-prune-test-requirements and committing the result."
- save_pip_cache
- when:
condition:
Expand Down Expand Up @@ -422,9 +423,9 @@ jobs:
environment:
RIOT_RUN_RECOMPILE_REQS: "<< pipeline.parameters.riot_run_latest >>"
command: |
mv .riot .ddriot
# Sort the hashes to ensure a consistent ordering/division between each node
riot list --hash-only 'integration-latest' | sort | circleci tests split | xargs -n 1 -I {} ./scripts/ddtest riot -v run --pass-env -s {}
./scripts/check-diff "Changes detected after running riot. Consider deleting changed files, running scripts/compile-and-prune-test-requirements and committing the result."

integration_testagent:
<<: *machine_executor
Expand Down Expand Up @@ -661,8 +662,8 @@ jobs:
environment:
RIOT_RUN_RECOMPILE_REQS: "<< pipeline.parameters.riot_run_latest >>"
command: |
mv .riot .ddriot
./scripts/ddtest riot -v run --pass-env -s 'gunicorn'
./scripts/check-diff "Changes detected after running riot. Consider deleting changed files, running scripts/compile-and-prune-test-requirements and committing the result."

httplib:
<<: *machine_executor
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ coverage.json
*,cover
.hypothesis/
.pytest_cache/
test.db
.benchmarks/**/*.json

# Translations
*.mo
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ services:
- ddagent:/tmp/ddagent
- ./:/root/project
- ./.ddtox:/root/project/.tox
- ./.ddriot:/root/project/.riot
- ./.riot:/root/project/.riot

localstack:
image: localstack/localstack:1.4.0
Expand Down
8 changes: 6 additions & 2 deletions scripts/check-diff
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#!/bin/bash

message=${1:-"Unexpected files changed or added"}
message=${1:-"Files were changed or added."}
changed_files="$(git diff)"
new_files="$(git ls-files -o --exclude-standard)"

if [[ "$(git diff --exit-code)" || ! -z "$(git ls-files -o --exclude-standard)" ]]
if [[ "$(git diff --exit-code)" || -n $new_files ]]
then
echo "${changed_files}"
echo "${new_files}"
echo "${message}"
exit 1
fi
3 changes: 2 additions & 1 deletion scripts/ddtest
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ fi
# retry docker pull if fails
for i in {1..3}; do docker-compose pull -q testrunner && break || sleep 3; done

FULL_CMD="pip install -q --disable-pip-version-check riot==0.17.2 && $CMD"
FULL_CMD="pip install -q --disable-pip-version-check riot==0.17.3 && $CMD"


# install and upgrade riot in case testrunner image has not been updated
# DEV: Use `--no-TTY` and `--quiet-pull` when running in CircleCI
Expand Down