Skip to content

Commit

Permalink
pull out finalize step into it's wn workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
bdemann committed Oct 29, 2024
1 parent 4843f21 commit f738121
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 121 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
73 changes: 5 additions & 68 deletions .github/workflows/benchmark_parallel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
required: false
type: string
default: ''
azle-version:
required: true
type: string

secrets:
GPG_SIGNING_KEY:
required: true
Expand All @@ -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:
Expand Down Expand Up @@ -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 }}
79 changes: 79 additions & 0 deletions .github/workflows/finalize_changes.yml
Original file line number Diff line number Diff line change
@@ -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 }}
67 changes: 14 additions & 53 deletions .github/workflows/release_parallel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f738121

Please sign in to comment.