From f738121ef8f9d9ca487268c016e6ccaba450a7bb Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 29 Oct 2024 12:46:09 -0600 Subject: [PATCH] pull out finalize step into it's wn workflow --- .github/workflows/benchmark.yml | 26 ++++++++ .github/workflows/benchmark_parallel.yml | 73 ++-------------------- .github/workflows/finalize_changes.yml | 79 ++++++++++++++++++++++++ .github/workflows/release_parallel.yml | 67 +++++--------------- 4 files changed, 124 insertions(+), 121 deletions(-) create mode 100644 .github/workflows/finalize_changes.yml diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 8038acf3c3..436853b2cc 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -96,11 +96,25 @@ jobs: EXCLUDE_DIRS=$(echo $EXCLUDE_DIRS | xargs) echo "exclude-dirs=$EXCLUDE_DIRS" >> $GITHUB_OUTPUT + get-version: + name: Get Azle Version + runs-on: ubuntu-latest + outputs: + azle-version: ${{ steps.get-version.outputs.azle-version }} + steps: + - uses: actions/checkout@v4 + + - id: get-version + run: | + VERSION=$(jq -r '.version' package.json) + echo "azle-version=$VERSION" >> $GITHUB_OUTPUT + run-benchmarks: name: ${{ matrix.benchmark_group.name }} needs: - determine-should-run-benchmarks - set-exclude-dirs + - get-version if: ${{ needs.determine-should-run-benchmarks.outputs.should-run-benchmarks == 'true' }} strategy: fail-fast: false @@ -139,3 +153,15 @@ jobs: with: directories: ${{ matrix.benchmark_group.directories }} exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} + azle-version: ${{ needs.get-version.outputs.azle-version }} + + finalize-benchmark: + needs: [run-benchmarks, get-version] + uses: ./.github/workflows/finalize_changes.yml + with: + branch-prefix: 'benchmark--${{ needs.get-version.outputs.azle-version }}-' + commit-message: 'Update all dependencies for benchmark ${{ needs.get-version.outputs.azle-version }}' + secrets: + GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + LASTMJS_GITHUB_TOKEN: ${{ secrets.LASTMJS_GITHUB_TOKEN }} diff --git a/.github/workflows/benchmark_parallel.yml b/.github/workflows/benchmark_parallel.yml index 3a94273c40..6b68b93bdb 100644 --- a/.github/workflows/benchmark_parallel.yml +++ b/.github/workflows/benchmark_parallel.yml @@ -9,6 +9,10 @@ on: required: false type: string default: '' + azle-version: + required: true + type: string + secrets: GPG_SIGNING_KEY: required: true @@ -25,16 +29,11 @@ jobs: GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} # All commits must be verified GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} outputs: - azle-version: ${{ steps.get-version.outputs.azle-version }} + azle-version: ${{ inputs.azle-version }} test-infos: ${{ steps.get-test-infos.outputs.test-infos }} steps: - uses: actions/checkout@v4 - - id: get-version - run: | - VERSION=$(jq -r '.version' package.json) - echo "azle-version=$VERSION" >> $GITHUB_OUTPUT - - id: get-test-infos uses: ./.github/actions/get_test_infos with: @@ -92,65 +91,3 @@ jobs: echo "No changes to commit. Skipping commit and push." fi git push origin "$BRANCH_NAME" - - finalize-benchmark: - needs: [prepare-benchmark, run-benchmarks] - name: Finalize Benchmark - runs-on: ubuntu-latest - env: - GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.ref || github.ref }} - token: ${{ secrets.LASTMJS_GITHUB_TOKEN }} - fetch-depth: 0 - - - uses: ./.github/actions/configure_git - with: - gpg_signing_key: ${{ secrets.GPG_SIGNING_KEY }} - - - name: Collect branches - id: collect-branches - run: | - # Get branches and convert to space-separated list - BRANCHES=$(git branch -r | grep "origin/benchmark--${{ needs.prepare-benchmark.outputs.azle-version }}-" | sed 's/origin\///' | xargs) - echo "branches=$BRANCHES" >> $GITHUB_OUTPUT - - - name: Display collected branches - run: | - echo "Collected branches:" - for branch in ${{ steps.collect-branches.outputs.branches }}; do - echo " - $branch" - done - echo "End of branch list" - - - name: Fetch branches - run: | - echo "Fetching all branches..." - BRANCHES_TO_FETCH="" - for branch in ${{ steps.collect-branches.outputs.branches }}; do - BRANCHES_TO_FETCH+=" $branch:$branch" - done - git fetch origin $BRANCHES_TO_FETCH - - - name: Squash changes - env: - PAT: ${{ secrets.LASTMJS_GITHUB_TOKEN }} - run: | - CURRENT_BRANCH=$(git branch --show-current) - - for branch in ${{ steps.collect-branches.outputs.branches }}; do - git merge --squash $branch - done - - # Create a merge commit with a descriptive message - git commit -am "Update all dependencies for benchmark ${{ needs.prepare-benchmark.outputs.azle-version }}" - - git push origin HEAD:$CURRENT_BRANCH - - - name: Delete branches - run: | - echo "Starting branch deletion process..." - git push origin --delete ${{ steps.collect-branches.outputs.branches }} diff --git a/.github/workflows/finalize_changes.yml b/.github/workflows/finalize_changes.yml new file mode 100644 index 0000000000..738dcaf67d --- /dev/null +++ b/.github/workflows/finalize_changes.yml @@ -0,0 +1,79 @@ +name: Finalize Changes +on: + workflow_call: + inputs: + branch-prefix: + required: true + type: string + commit-message: + required: true + type: string + secrets: + GPG_SIGNING_KEY: + required: true + GH_TOKEN: + required: true + LASTMJS_GITHUB_TOKEN: + required: true + +jobs: + finalize: + name: Finalize Changes + runs-on: ubuntu-latest + env: + GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.ref || github.ref }} + token: ${{ secrets.LASTMJS_GITHUB_TOKEN }} + fetch-depth: 0 + + - uses: ./.github/actions/configure_git + with: + gpg_signing_key: ${{ secrets.GPG_SIGNING_KEY }} + + - name: Collect branches + id: collect-branches + run: | + # Get branches and convert to space-separated list + BRANCHES=$(git branch -r | grep "origin/${{ inputs.branch-prefix }}" | sed 's/origin\///' | xargs) + echo "branches=$BRANCHES" >> $GITHUB_OUTPUT + + - name: Display collected branches + run: | + echo "Collected branches:" + for branch in ${{ steps.collect-branches.outputs.branches }}; do + echo " - $branch" + done + echo "End of branch list" + + - name: Fetch branches + run: | + echo "Fetching all branches..." + BRANCHES_TO_FETCH="" + for branch in ${{ steps.collect-branches.outputs.branches }}; do + BRANCHES_TO_FETCH+=" $branch:$branch" + done + git fetch origin $BRANCHES_TO_FETCH + + - name: Squash changes + env: + PAT: ${{ secrets.LASTMJS_GITHUB_TOKEN }} + run: | + CURRENT_BRANCH=$(git branch --show-current) + + for branch in ${{ steps.collect-branches.outputs.branches }}; do + git merge --squash $branch + done + + # Create a merge commit with a descriptive message + git commit -am "${{ inputs.commit-message }}" + + git push origin HEAD:$CURRENT_BRANCH + + - name: Delete branches + run: | + echo "Starting branch deletion process..." + git push origin --delete ${{ steps.collect-branches.outputs.branches }} diff --git a/.github/workflows/release_parallel.yml b/.github/workflows/release_parallel.yml index 7ed4c13120..b4169f00f2 100644 --- a/.github/workflows/release_parallel.yml +++ b/.github/workflows/release_parallel.yml @@ -129,67 +129,28 @@ jobs: finalize-release: needs: [prepare-release, update-test-files-for-release-commit] - name: Finalize Release - runs-on: ubuntu-latest - env: + uses: ./.github/workflows/finalize_changes.yml + with: + branch-prefix: 'update--${{ needs.prepare-release.outputs.release-version }}-' + commit-message: 'Update test files for all tests and examples ${{ needs.prepare-release.outputs.release-version }}' + secrets: GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.GH_TOKEN }} + LASTMJS_GITHUB_TOKEN: ${{ secrets.LASTMJS_GITHUB_TOKEN }} + + create-release: + needs: [prepare-release, finalize-release] + name: Create Release + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.ref || github.ref }} token: ${{ secrets.LASTMJS_GITHUB_TOKEN }} - fetch-depth: 0 - - - uses: ./.github/actions/configure_git - with: - gpg_signing_key: ${{ secrets.GPG_SIGNING_KEY }} - - - name: Collect branches - id: collect-branches - run: | - # Get branches and convert to space-separated list - BRANCHES=$(git branch -r | grep "origin/update--${{ needs.prepare-release.outputs.release-version }}-" | sed 's/origin\///' | xargs) - echo "branches=$BRANCHES" >> $GITHUB_OUTPUT - - - name: Display collected branches - run: | - echo "Collected branches:" - for branch in ${{ steps.collect-branches.outputs.branches }}; do - echo " - $branch" - done - echo "End of branch list" - - - name: Fetch branches - run: | - echo "Fetching all branches..." - BRANCHES_TO_FETCH="" - for branch in ${{ steps.collect-branches.outputs.branches }}; do - BRANCHES_TO_FETCH+=" $branch:$branch" - done - git fetch origin $BRANCHES_TO_FETCH - - - name: Squash changes - env: - PAT: ${{ secrets.LASTMJS_GITHUB_TOKEN }} - run: | - CURRENT_BRANCH=$(git branch --show-current) - - for branch in ${{ steps.collect-branches.outputs.branches }}; do - git merge --squash $branch - done - - # Create a merge commit with a descriptive message - git commit -am "Update test files for all tests and examples ${{ needs.prepare-release.outputs.release-version }}" - - git push origin HEAD:$CURRENT_BRANCH - - - name: Delete branches - run: | - echo "Starting branch deletion process..." - git push origin --delete ${{ steps.collect-branches.outputs.branches }} - name: Create release + env: + GH_TOKEN: ${{ secrets.GH_TOKEN }} run: | VERSION=${{ needs.prepare-release.outputs.release-version }} git tag $VERSION