-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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(tests): create a test to check whether requirements.txt
was generated with pip-compile
#11512
Closed
mahdikhashan
wants to merge
17
commits into
kubeflow:master
from
mahdikhashan:test-to-check-whether-requirements-txt-was-generated-with-pip-compile
Closed
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b8d50b8
init
mahdikhashan d669f38
add test-requirements.sh and ci file
mahdikhashan d23c23a
update .github/workflows/requirements-test.yaml
mahdikhashan a8bdb49
update .github/workflows/requirements-test.yaml
mahdikhashan 150a93c
rename ci workflow file
mahdikhashan 74c7342
fix renaming issue
mahdikhashan d9e935a
fix execute permission
mahdikhashan 042f6de
Merge branch 'kubeflow:master' into test-to-check-whether-requirement…
mahdikhashan d0e5244
update requirements in test/sample-test
mahdikhashan 4b6d44f
update requirements in test/kfp-functional-test
mahdikhashan 69f4940
update requirements in backend
mahdikhashan ee978e1
update requirements in sdk/python
mahdikhashan 6fbfc08
update requirements in backend/src/apiserver/visualization
mahdikhashan 019fca9
generate requirements.txt with '# via -r -' annotation for dependencies
mahdikhashan e6b4709
add backtracking as resolver
mahdikhashan abec4b6
update requirements in backend/src/apiserver/visulization
mahdikhashan ce7f54c
use make command to run tests in ci
mahdikhashan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env bash | ||
|
||
check_requirements() { | ||
local req_in="$1" | ||
local req_txt="$2" | ||
|
||
temp_file=$(mktemp) | ||
|
||
pip-compile - < "$req_in" --output-file="$temp_file" --annotate --resolver=backtracking | ||
|
||
# Compare the generated file with the existing requirements.txt | ||
if diff -q "$temp_file" "$req_txt" >/dev/null; then | ||
echo "Success: $req_txt matches the output of pip-compile for $req_in." | ||
rm "$temp_file" | ||
exit 0 | ||
else | ||
echo "Error: $req_txt does not match the output of pip-compile for $req_in." | ||
echo "Differences:" | ||
diff "$temp_file" "$req_txt" | ||
rm "$temp_file" | ||
exit 1 | ||
fi | ||
} | ||
|
||
for req_in_file in $(find . -name "requirements.in"); do | ||
|
||
echo $req_in_file | ||
req_txt="${req_in_file/requirements.in/requirements.txt}" | ||
|
||
# Check if the corresponding requirements.txt exists | ||
if [[ -f "$req_txt" ]]; then | ||
echo "Checking $req_in_file against $req_txt..." | ||
check_requirements "$req_in_file" "$req_txt" | ||
else | ||
echo "Error: $req_txt not found for $req_in_file." | ||
exit 1 | ||
fi | ||
done | ||
|
||
echo "All checks completed successfully." |
30 changes: 30 additions & 0 deletions
30
.github/workflows/requirements-txt-automatically-generated.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: requirements.txt automatically generated | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
|
||
pull_request: | ||
paths: | ||
- '.github/workflows/requirements-txt-automatically-generated.yaml' | ||
|
||
jobs: | ||
requirements-generated-tests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.9 | ||
|
||
- name: Install pip-tools | ||
run: | | ||
pip3 install pip-tools | ||
|
||
- name: Run Tests | ||
run: | | ||
make test-requirements | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to create this target. Please name it
test-requirements-txt-automatically-generated
.Also, follow the same pattern as in #11509, with a setup target. You'll have to create the
Makefile.setup.mk
file, in case that PR is not merged yet.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, i'll follow your guideline.