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(tests): Create a test to check whether requirements.txt was generated with pip-compile #11495

Open
hbelmiro opened this issue Jan 2, 2025 · 5 comments · May be fixed by #11512
Open

chore(tests): Create a test to check whether requirements.txt was generated with pip-compile #11495

hbelmiro opened this issue Jan 2, 2025 · 5 comments · May be fixed by #11512
Assignees

Comments

@hbelmiro
Copy link
Contributor

hbelmiro commented Jan 2, 2025

Chore description

Create a test to check whether requirements.txt was generated with pip-compile. That can be achieved by running pip-compile and comparing the result with the existing requirements.txt.
This test should be run only when a requirements.in or a requirements.txt file is modified.

Labels

/area testing


Love this idea? Give it a 👍.

@chahatsagarmain
Copy link

@hbelmiro I would like to work on this , Please assign this to me .

@mahdikhashan
Copy link

i would like to work on this.

/assign

@mahdikhashan
Copy link

@hbelmiro shall i keep the test in the test dir in the root? and may i use python/pytest for it? are there requirements for it to be add to the ci?

@hbelmiro
Copy link
Contributor Author

hbelmiro commented Jan 13, 2025

@mahdikhashan You can just create a bash script in https://github.com/kubeflow/pipelines/tree/master/.github/resources/scripts and call it from the CI. It can be something like:

# Generate a temporary file for comparison
temp_file=$(mktemp)

# Generate requirements.txt using pip-compile
pip-compile --output-file=- requirements.in > "$temp_file"

# Compare the generated file with the existing requirements.txt
if diff -q "$temp_file" requirements.txt >/dev/null; then
  echo "Success: requirements.txt matches the output of pip-compile."
  rm "$temp_file"
  exit 0
else
  echo "Error: requirements.txt does not match the output of pip-compile."
  echo "Differences:"
  diff "$temp_file" requirements.txt
  rm "$temp_file"
  exit 1
fi

Please check all occurrences of requirements.in/requirements.txt in the test.

find . -name "requirements.in"
./test/sample-test/requirements.in
./test/kfp-functional-test/requirements.in
./backend/metadata_writer/requirements.in
./backend/requirements.in
./backend/src/apiserver/visualization/requirements.in
./sdk/python/requirements.in

@mahdikhashan
Copy link

mahdikhashan commented Jan 14, 2025

@hbelmiro i need to create a new workflow file for it, right? otherwise, in which workflow shall i add it - probably as a job?

and in my test, i need to make sure the bash script is running in the root of the repo so that it can find all requirements in all nested directories. please correct me if i'm wrong. thanks for your time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants