diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml deleted file mode 100644 index e921e90b1..000000000 --- a/.github/workflows/main.yaml +++ /dev/null @@ -1,69 +0,0 @@ -name: Update PDM Lock Files - -on: - push: - - -jobs: - backend_changes: - uses: ./.github/workflows/reusable-file-change-check.yaml - with: - file_path: backend/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' - # runs-on: ubuntu-latest - # steps: - # - name: Checkout repository - # uses: actions/checkout@v3 - - # - name: Check backend_changed value - # run: | - # echo "backend_changed value: ${{ needs.backend_changes.outputs.changed }}" - - # - uses: ./.github/workflows/reusable-update-pdm-lock.yaml - # with: - # service: 'backend' - - # update-prompt-service-pdm-lock: - # needs: changes - # if: ${{ needs.changes.outputs.prompt_service_changed == 'true' }} - # - uses: ./.github/workflows/update-pdm-lock.yml - # with: - # service: 'prompt-service' - - # update-platform-service-pdm-lock: - # needs: changes - # if: ${{ needs.changes.outputs.platform_service_changed == 'true' }} - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v3 - # - name: Check platform_service_changed value - # run: | - # echo "platform_service_changed value: ${{ needs.changes.outputs.platform_service_changed }}" - # - uses: ./.github/workflows/update-pdm-lock.yml - # with: - # service: 'platform-service' - - # update-root-pdm-lock: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v3 - # - uses: ./.github/workflows/update-pdm-lock.yml - # with: - # service: '' - - # push-changes: - # needs: [update-backend-pdm-lock, update-prompt-service-pdm-lock, update-platform-service-pdm-lock, update-root-pdm-lock] - # runs-on: ubuntu-latest - # steps: - # - name: Checkout repository - # uses: actions/checkout@v3 - - # - name: Push changes - # run: git push - # if: success() diff --git a/.github/workflows/pdm-lock-automate-build.yaml b/.github/workflows/pdm-lock-automate-build.yaml deleted file mode 100644 index 5b8b4450f..000000000 --- a/.github/workflows/pdm-lock-automate-build.yaml +++ /dev/null @@ -1,77 +0,0 @@ -name: Update PDM Lock Files - -on: - push: - paths: - - '**/pyproject.toml' # Watch for changes in any pyproject.toml file - - -jobs: - update-pdm-lock: - runs-on: ubuntu-latest - - strategy: - matrix: - # service: [backend, prompt-service, platform-service] - service: [backend, prompt-service] - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.9' - - - name: Install PDM - run: python -m pip install pdm - - - - name: Create virtual environment - run: pdm venv create -w virtualenv --with-pip - - - name: Update pdm.lock for ${{ matrix.service }} - run: | - cd ${{ matrix.service }} - pdm venv create -w virtualenv --with-pip - source .venv/bin/activate - pdm lock - - git config --global user.name 'github-actions[bot]' - git config --global user.email 'github-actions[bot]@users.noreply.github.com' - - git add pdm.lock - - # Debugging output - echo "Listing matrix dir name:"; pwd - echo "Listing files in matrix directory:"; ls -al | grep pdm.lock - - - name: Update pdm.lock for root - run: | - source .venv/bin/activate - pdm lock - - git add pdm.lock - - # Debugging output - echo "Listing root dir name:"; pwd - echo "Listing files in root directory:"; ls -al | grep pdm.lock - - - name: Activate virtual environment and install pre-commit - run: | - source .venv/bin/activate - python -m pip install --upgrade pip - pip install pre-commit~=3.6.2 - - - name: Run pre-commit hooks and commit pdm lock changes - run: | - source .venv/bin/activate - git add .pre-commit-config.yaml - pre-commit run - git commit -m "Adding pdm.lock for root directory" - - - name: Push changes - run: | - echo "yes" | git push git@github.com:${{ github.repository }} HEAD:${{ github.ref }} - if: success() diff --git a/.github/workflows/pdm-lock-automation.yaml b/.github/workflows/pdm-lock-automation.yaml new file mode 100644 index 000000000..b086f43ff --- /dev/null +++ b/.github/workflows/pdm-lock-automation.yaml @@ -0,0 +1,53 @@ +name: Update PDM Lock Files + +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: + + # push-changes: + # needs: [update-backend-pdm-lock, update-prompt-service-pdm-lock, update-platform-service-pdm-lock, update-root-pdm-lock] + # runs-on: ubuntu-latest + # steps: + # - name: Checkout repository + # uses: actions/checkout@v3 + + # - name: Push changes + # run: git push + # if: success() diff --git a/.github/workflows/reusable-update-pdm-lock.yaml b/.github/workflows/reusable-update-pdm-lock.yaml index 30aa95f74..2ba8ef4d1 100644 --- a/.github/workflows/reusable-update-pdm-lock.yaml +++ b/.github/workflows/reusable-update-pdm-lock.yaml @@ -25,28 +25,41 @@ jobs: - name: Update and add pdm.lock run: | - echo "inside udpate pdm ${{ inputs.service }}"; if [ -n "${{ inputs.service }}" ]; then cd ${{ inputs.service }} fi - pdm venv create -w virtualenv --with-pip + echo "current dir before : "; pwd + echo "files in dir before : "; ls -al + + if [ ! -d ".venv" ]; then + echo 'Creating virtual environment inside "${{ inputs.service }}".' + pdm venv create -w virtualenv --with-pip + else + echo "Virtual environment already exists." + fi source .venv/bin/activate pdm lock - # Debugging output - echo "curent dir: "; pwd - echo "Listing files in ${{ inputs.service || 'root' }} directory:"; ls -al | grep pdm.lock + echo "current dir after : "; pwd + echo "files in dir after : "; ls -al + git add pdm.lock - - name: Commit pdm.lock + - name: Running pre-commit and commit pdm.lock run: | - echo "Dir: "; pwd - echo "LFiles in ${{ inputs.service || 'root' }} directory:"; ls -al + 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' - pdm venv create -w virtualenv --with-pip + + 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