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 #11512

Closed
Show file tree
Hide file tree
Changes from 13 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
40 changes: 40 additions & 0 deletions .github/resources/scripts/test-requirements.sh
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 --output-file=- "$req_in" > "$temp_file"

# 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 .github/workflows/requirements-txt-automatically-generated.yaml
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: |
./.github/resources/scripts/test-requirements.sh
14 changes: 3 additions & 11 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# This file is autogenerated by pip-compile with Python 3.7
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile --output-file=- -
# pip-compile --resolver=backtracking
#
cachetools==5.3.1
# via google-auth
Expand Down Expand Up @@ -41,10 +41,8 @@ googleapis-common-protos==1.60.0
# via google-api-core
idna==3.4
# via requests
importlib-metadata==6.7.0
# via click
kfp==2.0.1
# via -r -
# via -r requirements.in
kfp-pipeline-spec==0.2.2
# via kfp
kfp-server-api==2.0.1
Expand Down Expand Up @@ -93,10 +91,6 @@ six==1.16.0
# python-dateutil
tabulate==0.9.0
# via kfp
typing-extensions==4.7.1
# via
# importlib-metadata
# kfp
urllib3==1.26.16
# via
# google-auth
Expand All @@ -106,8 +100,6 @@ urllib3==1.26.16
# requests
websocket-client==1.6.1
# via kubernetes
zipp==3.15.0
# via importlib-metadata

# The following packages are considered to be unsafe in a requirements file:
# setuptools
Loading
Loading