Skip to content

Commit

Permalink
make commit and push action
Browse files Browse the repository at this point in the history
  • Loading branch information
bdemann committed Oct 29, 2024
1 parent 80b28f9 commit 7e70a09
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 40 deletions.
33 changes: 33 additions & 0 deletions .github/actions/commit_and_push/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Commit and Push Changes
description: 'Configures git, commits changes and pushes to a new branch'
inputs:
branch-name:
description: 'Name of the branch to create'
required: true
commit-message:
description: 'Commit message'
required: true
gpg_signing_key:
description: 'The GPG signing key to use for signing commits'
required: true
runs:
using: composite
steps:
- uses: ./.github/actions/configure_git
with:
gpg_signing_key: ${{ inputs.gpg_signing_key }}

- name: Commit and push changes
shell: bash
run: |
# Create and switch to new branch
git switch -c "${{ inputs.branch-name }}"
# Add and commit changes if there are any
git add --all
if ! git diff --cached --quiet; then
git commit -m "${{ inputs.commit-message }}"
git push origin "${{ inputs.branch-name }}"
else
echo "No changes to commit. Skipping commit and push."
fi
20 changes: 10 additions & 10 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,25 +98,25 @@ jobs:
EXCLUDE_DIRS=$(echo $EXCLUDE_DIRS | xargs)
echo "exclude-dirs=$EXCLUDE_DIRS" >> $GITHUB_OUTPUT
get-version:
name: Get Azle Version
create-branch-prefix:
name: Create Branch Prefix
runs-on: ubuntu-latest
outputs:
azle-version: ${{ steps.get-version.outputs.azle-version }}
branch-prefix: ${{ steps.create-prefix.outputs.branch-prefix }}
steps:
- uses: actions/checkout@v4

- id: get-version
- id: create-prefix
run: |
VERSION=$(jq -r '.version' package.json)
echo "azle-version=$VERSION" >> $GITHUB_OUTPUT
echo "branch-prefix=benchmark--$VERSION-" >> $GITHUB_OUTPUT
run-benchmarks:
name: ${{ matrix.benchmark_group.name }}
needs:
- determine-should-run-benchmarks
- set-exclude-dirs
- get-version
- create-branch-prefix
if: ${{ needs.determine-should-run-benchmarks.outputs.should-run-benchmarks == 'true' }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -155,14 +155,14 @@ jobs:
with:
directories: ${{ matrix.benchmark_group.directories }}
exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }}
azle-version: ${{ needs.get-version.outputs.azle-version }}
branch-prefix: ${{ needs.create-branch-prefix.outputs.branch-prefix }}

finalize-benchmark:
needs: [run-benchmarks, get-version]
needs: [run-benchmarks, create-branch-prefix]
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 }}'
branch-prefix: ${{ needs.create-branch-prefix.outputs.branch-prefix }}
commit-message: 'Update all dependencies for benchmark'
secrets:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
40 changes: 23 additions & 17 deletions .github/workflows/benchmark_parallel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
required: false
type: string
default: ''
azle-version:
branch-prefix:
required: true
type: string

Expand All @@ -25,11 +25,7 @@ jobs:
prepare-benchmark:
name: Prepare Benchmark
runs-on: ubuntu-latest
env:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} # All commits must be verified
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
outputs:
azle-version: ${{ inputs.azle-version }}
test-infos: ${{ steps.get-test-infos.outputs.test-infos }}
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -71,23 +67,33 @@ jobs:
working-directory: ${{ matrix.test.path }}
run: dfx start --clean --background --host 127.0.0.1:8000 --artificial-delay 0

- name: Print benchmark.md contents (before test)
working-directory: ${{ matrix.test.path }}
run: |
if [ -f benchmark.md ]; then
echo "Contents of benchmark.md before test:"
cat benchmark.md
else
echo "benchmark.md does not exist before test"
fi
- name: Run npm test (continue on error)
working-directory: ${{ matrix.test.path }}
continue-on-error: true
run: npm test

- uses: ./.github/actions/configure_git
with:
gpg_signing_key: ${{ secrets.GPG_SIGNING_KEY }}

- name: Commit and push changes
- name: Print benchmark.md contents (after test)
working-directory: ${{ matrix.test.path }}
run: |
BRANCH_NAME="benchmark--${{ needs.prepare-benchmark.outputs.azle-version }}-$(echo '${{ matrix.test.displayPath }}' | sed 's/\//-/g')"
git switch -c "$BRANCH_NAME"
git add --all
if ! git diff --cached --quiet; then
git commit -m "Run benchmarks for ${{ matrix.test.displayPath }}"
if [ -f benchmark.md ]; then
echo "Contents of benchmark.md after test:"
cat benchmark.md
else
echo "No changes to commit. Skipping commit and push."
echo "benchmark.md does not exist after test"
fi
git push origin "$BRANCH_NAME"
- uses: ./.github/actions/commit_and_push
with:
branch-name: "${{ inputs.branch-prefix }}$(echo '${{ matrix.test.displayPath }}' | sed 's/\//-/g')"
commit-message: 'Run benchmarks for ${{ matrix.test.displayPath }}'
gpg_signing_key: ${{ secrets.GPG_SIGNING_KEY }}
16 changes: 3 additions & 13 deletions .github/workflows/release_parallel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,12 @@ jobs:
continue-on-error: true
run: npm test

- uses: ./.github/actions/configure_git
- uses: ./.github/actions/commit_and_push
with:
branch-name: "update--${{ needs.prepare-release.outputs.release-version }}-$(echo '${{ matrix.test.displayPath }}' | sed 's/\//-/g')"
commit-message: 'Update dependencies for ${{ matrix.test.displayPath }}'
gpg_signing_key: ${{ secrets.GPG_SIGNING_KEY }}

- name: Commit and push changes
run: |
BRANCH_NAME="update--${{ needs.prepare-release.outputs.release-version }}-$(echo '${{ matrix.test.displayPath }}' | sed 's/\//-/g')"
git switch -c "$BRANCH_NAME"
git add --all
if ! git diff --cached --quiet; then
git commit -m "Update dependencies for ${{ matrix.test.displayPath }}"
else
echo "No changes to commit. Skipping commit and push."
fi
git push origin "$BRANCH_NAME"
finalize-release:
needs: [prepare-release, update-test-files-for-release-commit]
uses: ./.github/workflows/finalize_changes.yml
Expand Down

0 comments on commit 7e70a09

Please sign in to comment.