-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13a5bdd
commit c07ef66
Showing
4 changed files
with
93 additions
and
240 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,42 +1,97 @@ | ||
name: Automate pdm.lock | ||
|
||
on: | ||
push: | ||
|
||
on: push | ||
|
||
jobs: | ||
backend_changes: | ||
uses: ./.github/workflows/reusable-file-change-check.yaml | ||
with: | ||
file_path: backend/pyproject.toml | ||
|
||
prompt_changes: | ||
uses: ./.github/workflows/reusable-file-change-check.yaml | ||
with: | ||
file_path: prompt-service/pyproject.toml | ||
|
||
root_changes: | ||
uses: ./.github/workflows/reusable-file-change-check.yaml | ||
with: | ||
file_path: pyproject.toml | ||
|
||
update-backend-pdm-lock: | ||
needs: backend_changes | ||
if: ${{ needs.backend_changes.outputs.changed == 'true' }} | ||
uses: ./.github/workflows/reusable-update-pdm-lock.yaml | ||
with: | ||
service: 'backend' | ||
|
||
update-prompt-service-pdm-lock: | ||
needs: prompt_changes | ||
if: ${{ needs.prompt_changes.outputs.changed == 'true' }} | ||
uses: ./.github/workflows/reusable-update-pdm-lock.yaml | ||
with: | ||
service: 'prompt-service' | ||
|
||
update-root-pdm-lock: | ||
needs: root_changes | ||
if: ${{ needs.root_changes.outputs.changed == 'true' }} | ||
uses: ./.github/workflows/reusable-update-pdm-lock.yaml | ||
with: | ||
service: | ||
check_pyproject_changes: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
directory: [backend, prompt-service, root] | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Check file changes | ||
id: check | ||
run: | | ||
if [ "${{ matrix.directory }}" = "root" ]; then | ||
file_path="pyproject.toml" | ||
else | ||
file_path="${{ matrix.directory }}/pyproject.toml" | ||
fi | ||
echo "checking changes for $file_path" | ||
echo "changed=false" >> $GITHUB_ENV | ||
if git diff --quiet main -- $file_path; then | ||
echo "No changes detected in $file_path against main branch." | ||
else | ||
echo "Changes detected in $file_path against main branch." | ||
echo "changed=true" >> $GITHUB_ENV | ||
fi | ||
- name: Set output | ||
id: set_output | ||
run: echo "::set-output name=changed::${{ env.changed }}" | ||
if: always() | ||
|
||
- name: Set up Python | ||
if: steps.set_output.outputs.changed == 'true' | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.9' | ||
|
||
- name: Install PDM | ||
if: steps.set_output.outputs.changed == 'true' | ||
run: python -m pip install pdm | ||
|
||
- name: Update and add pdm.lock | ||
if: steps.set_output.outputs.changed == 'true' | ||
run: | | ||
if [ "${{ matrix.directory }}" != "root" ]; then | ||
cd ${{ matrix.directory }} | ||
fi | ||
echo "current dir before: "; pwd | ||
echo "files in dir before: "; ls -al | ||
if [ ! -d ".venv" ]; then | ||
echo 'Creating virtual environment inside "${{ matrix.directory }}".' | ||
pdm venv create -w virtualenv --with-pip | ||
else | ||
echo "Virtual environment already exists." | ||
fi | ||
source .venv/bin/activate | ||
pdm lock | ||
echo "current dir after: "; pwd | ||
echo "files in dir after: "; ls -al | ||
git add pdm.lock | ||
- name: Running pre-commit and commit pdm.lock | ||
if: steps.set_output.outputs.changed == 'true' | ||
run: | | ||
echo "current root dir: "; pwd | ||
echo "files in root dir: "; ls -al | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
if [ ! -d ".venv" ]; then | ||
echo "Creating virtual environment inside root" | ||
pdm venv create -w virtualenv --with-pip | ||
else | ||
echo "Virtual environment already exists." | ||
fi | ||
source .venv/bin/activate | ||
pip install pre-commit~=3.6.2 | ||
git add .pre-commit-config.yaml | ||
pre-commit run | ||
if [ "${{ matrix.directory }}" != "root" ]; then | ||
git commit -m "Update pdm.lock for ${{ matrix.directory }}" | ||
else | ||
git commit -m "Update pdm.lock for root directory" | ||
fi | ||
# git push |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.