Skip to content

Commit

Permalink
Merge pull request #2281 from demergent-labs/workflow_updates
Browse files Browse the repository at this point in the history
Workflow updates
  • Loading branch information
lastmjs authored Nov 20, 2024
2 parents 787a6ae + cdff184 commit 3e6db77
Show file tree
Hide file tree
Showing 8 changed files with 163 additions and 57 deletions.
1 change: 1 addition & 0 deletions .github/actions/commit_and_push/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ steps:
gpg_signing_key: ${{ secrets.GPG_SIGNING_KEY }}
branch-name: 'branch-name'
commit-message: 'commit message'
create-branch: 'true'
```
14 changes: 11 additions & 3 deletions .github/actions/commit_and_push/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ 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'
description: 'Name of the branch to push to'
required: true
create-branch:
description: 'Whether to create the branch specified by branch-name'
required: false
default: 'false'
commit-message:
description: 'Commit message'
required: true
Expand All @@ -20,8 +24,12 @@ runs:
- name: Commit and push changes
shell: bash
run: |
# Create and switch to new branch
git switch -c "${{ inputs.branch-name }}"
# Create new branch if requested
if [ "${{ inputs.create-branch }}" = "true" ]; then
git switch -c "${{ inputs.branch-name }}"
else
git switch "${{ inputs.branch-name }}"
fi
# Show status of working directory
echo "Current git status:"
Expand Down
36 changes: 10 additions & 26 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,12 @@ jobs:
exclude-release-only: ${{ github.event.inputs.exclude-release-only-benchmarks }}

create-branch-prefix:
name: Create Branch and Branch Prefix
runs-on: ubuntu-latest
outputs:
branch-prefix: ${{ steps.create-prefix.outputs.branch-prefix }}
base-branch: ${{ steps.create-prefix.outputs.base-branch }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- id: create-prefix
run: |
VERSION=$(jq -r '.version' package.json)
echo "branch-prefix=benchmark--$VERSION-" >> $GITHUB_OUTPUT
echo "base-branch=benchmark--$VERSION" >> $GITHUB_OUTPUT
- uses: ./.github/actions/configure_git
with:
gpg_signing_key: ${{ secrets.GPG_SIGNING_KEY }}

- name: Create base branch
run: |
git checkout -b ${{ steps.create-prefix.outputs.base-branch }}
git push origin ${{ steps.create-prefix.outputs.base-branch }}
uses: ./.github/workflows/create_branch_prefix.yml
with:
prefix: 'benchmark'
version: $(jq -r '.version' package.json)
secrets:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}

run-benchmarks:
name: ${{ matrix.benchmark_group.name }}
Expand Down Expand Up @@ -110,7 +92,9 @@ jobs:
LASTMJS_GITHUB_TOKEN: ${{ secrets.LASTMJS_GITHUB_TOKEN }}

create-pr:
needs: [squash-branches, create-branch-prefix]
needs:
- squash-branches
- create-branch-prefix
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -119,7 +103,7 @@ jobs:

- name: Create Pull Request
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.LASTMJS_GITHUB_TOKEN }}
run: |
gh pr create \
--base main \
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/benchmark_parallel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ jobs:
ref: ${{ inputs.base-branch }}
token: ${{ secrets.LASTMJS_GITHUB_TOKEN || github.token }}

- name: Report full path of test
# Just in case the path isn't obvious from the name, this will remove ambiguity
run: echo ${{matrix.test.path}}

- uses: ./.github/actions/setup_node

- uses: ./.github/actions/setup_dfx
Expand All @@ -77,7 +81,7 @@ jobs:
- name: Run npm test (continue on error)
working-directory: ${{ matrix.test.path }}
continue-on-error: true
run: AZLE_RECORD_BENCHMARKS=true npm test
run: AZLE_IDENTITY_STORAGE_MODE=plaintext AZLE_RECORD_BENCHMARKS=true npm test

- name: Create branch name
id: create-branch-name
Expand All @@ -91,3 +95,4 @@ jobs:
branch-name: ${{ steps.create-branch-name.outputs.branch-name }}
commit-message: 'Run benchmarks for ${{ matrix.test.displayPath }}'
gpg_signing_key: ${{ secrets.GPG_SIGNING_KEY }}
create-branch: 'true'
50 changes: 50 additions & 0 deletions .github/workflows/create_branch_prefix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Create Branch Prefix
on:
workflow_call:
inputs:
prefix:
required: true
type: string
description: 'Prefix to use for branch names (e.g. benchmark, release)'
version:
required: true
type: string
description: 'Version to use in branch names'
outputs:
branch-prefix:
description: 'The generated branch prefix ({prefix}--{version}-)'
value: ${{ jobs.create-branch-prefix.outputs.branch-prefix }}
base-branch:
description: 'The generated base branch name ({prefix}--{version})'
value: ${{ jobs.create-branch-prefix.outputs.base-branch }}
secrets:
GPG_SIGNING_KEY:
required: true

jobs:
create-branch-prefix:
name: Create Branch and Branch Prefix
runs-on: ubuntu-latest
outputs:
branch-prefix: ${{ steps.create-prefix.outputs.branch-prefix }}
base-branch: ${{ steps.create-prefix.outputs.base-branch }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- id: create-prefix
shell: bash
run: |
VERSION="${{ inputs.version }}"
echo "branch-prefix=${{ inputs.prefix }}--$VERSION-" >> $GITHUB_OUTPUT
echo "base-branch=${{ inputs.prefix }}--$VERSION" >> $GITHUB_OUTPUT
- uses: ./.github/actions/configure_git
with:
gpg_signing_key: ${{ secrets.GPG_SIGNING_KEY }}

- name: Create base branch
run: |
git checkout -b ${{ steps.create-prefix.outputs.base-branch }}
git push origin ${{ steps.create-prefix.outputs.base-branch }}
3 changes: 1 addition & 2 deletions .github/workflows/get_and_run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ jobs:
id: set-conditions
- id: set-include-npm
run: |
if [[ "${{ steps.set-conditions.outputs.is_main_branch_push }}" == "true" || \
"${{ steps.set-conditions.outputs.is_main_branch_push_from_release_merge }}" == "true" || \
if [[ "${{ steps.set-conditions.outputs.is_main_branch_push_from_release_merge }}" == "true" || \
"${{ steps.set-conditions.outputs.is_release_branch_pr }}" == "true" ]]; then
echo "include_npm=true" >> $GITHUB_OUTPUT
else
Expand Down
93 changes: 76 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,54 @@
name: Parallel Release
name: Release
on:
workflow_dispatch:
inputs:
release-version:
required: true
exclude-slow-tests:
description: 'Exclude slow tests'
required: true
type: boolean
default: false
exclude-unstable-tests:
description: 'Exclude unstable tests'
required: true
type: boolean
default: false
exclude-release-only-tests:
description: 'Exclude release tests'
required: true
type: boolean
default: false

jobs:
get-exclude-dirs:
name: Get exclude directories
runs-on: ubuntu-latest
outputs:
exclude-dirs: ${{ steps.get-exclude-dirs.outputs.exclude-dirs }}
steps:
- uses: actions/checkout@v4

- id: get-exclude-dirs
uses: ./.github/actions/get_exclude_dirs
with:
exclude-slow: ${{ github.event.inputs.exclude-slow-tests }}
exclude-unstable: ${{ github.event.inputs.exclude-unstable-tests }}
exclude-release-only: ${{ github.event.inputs.exclude-release-only-tests }}

create-branch-prefix:
uses: ./.github/workflows/create_branch_prefix.yml
with:
prefix: 'release'
version: ${{ inputs.release-version }}
secrets:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}

prepare-release:
name: Prepare Release
needs:
- get-exclude-dirs
- create-branch-prefix
runs-on: ubuntu-latest
env:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} # All commits must be verified
Expand All @@ -18,7 +59,7 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
ref: ${{ needs.create-branch-prefix.outputs.base-branch }}
token: ${{ secrets.LASTMJS_GITHUB_TOKEN || github.token }}

- uses: ./.github/actions/setup_node
Expand All @@ -43,6 +84,12 @@ jobs:
AZLE_VERBOSE=true npx azle template
AZLE_VERBOSE=true npx azle template --experimental
- uses: ./.github/actions/commit_and_push
with:
branch-name: ${{ needs.create-branch-prefix.outputs.base-branch }}
commit-message: 'Prepare release ${{ inputs.release-version }}'
gpg_signing_key: ${{ secrets.GPG_SIGNING_KEY }}

- name: Publish to npm
run: |
if [[ "${{ inputs.release-version }}" == *"-rc."* ]]; then
Expand All @@ -57,9 +104,12 @@ jobs:
directories: |
./examples
./tests
exclude-dirs: ${{ needs.get-exclude-dirs.outputs.exclude-dirs }}

update-test-files-for-release-commit:
needs: prepare-release
needs:
- prepare-release
- create-branch-prefix
name: Update ${{ matrix.test.name }} files for release commit
runs-on: ubuntu-latest
env:
Expand All @@ -72,7 +122,7 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
ref: ${{ needs.create-branch-prefix.outputs.base-branch }}
token: ${{ secrets.LASTMJS_GITHUB_TOKEN || github.token }}

- uses: ./.github/actions/setup_node
Expand All @@ -83,7 +133,7 @@ jobs:
run: |
npm install
cd ${{ matrix.test.path }}
sed -E -i "s/(\"azle\": \")(.*)(\")/\1${{ needs.prepare-release.outputs.release-version }}\3/" package.json
sed -E -i "s/(\"azle\": \")(.*)(\")/\1${{ inputs.release-version }}\3/" package.json
npm install
- name: Start dfx with artificial delay 0
Expand All @@ -99,29 +149,35 @@ jobs:
id: create-branch-name
uses: ./.github/actions/create_branch_name
with:
prefix: 'update--${{ needs.prepare-release.outputs.release-version }}-'
prefix: ${{ needs.create-branch-prefix.outputs.branch-prefix }}
path: ${{ matrix.test.displayPath }}

- uses: ./.github/actions/commit_and_push
with:
branch-name: ${{ steps.create-branch-name.outputs.branch-name }}
commit-message: 'Update test files for ${{ matrix.test.displayPath }}'
gpg_signing_key: ${{ secrets.GPG_SIGNING_KEY }}
create-branch: 'true'

squash-branches:
needs: [prepare-release, update-test-files-for-release-commit]
needs:
- prepare-release
- update-test-files-for-release-commit
- create-branch-prefix
uses: ./.github/workflows/squash_branches.yml
with:
base-branch: release--${{ needs.prepare-release.outputs.release-version }}
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 }}'
base-branch: ${{ needs.create-branch-prefix.outputs.base-branch }}
branch-prefix: ${{ needs.create-branch-prefix.outputs.branch-prefix }}
commit-message: 'Update test files for all tests and examples ${{ inputs.release-version }}'
secrets:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LASTMJS_GITHUB_TOKEN: ${{ secrets.LASTMJS_GITHUB_TOKEN }}

create-release:
needs: [prepare-release, squash-branches]
needs:
- prepare-release
- squash-branches
name: Create Release
runs-on: ubuntu-latest
steps:
Expand All @@ -134,7 +190,7 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION=${{ needs.prepare-release.outputs.release-version }}
VERSION=${{ inputs.release-version }}
git tag $VERSION
git push origin $VERSION
Expand All @@ -145,7 +201,10 @@ jobs:
fi
create-pr:
needs: [prepare-release, squash-branches]
needs:
- prepare-release
- squash-branches
- create-branch-prefix
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -154,10 +213,10 @@ jobs:

- name: Create Pull Request
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.LASTMJS_GITHUB_TOKEN }}
run: |
gh pr create \
--base main \
--head release--${{ needs.prepare-release.outputs.release-version }} \
--title "Release ${{ needs.prepare-release.outputs.release-version }}" \
--body "Automated PR for release ${{ needs.prepare-release.outputs.release-version }}"
--head ${{ needs.create-branch-prefix.outputs.base-branch }} \
--title "Release ${{ inputs.release-version }}" \
--body "Automated PR for release ${{ inputs.release-version }}"
Loading

0 comments on commit 3e6db77

Please sign in to comment.