From ff4e77176d2025ee4e53defdbbded7619a60ca4c Mon Sep 17 00:00:00 2001 From: Max Alcala Date: Fri, 15 Mar 2024 16:03:12 -0300 Subject: [PATCH 1/7] chore: add downstream workflow calls manually --- .github/workflows/lint.yml | 1 + .github/workflows/pre-commit-autoupdate.yml | 11 +++++++++++ .github/workflows/test.yml | 1 + 3 files changed, 13 insertions(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 26c1274b..ecceefe1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -10,6 +10,7 @@ on: - main - develop merge_group: + workflow_call: concurrency: group: (${{ github.workflow }}-${{ github.event.inputs.branch || github.event.pull_request.head.ref }}) diff --git a/.github/workflows/pre-commit-autoupdate.yml b/.github/workflows/pre-commit-autoupdate.yml index a08844b3..a6d134fa 100644 --- a/.github/workflows/pre-commit-autoupdate.yml +++ b/.github/workflows/pre-commit-autoupdate.yml @@ -14,6 +14,17 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 - uses: browniebroke/pre-commit-autoupdate-action@main + - name: Check for changes + id: git-check + run: | + git diff --exit-code || echo "::set-output name=modified::true" + continue-on-error: true + - name: lint on diff + if: steps.git-check.outputs.modified == 'true' + uses: ./github/workflows/lint.yml + - name: run tests on diff + if: steps.git-check.outputs.modified == 'true' + uses: ./github/workflows/test.yml - uses: peter-evans/create-pull-request@v6 with: token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a3173b81..92427e6b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,6 +14,7 @@ on: - develop - "[0-9]+.[0-9]+.x" merge_group: + workflow_call: concurrency: group: ${{ github.workflow }}-${{ github.ref }} From 797ff7c657a3fb077cb9dec5484076a6eb9ef632 Mon Sep 17 00:00:00 2001 From: Max Alcala Date: Mon, 18 Mar 2024 09:01:36 -0300 Subject: [PATCH 2/7] chore: trigger action for testing --- .github/workflows/pre-commit-autoupdate.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pre-commit-autoupdate.yml b/.github/workflows/pre-commit-autoupdate.yml index a6d134fa..1d6a6ae1 100644 --- a/.github/workflows/pre-commit-autoupdate.yml +++ b/.github/workflows/pre-commit-autoupdate.yml @@ -6,6 +6,7 @@ on: - cron: "0 0 * * *" # on demand workflow_dispatch: + push: jobs: auto-update: From b60cab2a0d023aabb526ce27540f8a1a32bce4b2 Mon Sep 17 00:00:00 2001 From: Max Alcala Date: Mon, 18 Mar 2024 09:08:47 -0300 Subject: [PATCH 3/7] fix: typo --- .github/workflows/pre-commit-autoupdate.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pre-commit-autoupdate.yml b/.github/workflows/pre-commit-autoupdate.yml index 1d6a6ae1..61721faa 100644 --- a/.github/workflows/pre-commit-autoupdate.yml +++ b/.github/workflows/pre-commit-autoupdate.yml @@ -22,10 +22,10 @@ jobs: continue-on-error: true - name: lint on diff if: steps.git-check.outputs.modified == 'true' - uses: ./github/workflows/lint.yml + uses: ./.github/workflows/lint.yml - name: run tests on diff if: steps.git-check.outputs.modified == 'true' - uses: ./github/workflows/test.yml + uses: ./.github/workflows/test.yml - uses: peter-evans/create-pull-request@v6 with: token: ${{ secrets.GITHUB_TOKEN }} From 037523a8dfaed6fc2e5ec7fbaf5650ddf305138c Mon Sep 17 00:00:00 2001 From: Max Alcala Date: Mon, 18 Mar 2024 09:36:37 -0300 Subject: [PATCH 4/7] chore: separate jobs with dependency --- .github/workflows/pre-commit-autoupdate.yml | 48 ++++++++++++++++----- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/.github/workflows/pre-commit-autoupdate.yml b/.github/workflows/pre-commit-autoupdate.yml index 61721faa..9e74e235 100644 --- a/.github/workflows/pre-commit-autoupdate.yml +++ b/.github/workflows/pre-commit-autoupdate.yml @@ -11,25 +11,51 @@ on: jobs: auto-update: runs-on: ubuntu-latest + outputs: + diff: ${{ steps.check-diff.outputs.diff }} steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 - uses: browniebroke/pre-commit-autoupdate-action@main - - name: Check for changes - id: git-check - run: | - git diff --exit-code || echo "::set-output name=modified::true" - continue-on-error: true - - name: lint on diff - if: steps.git-check.outputs.modified == 'true' - uses: ./.github/workflows/lint.yml - - name: run tests on diff - if: steps.git-check.outputs.modified == 'true' - uses: ./.github/workflows/test.yml + # - name: Check for changes + # id: git-check + # run: | + # git diff --exit-code || echo "::set-output name=modified::true" + # continue-on-error: true + # - name: lint on diff + # if: steps.git-check.outputs.modified == 'true' + # uses: ./.github/workflows/lint.yml + # - name: run tests on diff + # if: steps.git-check.outputs.modified == 'true' + # uses: ./.github/workflows/test.yml - uses: peter-evans/create-pull-request@v6 + id: pr-create with: token: ${{ secrets.GITHUB_TOKEN }} branch: update/pre-commit-hooks title: Update pre-commit hooks commit-message: "chore: update pre-commit hooks" body: Update versions of pre-commit hooks to latest version. + # output is called pull-request-operation + - name: Set outputs + id: check-diff + if: | + steps.pr-create.outputs.pull-request-number && + (steps.pr-create.outputs.pull-request-operation == 'created' || + steps.pr-create.outputs.pull-request-operation == 'updated') + run: echo "diff=true" >> "$GITHUB_OUTPUT" + + lint-workflow: + name: Run lint + uses: ./.github/workflows/lint.yml + if: ${{ needs.auto-update.outputs.diff }} + runs-on: ubuntu-latest + needs: auto-update + + + test-workflow: + name: run tests on diff + uses: ./.github/workflows/test.yml + if: ${{ needs.auto-update.outputs.diff }} + runs-on: ubuntu-latest + needs: auto-update From 1d81df78f3aa1c988e050bb8cf596278626a543b Mon Sep 17 00:00:00 2001 From: Max Alcala Date: Mon, 18 Mar 2024 09:38:38 -0300 Subject: [PATCH 5/7] chore: spacing --- .github/workflows/pre-commit-autoupdate.yml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pre-commit-autoupdate.yml b/.github/workflows/pre-commit-autoupdate.yml index 9e74e235..55b537e8 100644 --- a/.github/workflows/pre-commit-autoupdate.yml +++ b/.github/workflows/pre-commit-autoupdate.yml @@ -35,11 +35,12 @@ jobs: branch: update/pre-commit-hooks title: Update pre-commit hooks commit-message: "chore: update pre-commit hooks" - body: Update versions of pre-commit hooks to latest version. + body: + Update versions of pre-commit hooks to latest version. # output is called pull-request-operation - name: Set outputs id: check-diff - if: | + if: | steps.pr-create.outputs.pull-request-number && (steps.pr-create.outputs.pull-request-operation == 'created' || steps.pr-create.outputs.pull-request-operation == 'updated') @@ -47,15 +48,12 @@ jobs: lint-workflow: name: Run lint - uses: ./.github/workflows/lint.yml - if: ${{ needs.auto-update.outputs.diff }} - runs-on: ubuntu-latest needs: auto-update - + if: ${{ needs.auto-update.outputs.diff }} + uses: ./.github/workflows/lint.yml test-workflow: name: run tests on diff - uses: ./.github/workflows/test.yml - if: ${{ needs.auto-update.outputs.diff }} - runs-on: ubuntu-latest needs: auto-update + if: ${{ needs.auto-update.outputs.diff }} + uses: ./.github/workflows/test.yml From 397c7b44d9721a0ac804912bcee6cc7c7a32d975 Mon Sep 17 00:00:00 2001 From: Max Alcala Date: Mon, 18 Mar 2024 09:51:48 -0300 Subject: [PATCH 6/7] chore: clean up envs --- .github/workflows/pre-commit-autoupdate.yml | 22 +++++++-------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/.github/workflows/pre-commit-autoupdate.yml b/.github/workflows/pre-commit-autoupdate.yml index 55b537e8..c63ff986 100644 --- a/.github/workflows/pre-commit-autoupdate.yml +++ b/.github/workflows/pre-commit-autoupdate.yml @@ -17,17 +17,6 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 - uses: browniebroke/pre-commit-autoupdate-action@main - # - name: Check for changes - # id: git-check - # run: | - # git diff --exit-code || echo "::set-output name=modified::true" - # continue-on-error: true - # - name: lint on diff - # if: steps.git-check.outputs.modified == 'true' - # uses: ./.github/workflows/lint.yml - # - name: run tests on diff - # if: steps.git-check.outputs.modified == 'true' - # uses: ./.github/workflows/test.yml - uses: peter-evans/create-pull-request@v6 id: pr-create with: @@ -37,14 +26,17 @@ jobs: commit-message: "chore: update pre-commit hooks" body: Update versions of pre-commit hooks to latest version. - # output is called pull-request-operation - name: Set outputs id: check-diff if: | - steps.pr-create.outputs.pull-request-number && (steps.pr-create.outputs.pull-request-operation == 'created' || - steps.pr-create.outputs.pull-request-operation == 'updated') - run: echo "diff=true" >> "$GITHUB_OUTPUT" + steps.pr-create.outputs.pull-request-operation == 'updated') && + steps.pr-create.outputs.pull-request-number + run: | + echo "diff=true" >> "$GITHUB_OUTPUT" + echo "PR status: ${{ steps.pr-create.outputs.pull-request-operation }}" + echo "PR number: ${{ steps.pr-create.outputs.pull-request-number }}" + echo "Running workflows for ${{ steps.pr-create.outputs.pull-request-url }}" lint-workflow: name: Run lint From ed828d39f3ed12e6e023e20c459f48b59c3880b4 Mon Sep 17 00:00:00 2001 From: Max Alcala Date: Mon, 18 Mar 2024 10:03:44 -0300 Subject: [PATCH 7/7] chore: cleanup --- .github/workflows/pre-commit-autoupdate.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/pre-commit-autoupdate.yml b/.github/workflows/pre-commit-autoupdate.yml index c63ff986..4634c6ee 100644 --- a/.github/workflows/pre-commit-autoupdate.yml +++ b/.github/workflows/pre-commit-autoupdate.yml @@ -6,7 +6,6 @@ on: - cron: "0 0 * * *" # on demand workflow_dispatch: - push: jobs: auto-update: @@ -24,8 +23,7 @@ jobs: branch: update/pre-commit-hooks title: Update pre-commit hooks commit-message: "chore: update pre-commit hooks" - body: - Update versions of pre-commit hooks to latest version. + body: Update versions of pre-commit hooks to latest version. - name: Set outputs id: check-diff if: |