-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into huiling-lvm
- Loading branch information
Showing
65 changed files
with
917 additions
and
390 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,38 @@ | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
name: Freeze-requirements | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
freeze-requirements: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
ref: ${{ github.ref }} | ||
|
||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
|
||
- name: Set up Git | ||
run: | | ||
git config --global user.name "NeuralChatBot" | ||
git config --global user.email "grp_neural_chat_bot@intel.com" | ||
git remote set-url origin https://NeuralChatBot:"${{ secrets.ACTION_TOKEN }}"@github.com/opea-project/GenAIComps.git | ||
- name: Run script | ||
run: | | ||
bash .github/workflows/scripts/freeze_requirements.sh | ||
- name: Commit changes | ||
run: | | ||
git add . | ||
git commit -m "Freeze requirements" | ||
git push |
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,59 @@ | ||
#!/bin/bash | ||
|
||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
function freeze() { | ||
local file=$1 | ||
local folder=$(dirname "$file") | ||
local keep_origin_packages="true" | ||
echo "::group::Check $file ..." | ||
pip-compile \ | ||
--no-upgrade \ | ||
--no-annotate \ | ||
--no-header \ | ||
--output-file "$folder/freeze.txt" \ | ||
"$file" | ||
echo "::endgroup::" | ||
if [[ -e "$folder/freeze.txt" ]]; then | ||
if [[ "$keep_origin_packages" == "true" ]]; then | ||
sed -i '/^\s*#/d; s/#.*//; /^\s*$/d' "$file" | ||
sed -i '/^\s*#/d; s/#.*//; /^\s*$/d' "$folder/freeze.txt" | ||
|
||
packages1=$(cut -d'=' -f1 "$file" | tr '[:upper:]' '[:lower:]' | sed 's/[-_]/-/g') | ||
packages2=$(cut -d'=' -f1 "$folder/freeze.txt" | tr '[:upper:]' '[:lower:]' | sed 's/[-_]/-/g') | ||
common_packages=$(comm -12 <(echo "$packages2" | sort) <(echo "$packages1" | sort)) | ||
|
||
rm "$file" | ||
while IFS= read -r line; do | ||
package=$(echo "$line" | cut -d'=' -f1) | ||
package_transformed=$(echo "$package" | tr '[:upper:]' '[:lower:]' | sed 's/[_-]/-/g') | ||
pattern=$(echo "$package_transformed" | sed 's/\[/\\\[/g; s/\]/\\\]/g') | ||
if echo "$common_packages" | grep -q "^$pattern$"; then | ||
echo "$line" >>"$file" | ||
fi | ||
done <"$folder/freeze.txt" | ||
rm "$folder/freeze.txt" | ||
else | ||
mv "$folder/freeze.txt" "$file" | ||
fi | ||
fi | ||
} | ||
|
||
function check_branch_name() { | ||
if [[ "$GITHUB_REF_NAME" == "main" ]]; then | ||
echo "$GITHUB_REF_NAME is protected branch" | ||
exit 0 | ||
else | ||
echo "branch name is $GITHUB_REF_NAME" | ||
fi | ||
} | ||
|
||
function main() { | ||
check_branch_name | ||
echo "::group::pip install pip-tools" && pip install pip-tools --upgrade && echo "::endgroup::" | ||
export -f freeze | ||
find . -name "requirements.txt" | xargs -n 1 -I {} bash -c 'freeze "$@"' _ {} | ||
} | ||
|
||
main |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
__pycache__ | ||
*.egg-info/ |
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
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.