-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test-requirements.sh and ci file
- Loading branch information
1 parent
bef7c34
commit 02fc4c7
Showing
2 changed files
with
72 additions
and
0 deletions.
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 --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." |
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,32 @@ | ||
name: Requirements generated tests | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
|
||
pull_request: | ||
paths: | ||
- 'test/**' | ||
- 'backend/**' | ||
- 'sdk/**' | ||
|
||
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 |