From bb51fd1497a37b123707eb4ac3e9b888055da945 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Fri, 18 Jul 2025 09:28:36 +0100 Subject: [PATCH 01/10] Modify update PR script --- .github/workflows/dependency-updater-test.yml | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 .github/workflows/dependency-updater-test.yml diff --git a/.github/workflows/dependency-updater-test.yml b/.github/workflows/dependency-updater-test.yml new file mode 100644 index 000000000..c48d0ec50 --- /dev/null +++ b/.github/workflows/dependency-updater-test.yml @@ -0,0 +1,85 @@ +name: Update dependencies + +on: + pull_request: + +jobs: + update-dependencies: + name: Update dependencies + runs-on: ubuntu-latest + + permissions: + contents: write + pull-requests: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v5 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.11" + + - name: Set up poetry + run: uv pip install poetry --system + + - name: Update dependencies + id: update + run: | + # Run the update command + make update + + # Check if there are changes + if [[ -z $(git status --porcelain) ]]; then + echo "No changes detected" + echo "changes_detected=false" >> $GITHUB_OUTPUT + else + echo "Changes detected" + echo "changes_detected=true" >> $GITHUB_OUTPUT + fi + + - name: Run tests + if: steps.update.outputs.changes_detected == 'true' + run: | + # Add your test command here + make test + # or: pytest + # or: uv run pytest + + - name: Create pull request + if: steps.update.outputs.changes_detected == 'true' + run: | + # Configure git + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + + # Create and push branch + git checkout -b update-dependencies + git add . + git commit -m "Update dependencies" + git push origin update-dependencies --force + + # Create or update PR + if gh pr view update-dependencies --json number > /dev/null 2>&1; then + echo "PR already exists, updating..." + gh pr edit update-dependencies --body "Automated dependency updates + + This PR was automatically created by the dependency update workflow. + + Last updated: $(date)" + else + echo "Creating new PR..." + gh pr create \ + --title "Update dependencies" \ + --body "Automated dependency updates + + This PR was automatically created by the dependency update workflow." \ + --base main \ + --head update-dependencies + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 7ab6700ff11e3affcc118bb41fb89aa62f44ffe7 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Fri, 18 Jul 2025 09:31:03 +0100 Subject: [PATCH 02/10] Fix syntax --- .github/workflows/dependency-updater-test.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/dependency-updater-test.yml b/.github/workflows/dependency-updater-test.yml index c48d0ec50..f0d74a296 100644 --- a/.github/workflows/dependency-updater-test.yml +++ b/.github/workflows/dependency-updater-test.yml @@ -1,4 +1,4 @@ -name: Update dependencies +name: Update Dependencies on: pull_request: @@ -67,17 +67,17 @@ jobs: if gh pr view update-dependencies --json number > /dev/null 2>&1; then echo "PR already exists, updating..." gh pr edit update-dependencies --body "Automated dependency updates - - This PR was automatically created by the dependency update workflow. - - Last updated: $(date)" + + This PR was automatically created by the dependency update workflow. + + Last updated: $(date)" else echo "Creating new PR..." gh pr create \ --title "Update dependencies" \ --body "Automated dependency updates - - This PR was automatically created by the dependency update workflow." \ + + This PR was automatically created by the dependency update workflow." \ --base main \ --head update-dependencies fi From 7f89d1cd840b28c4cf20b58805830362294f4982 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Fri, 18 Jul 2025 09:32:08 +0100 Subject: [PATCH 03/10] Remove test bit --- .github/workflows/dependency-updater-test.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/dependency-updater-test.yml b/.github/workflows/dependency-updater-test.yml index f0d74a296..1583d9b8d 100644 --- a/.github/workflows/dependency-updater-test.yml +++ b/.github/workflows/dependency-updater-test.yml @@ -42,14 +42,6 @@ jobs: echo "changes_detected=true" >> $GITHUB_OUTPUT fi - - name: Run tests - if: steps.update.outputs.changes_detected == 'true' - run: | - # Add your test command here - make test - # or: pytest - # or: uv run pytest - - name: Create pull request if: steps.update.outputs.changes_detected == 'true' run: | From 50c98b369e772b97ceffbe93c0d1be055e317c74 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Fri, 18 Jul 2025 10:31:11 +0100 Subject: [PATCH 04/10] Add token update --- .github/workflows/dependency-updater-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dependency-updater-test.yml b/.github/workflows/dependency-updater-test.yml index 1583d9b8d..8e4025bdb 100644 --- a/.github/workflows/dependency-updater-test.yml +++ b/.github/workflows/dependency-updater-test.yml @@ -74,4 +74,4 @@ jobs: --head update-dependencies fi env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.POLICYENGINE_BOT_TOKEN }} \ No newline at end of file From 50f6a92b20078337b575b698ca3750d64880984c Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Fri, 18 Jul 2025 10:56:09 +0100 Subject: [PATCH 05/10] Modify script --- .github/workflows/dependency-updater-test.yml | 32 +++++++------------ 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/.github/workflows/dependency-updater-test.yml b/.github/workflows/dependency-updater-test.yml index 8e4025bdb..9bcc1f83b 100644 --- a/.github/workflows/dependency-updater-test.yml +++ b/.github/workflows/dependency-updater-test.yml @@ -45,33 +45,23 @@ jobs: - name: Create pull request if: steps.update.outputs.changes_detected == 'true' run: | - # Configure git - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global user.name "policyengine-auto" + git config --global user.email "policyengine-auto@users.noreply.github.com" - # Create and push branch git checkout -b update-dependencies git add . git commit -m "Update dependencies" git push origin update-dependencies --force - # Create or update PR - if gh pr view update-dependencies --json number > /dev/null 2>&1; then - echo "PR already exists, updating..." - gh pr edit update-dependencies --body "Automated dependency updates - + # Try to create PR, ignore if it already exists + gh pr create \ + --title "Update dependencies" \ + --body "Automated dependency updates + This PR was automatically created by the dependency update workflow. - Last updated: $(date)" - else - echo "Creating new PR..." - gh pr create \ - --title "Update dependencies" \ - --body "Automated dependency updates - - This PR was automatically created by the dependency update workflow." \ - --base main \ - --head update-dependencies - fi + Last updated: $(date)" \ + --base main \ + --head update-dependencies || echo "PR may already exist, continuing..." env: - GITHUB_TOKEN: ${{ secrets.POLICYENGINE_BOT_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} \ No newline at end of file From c5586a9354cac0b37ff37b5bcdf28c8819b539df Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Fri, 18 Jul 2025 11:02:41 +0100 Subject: [PATCH 06/10] Rename --- .github/workflows/dependency-updater-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dependency-updater-test.yml b/.github/workflows/dependency-updater-test.yml index 9bcc1f83b..cc0218788 100644 --- a/.github/workflows/dependency-updater-test.yml +++ b/.github/workflows/dependency-updater-test.yml @@ -1,11 +1,11 @@ -name: Update Dependencies +name: Update dependencies on: pull_request: jobs: update-dependencies: - name: Update dependencies + name: File update PR runs-on: ubuntu-latest permissions: From 08577cd206cf85969531e274de519926bd3a2bb7 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Fri, 18 Jul 2025 11:06:22 +0100 Subject: [PATCH 07/10] Use correct token --- .github/workflows/dependency-updater-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dependency-updater-test.yml b/.github/workflows/dependency-updater-test.yml index cc0218788..531bf8139 100644 --- a/.github/workflows/dependency-updater-test.yml +++ b/.github/workflows/dependency-updater-test.yml @@ -64,4 +64,4 @@ jobs: --base main \ --head update-dependencies || echo "PR may already exist, continuing..." env: - GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.POLICYENGINE_BOT_TOKEN }} \ No newline at end of file From 955bb4c10dad77ac5ca4c1e1306449ea69adb089 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Fri, 18 Jul 2025 11:15:02 +0100 Subject: [PATCH 08/10] Update action --- .github/workflows/dependency-updater-test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/dependency-updater-test.yml b/.github/workflows/dependency-updater-test.yml index 531bf8139..8cac672ed 100644 --- a/.github/workflows/dependency-updater-test.yml +++ b/.github/workflows/dependency-updater-test.yml @@ -15,6 +15,11 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 + # Checkout main branch + with: + ref: main + env: + GITHUB_TOKEN: ${{ secrets.POLICYENGINE_BOT_TOKEN }} - name: Install uv uses: astral-sh/setup-uv@v5 From 7bc11d9df3e3e3cffda9fcfe859e484a52151828 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Fri, 18 Jul 2025 11:20:13 +0100 Subject: [PATCH 09/10] Add test action --- .github/workflows/pr.yml | 4 +++- Makefile | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index adbbb7b80..dd4fbd23d 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -18,7 +18,7 @@ env: COMMIT_TAG: ${{ github.sha }} jobs: build: - name: Build + name: Build and test # Any runner supporting Node 20 or newer runs-on: ubuntu-latest environment: beta @@ -47,3 +47,5 @@ jobs: architecture: x64 - name: Build application run: make build + - name: Run tests + run: make test diff --git a/Makefile b/Makefile index dcd0478ea..b0f1d5970 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,11 @@ update: $(MAKE) -C $$dir update; \ done +test: + for dir in $(SUBDIRS); do \ + $(MAKE) -C $$dir test; \ + done + dev-api-full: echo "Starting API (full) in dev mode" cd projects/policyengine-api-full && make dev From 9758d31fa1bb6aa4aa67af16ca4ff576dedd9f2d Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Fri, 18 Jul 2025 11:24:04 +0100 Subject: [PATCH 10/10] Move to main action --- .github/workflows/dependency-updater-test.yml | 72 ------------------- .github/workflows/dependency-updater.yml | 46 +++++++----- 2 files changed, 30 insertions(+), 88 deletions(-) delete mode 100644 .github/workflows/dependency-updater-test.yml diff --git a/.github/workflows/dependency-updater-test.yml b/.github/workflows/dependency-updater-test.yml deleted file mode 100644 index 8cac672ed..000000000 --- a/.github/workflows/dependency-updater-test.yml +++ /dev/null @@ -1,72 +0,0 @@ -name: Update dependencies - -on: - pull_request: - -jobs: - update-dependencies: - name: File update PR - runs-on: ubuntu-latest - - permissions: - contents: write - pull-requests: write - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - # Checkout main branch - with: - ref: main - env: - GITHUB_TOKEN: ${{ secrets.POLICYENGINE_BOT_TOKEN }} - - - name: Install uv - uses: astral-sh/setup-uv@v5 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: "3.11" - - - name: Set up poetry - run: uv pip install poetry --system - - - name: Update dependencies - id: update - run: | - # Run the update command - make update - - # Check if there are changes - if [[ -z $(git status --porcelain) ]]; then - echo "No changes detected" - echo "changes_detected=false" >> $GITHUB_OUTPUT - else - echo "Changes detected" - echo "changes_detected=true" >> $GITHUB_OUTPUT - fi - - - name: Create pull request - if: steps.update.outputs.changes_detected == 'true' - run: | - git config --global user.name "policyengine-auto" - git config --global user.email "policyengine-auto@users.noreply.github.com" - - git checkout -b update-dependencies - git add . - git commit -m "Update dependencies" - git push origin update-dependencies --force - - # Try to create PR, ignore if it already exists - gh pr create \ - --title "Update dependencies" \ - --body "Automated dependency updates - - This PR was automatically created by the dependency update workflow. - - Last updated: $(date)" \ - --base main \ - --head update-dependencies || echo "PR may already exist, continuing..." - env: - GITHUB_TOKEN: ${{ secrets.POLICYENGINE_BOT_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/dependency-updater.yml b/.github/workflows/dependency-updater.yml index 3a0bf70b6..9cb5a346c 100644 --- a/.github/workflows/dependency-updater.yml +++ b/.github/workflows/dependency-updater.yml @@ -1,14 +1,14 @@ -name: Update Dependencies +name: Update dependencies on: schedule: - # Run every hour - - cron: '0 * * * *' + # Run every 15 minutes + - cron: '*/15 * * * *' workflow_dispatch: # Allow manual triggering jobs: update-dependencies: - name: Update dependencies + name: File update PR runs-on: ubuntu-latest permissions: @@ -18,6 +18,11 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 + # Checkout main branch + with: + ref: main + env: + GITHUB_TOKEN: ${{ secrets.POLICYENGINE_BOT_TOKEN }} - name: Install uv uses: astral-sh/setup-uv@v5 @@ -47,15 +52,24 @@ jobs: - name: Create pull request if: steps.update.outputs.changes_detected == 'true' - uses: peter-evans/create-pull-request@v5 - with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: Update dependencies - branch: update-dependencies - base: main - delete-branch: true - title: "Update dependencies" - body: | - Automated dependency updates - - This PR was automatically created by the dependency update workflow. \ No newline at end of file + run: | + git config --global user.name "policyengine-auto" + git config --global user.email "policyengine-auto@users.noreply.github.com" + + git checkout -b update-dependencies + git add . + git commit -m "Update dependencies" + git push origin update-dependencies --force + + # Try to create PR, ignore if it already exists + gh pr create \ + --title "Update dependencies" \ + --body "Automated dependency updates + + This PR was automatically created by the dependency update workflow. + + Last updated: $(date)" \ + --base main \ + --head update-dependencies || echo "PR may already exist, continuing..." + env: + GITHUB_TOKEN: ${{ secrets.POLICYENGINE_BOT_TOKEN }} \ No newline at end of file