From f9171fbff725e057515865ee1a85efc980297821 Mon Sep 17 00:00:00 2001 From: Anthony Volk Date: Thu, 19 Sep 2024 15:58:37 +0200 Subject: [PATCH 1/7] fix: Update changelogging method --- .github/workflows/pull_request.yaml | 7 +++ .github/workflows/push_1.yaml | 42 +++++++++++++ .github/workflows/{push.yaml => push_2.yaml} | 64 ++++---------------- changelog_entry.yaml | 5 ++ 4 files changed, 65 insertions(+), 53 deletions(-) create mode 100644 .github/workflows/push_1.yaml rename .github/workflows/{push.yaml => push_2.yaml} (66%) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 6d39d38..1e55a1c 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -1,3 +1,10 @@ +# This workflow is used to check various parts of the +# run prior to merging: + +# - The code's formatting +# - Versioning - note that this checks, but does not update +# - That the code builds successfully +# - That any automated tests pass name: Pull request on: diff --git a/.github/workflows/push_1.yaml b/.github/workflows/push_1.yaml new file mode 100644 index 0000000..4f73a15 --- /dev/null +++ b/.github/workflows/push_1.yaml @@ -0,0 +1,42 @@ +# This builds and pushes the changelog, then +# automatically runs push_2 using the new version number +# to allow for proper pushing to PyPI. + +# This script must run first and complete to allow for +# proper versioning. + +name: Push 1 + +on: + push: + branches: [main] + +jobs: + check-version: + name: Check version + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch all history for all tags and branches + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.event.pull_request.head.ref }} + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.12 + - name: Build changelog + run: pip install "yaml-changelog>=0.1.7" && make changelog + - name: Preview changelog update + run: ".github/get-changelog-diff.sh" + - name: Check version number has been properly updated + run: ".github/is-version-number-acceptable.sh" + - name: Update changelog + uses: EndBug/add-and-commit@v9 + with: + add: "." + committer_name: Github Actions[bot] + author_name: Github Actions[bot] + message: Update PolicyEngine US data + github_token: ${{ secrets.POLICYENGINE_GITHUB }} \ No newline at end of file diff --git a/.github/workflows/push.yaml b/.github/workflows/push_2.yaml similarity index 66% rename from .github/workflows/push.yaml rename to .github/workflows/push_2.yaml index 13b8612..a3ace69 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push_2.yaml @@ -1,16 +1,15 @@ -name: Push +# After successful versioning, this +name: Push 2 on: - push: - branches: [main] - workflow_dispatch: + workflow_run: + workflows: [Push 1] + types: [completed] jobs: lint: runs-on: ubuntu-latest - if: | - (github.repository == 'PolicyEngine/policyengine-us-data') - && (github.event.head_commit.message == 'Update PolicyEngine US data') + if: ${{ github.event.workflow_run.conclusion == 'success' }} name: Lint steps: - uses: actions/checkout@v4 @@ -24,43 +23,10 @@ jobs: pip install black - name: Check formatting run: black . -l 79 --check - check-version: - name: Check version - runs-on: ubuntu-latest - if: | - (github.repository == 'PolicyEngine/policyengine-us-data') - && !(github.event.head_commit.message == 'Update PolicyEngine US data') - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Fetch all history for all tags and branches - repository: ${{ github.event.pull_request.head.repo.full_name }} - ref: ${{ github.event.pull_request.head.ref }} - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: 3.12 - - name: Build changelog - run: pip install "yaml-changelog>=0.1.7" && make changelog - - name: Preview changelog update - run: ".github/get-changelog-diff.sh" - - name: Check version number has been properly updated - run: ".github/is-version-number-acceptable.sh" - - name: Update changelog - uses: EndBug/add-and-commit@v9 - with: - add: "." - committer_name: Github Actions[bot] - author_name: Github Actions[bot] - message: Update PolicyEngine US data - github_token: ${{ secrets.POLICYENGINE_GITHUB }} test: name: Build and test runs-on: ubuntu-latest - if: | - (github.repository == 'PolicyEngine/policyengine-us-data') - && (github.event.head_commit.message == 'Update PolicyEngine US data') + if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - name: Checkout code uses: actions/checkout@v4 @@ -87,9 +53,7 @@ jobs: publish-to-pypi: name: Publish to PyPI runs-on: ubuntu-latest - if: | - (github.repository == 'PolicyEngine/policyengine-us-data') - && (github.event.head_commit.message == 'Update PolicyEngine US data') + if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - name: Checkout code uses: actions/checkout@v4 @@ -114,9 +78,7 @@ jobs: docker: name: Docker runs-on: ubuntu-latest - if: | - (github.repository == 'PolicyEngine/policyengine-us-data') - && (github.event.head_commit.message == 'Update PolicyEngine US data') + if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - name: Checkout repo uses: actions/checkout@v4 @@ -133,9 +95,7 @@ jobs: publish-docs: name: Publish documentation runs-on: ubuntu-latest - if: | - (github.repository == 'PolicyEngine/policyengine-us-data') - && (github.event.head_commit.message == 'Update PolicyEngine US data') + if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - name: Checkout code uses: actions/checkout@v4 @@ -159,9 +119,7 @@ jobs: name: Upload data runs-on: ubuntu-latest needs: [lint, test] - if: | - (github.repository == 'PolicyEngine/policyengine-us-data') - && (github.event.head_commit.message == 'Update PolicyEngine US data') + if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - name: Checkout code uses: actions/checkout@v4 diff --git a/changelog_entry.yaml b/changelog_entry.yaml index e69de29..f2922bd 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -0,0 +1,5 @@ +- bump: patch + changes: + changed: + - Split push actions into two separate files + - Made run of second portion of push conditional upon run of first \ No newline at end of file From 59c507a771563cc857f713be0fa031ed9c07067b Mon Sep 17 00:00:00 2001 From: Anthony Volk Date: Thu, 19 Sep 2024 16:26:09 +0200 Subject: [PATCH 2/7] test: Briefly reverse push and PR to verify code works --- .github/workflows/pull_request.yaml | 3 ++- .github/workflows/push_1.yaml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 1e55a1c..16b926c 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -8,7 +8,8 @@ name: Pull request on: - pull_request: + # pull_request: + push: branches: [main] jobs: diff --git a/.github/workflows/push_1.yaml b/.github/workflows/push_1.yaml index 4f73a15..03f939c 100644 --- a/.github/workflows/push_1.yaml +++ b/.github/workflows/push_1.yaml @@ -8,7 +8,8 @@ name: Push 1 on: - push: + # push: + pull_request: branches: [main] jobs: From a07ce7f35c9aeb71c707bc74496b06017259ad27 Mon Sep 17 00:00:00 2001 From: Anthony Volk Date: Thu, 19 Sep 2024 16:27:57 +0200 Subject: [PATCH 3/7] test: Ensure lint always runs for testing purposes --- .github/workflows/push_2.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_2.yaml b/.github/workflows/push_2.yaml index a3ace69..79accab 100644 --- a/.github/workflows/push_2.yaml +++ b/.github/workflows/push_2.yaml @@ -9,7 +9,7 @@ on: jobs: lint: runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' }} + # if: ${{ github.event.workflow_run.conclusion == 'success' }} name: Lint steps: - uses: actions/checkout@v4 From 0def59e29c1dc02870a4dfd18c58bc62e1ea4de4 Mon Sep 17 00:00:00 2001 From: Anthony Volk Date: Thu, 19 Sep 2024 16:31:43 +0200 Subject: [PATCH 4/7] test: See if quotation marks are necessary --- .github/workflows/push_2.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_2.yaml b/.github/workflows/push_2.yaml index 79accab..c68ca12 100644 --- a/.github/workflows/push_2.yaml +++ b/.github/workflows/push_2.yaml @@ -3,7 +3,7 @@ name: Push 2 on: workflow_run: - workflows: [Push 1] + workflows: ["Push 1"] types: [completed] jobs: From f0c1f4ebc556129ef12e62e63b8c90caf5d674f7 Mon Sep 17 00:00:00 2001 From: Anthony Volk Date: Thu, 19 Sep 2024 17:19:45 +0200 Subject: [PATCH 5/7] test: Try manually dispatching --- .github/workflows/push_2.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/push_2.yaml b/.github/workflows/push_2.yaml index c68ca12..0aa304d 100644 --- a/.github/workflows/push_2.yaml +++ b/.github/workflows/push_2.yaml @@ -5,6 +5,7 @@ on: workflow_run: workflows: ["Push 1"] types: [completed] + workflow_dispatch: jobs: lint: From c417b54cd0a551bbb690e1567d2bbc495780f442 Mon Sep 17 00:00:00 2001 From: Anthony Volk Date: Thu, 19 Sep 2024 17:29:23 +0200 Subject: [PATCH 6/7] test: Change commit token --- .github/workflows/push_1.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_1.yaml b/.github/workflows/push_1.yaml index 03f939c..979ce04 100644 --- a/.github/workflows/push_1.yaml +++ b/.github/workflows/push_1.yaml @@ -40,4 +40,4 @@ jobs: committer_name: Github Actions[bot] author_name: Github Actions[bot] message: Update PolicyEngine US data - github_token: ${{ secrets.POLICYENGINE_GITHUB }} \ No newline at end of file + github_token: ${{ secrets.POLICYENGINE_US_DATA_GITHUB_TOKEN }} \ No newline at end of file From fbce19a2c697fd59a339b1bfb3069123bb9194cf Mon Sep 17 00:00:00 2001 From: Anthony Volk Date: Thu, 19 Sep 2024 17:34:31 +0200 Subject: [PATCH 7/7] fix: Revert to non-testing --- .github/workflows/pull_request.yaml | 3 +-- .github/workflows/push_1.yaml | 3 +-- .github/workflows/push_2.yaml | 6 +++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 16b926c..1e55a1c 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -8,8 +8,7 @@ name: Pull request on: - # pull_request: - push: + pull_request: branches: [main] jobs: diff --git a/.github/workflows/push_1.yaml b/.github/workflows/push_1.yaml index 979ce04..5afe806 100644 --- a/.github/workflows/push_1.yaml +++ b/.github/workflows/push_1.yaml @@ -8,8 +8,7 @@ name: Push 1 on: - # push: - pull_request: + push: branches: [main] jobs: diff --git a/.github/workflows/push_2.yaml b/.github/workflows/push_2.yaml index 0aa304d..1ec40d5 100644 --- a/.github/workflows/push_2.yaml +++ b/.github/workflows/push_2.yaml @@ -1,16 +1,16 @@ -# After successful versioning, this +# After successful versioning, this script runs various +# parts of the push process name: Push 2 on: workflow_run: workflows: ["Push 1"] types: [completed] - workflow_dispatch: jobs: lint: runs-on: ubuntu-latest - # if: ${{ github.event.workflow_run.conclusion == 'success' }} + if: ${{ github.event.workflow_run.conclusion == 'success' }} name: Lint steps: - uses: actions/checkout@v4