Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command action test #29

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
4ea27e6
added cmd-fmt
Bullrich Jun 5, 2024
039e8c1
added gh cli to image
Bullrich Jun 5, 2024
1a14326
added branch selection
Bullrich Jun 5, 2024
7808ca7
added gh-cli again
Bullrich Jun 5, 2024
eb8ba62
removed branch name verification
Bullrich Jun 5, 2024
e1296cd
added git safe directory
Bullrich Jun 5, 2024
a5ffe7f
added commandupdate ui
Bullrich Jun 6, 2024
ec94419
updated error message
Bullrich Jun 6, 2024
8112589
fixed naming of error
Bullrich Jun 6, 2024
4a2dc63
added setup composite action
Bullrich Jun 6, 2024
cbc99f9
replaced installation step for composite action
Bullrich Jun 6, 2024
732eb78
renamed directory
Bullrich Jun 6, 2024
da9bba5
added missing property shell
Bullrich Jun 6, 2024
b4d01dc
added missing pr number
Bullrich Jun 6, 2024
cc90132
added missing values
Bullrich Jun 6, 2024
c2f2adb
added command-sync
Bullrich Jun 10, 2024
c1a0666
added correct error message
Bullrich Jun 10, 2024
d74f094
added bench command
Bullrich Jun 10, 2024
81415eb
updated messages to have correct header
Bullrich Jun 10, 2024
64be0bc
fixed missing bracket
Bullrich Jun 10, 2024
11c1538
added lib scripts
Bullrich Jun 10, 2024
998c841
added missing ARTIFACTS_DIR
Bullrich Jun 10, 2024
8c4bfcf
moved artifact dire to util
Bullrich Jun 10, 2024
547e31a
added missing runtime dir
Bullrich Jun 10, 2024
3da081d
added pull --rebase just before pushing
Bullrich Jun 10, 2024
c4d80f8
Merge branch 'paritytech:master' into master
alvicsam Jun 11, 2024
43f3fb3
added bench-all
Bullrich Jun 17, 2024
6bc51c3
added bench-all write mode
Bullrich Jun 17, 2024
5bba4db
added cmd action
Bullrich Apr 22, 2024
a3dfe5a
added example commands
Bullrich Apr 22, 2024
60af089
implemented checkout for branch
Bullrich Apr 22, 2024
3c28cc1
changed hub for gh
Bullrich Apr 22, 2024
04eac30
fixed broken echo line
Bullrich Apr 22, 2024
a08d4c0
added output of command
Bullrich Apr 22, 2024
a4588fa
added test to run matrix
Bullrich Apr 22, 2024
63b67bc
added missing fromJson parameter
Bullrich Apr 22, 2024
b9a379d
fixed missing env variable
Bullrich Apr 22, 2024
0e42203
added branch reference
Bullrich Apr 22, 2024
d6397f8
made command be ran
Bullrich Apr 22, 2024
fa49b98
removed unused fields
Bullrich Apr 22, 2024
289b2f8
removed example test
Bullrich Apr 22, 2024
7dd80a3
added a new command
Bullrich Apr 22, 2024
02e17fa
cmd-action - changes
Apr 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/actions/set-up-gh/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: 'install gh'
description: 'Install the gh cli in a debian based distro and switches to the PR branch.'
inputs:
pr-number:
description: "Number of the PR"
required: true
GH_TOKEN:
description: "GitHub token"
required: true
outputs:
branch:
description: 'Branch name for the PR'
value: ${{ steps.branch.outputs.branch }}
runs:
using: "composite"
steps:
- name: Instal gh cli
shell: bash
# Here it would get the script from previous step
run: |
(type -p wget >/dev/null || (apt update && apt-get install wget -y)) \
&& mkdir -p -m 755 /etc/apt/keyrings \
&& wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& apt update \
&& apt install gh -y
git config --global --add safe.directory '*'
- run: gh pr checkout ${{ inputs.pr-number }}
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.GH_TOKEN }}
- name: Export branch name
shell: bash
run: echo "branch=$(git rev-parse --abbrev-ref HEAD)" >> "$GITHUB_OUTPUT"
id: branch
3 changes: 3 additions & 0 deletions .github/commands/example/example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: example
description: This command is just used for examples
commandStart: 'echo "Hello World!"'
3 changes: 3 additions & 0 deletions .github/commands/print/print.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: print
description: This command is used to create a file
commandStart: "touch file.txt"
68 changes: 68 additions & 0 deletions .github/workflows/cmd-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Command-Action

on:
pull_request:
issue_comment:
types: [created]

jobs:
cmd-check:
runs-on: ubuntu-latest
outputs:
commands: ${{ steps.cmd.outputs.commands }}
branch: ${{ steps.branch.outputs.branch }}
name: Bot
steps:
- uses: actions/checkout@v4
- run: gh pr checkout ${{ github.event.issue.number || github.event.pull_request.number }}
env:
GITHUB_TOKEN: ${{ github.token }}
- uses: paritytech/cmd-action@parse-comment
id: cmd
with:
commands-directory: ".github/commands"
GITHUB_TOKEN: ${{ github.token }}
- name: Export branch name
run: echo "branch=$(git rev-parse --abbrev-ref HEAD)" >> "$GITHUB_OUTPUT"
id: branch
- name: Print commands
if: ${{ github.event.issue.pull_request }}
run: echo "Commands are $CMD"
env:
CMD: ${{ steps.cmd.outputs.commands }}

cmd:
needs: [cmd-check]
continue-on-error: true
# We set the current machine here (to differ between ours and generic ones)
runs-on: ubuntu-latest
strategy:
matrix:
command: ${{ fromJson(needs.cmd-check.outputs.commands) }}
container:
image: node:20
steps:
- name: Download repo
uses: actions/[email protected]
with:
ref: ${{ needs.cmd-check.outputs.branch }}
- name: Generate script
# Here it would get the script from previous step
run: bash -c $COMMAND
env:
COMMAND: ${{ matrix.command }}
- name: Report failure
if: ${{ failure() }}
run: echo "Command failed!"
- run: git status
# - uses: stefanzweifel/git-auto-commit-action@v5
# - name: Push changes
# run: |
# git config --global --add safe.directory /__w/cmd-action/cmd-action
# git config --system user.name command-bot
# git config --system user.email "[email protected]"
# git add .
# git commit -m "changes"
# git push origin $BRANCH
# env:
# BRANCH: ${{ github.head_ref || github.ref_name }}
97 changes: 97 additions & 0 deletions .github/workflows/command-bench-all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Command Bench All

on:
workflow_dispatch:
inputs:
pr:
description: Number of the Pull Request
required: true
benchmark:
description: Pallet benchmark
type: choice
required: true
options:
- pallet
- substrate
- polkadot
- cumulus
pallet:
description: Pallet
required: false
type: string
default: pallet_name
target_dir:
description: Target directory
type: choice
options:
- substrate
- polkadot
- cumulus
runtime:
description: Runtime
type: choice
options:
- rococo
- westend
- asset-hub-kusama
- asset-hub-polkadot
- asset-hub-rococo
- asset-hub-westend
- bridge-hub-kusama
- bridge-hub-polkadot
- bridge-hub-rococo
- bridge-hub-westend
- collectives-polkadot
- collectives-westend
- coretime-rococo
- coretime-westend
- contracts-rococo
- glutton-kusama
- glutton-westend
- people-rococo
- people-westend


jobs:
set-image:
runs-on: ubuntu-latest
outputs:
IMAGE: ${{ steps.set_image.outputs.IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
- id: set_image
run: cat .github/env >> $GITHUB_OUTPUT
cmd-bench-all:
needs: [set-image]
runs-on: ubuntu-latest
container:
image: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Download repo
uses: actions/checkout@v4
- name: Install gh cli
id: gh
uses: ./.github/actions/set-up-gh
with:
pr-number: ${{ inputs.pr }}
GH_TOKEN: ${{ github.token }}
- name: Run bench
run: |
"./scripts/bench-all.sh" "${{ inputs.benchmark }}" --runtime "${{ inputs.runtime }}" --pallet "${{ inputs.pallet }}" --target_dir "${{ inputs.target_dir }}"
- name: Report failure
if: ${{ failure() }}
run: gh pr comment ${{ inputs.pr }} --body "<h2>Command failed ❌</h2> Run by @${{ github.actor }} for <code>${{ github.workflow }}</code> failed. See logs <a href=\"$RUN\">here</a>."
env:
RUN: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
GH_TOKEN: ${{ github.token }}
- run: git pull --rebase
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: cmd-action - ${{ github.workflow }}
branch: ${{ steps.gh.outputs.branch }}
- name: Report succeed
run: gh pr comment ${{ inputs.pr }} --body "<h2>Action completed 🎉🎉</h2> Run by @${{ github.actor }} for <code>${{ github.workflow }}</code> completed 🎉. See logs <a href=\"$RUN\">here</a>."
env:
RUN: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
GH_TOKEN: ${{ github.token }}
122 changes: 122 additions & 0 deletions .github/workflows/command-bench.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: Command Bench

on:
workflow_dispatch:
inputs:
pr:
description: Number of the Pull Request
required: true
benchmark:
description: Pallet benchmark
type: choice
required: true
options:
- substrate-pallet
- polkadot-pallet
- cumulus-assets
- cumulus-collectives
- cumulus-coretime
- cumulus-bridge-hubs
- cumulus-contracts
- cumulus-glutton
- cumulus-starters
- cumulus-people
- cumulus-testing
subcommand:
description: Subcommand
type: choice
required: true
options:
- pallet
- xcm
runtime:
description: Runtime
type: choice
options:
- dev
- rococo
- westend
- asset-hub-westend
- asset-hub-rococo
- collectives-westend
- coretime-rococo
- coretime-westend
- bridge-hub-rococo
- bridge-hub-westend
- contracts-rococo
- glutton-westend
- glutton-westend-dev-1300
- seedling
- shell
- people-westend
- people-rococo
- penpal
- rococo-parachain
pallet:
description: Pallet
type: string
default: pallet_name
target_dir:
description: Target directory
type: choice
options:
- substrate
- polkadot
- cumulus
runtime_dir:
description: Runtime directory
type: choice
options:
- people
- collectives
- coretime
- bridge-hubs
- contracts
- glutton
- starters
- testing


jobs:
set-image:
runs-on: ubuntu-latest
outputs:
IMAGE: ${{ steps.set_image.outputs.IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
- id: set_image
run: cat .github/env >> $GITHUB_OUTPUT
cmd-bench:
needs: [set-image]
runs-on: ubuntu-latest
container:
image: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Download repo
uses: actions/checkout@v4
- name: Install gh cli
id: gh
uses: ./.github/actions/set-up-gh
with:
pr-number: ${{ inputs.pr }}
GH_TOKEN: ${{ github.token }}
- name: Run bench
run: |
"./scripts/bench.sh" "${{ inputs.benchmark }}" --runtime "${{ inputs.runtime }}" --pallet "${{ inputs.pallet }}" --target_dir "${{ inputs.target_dir }}" --subcommand "${{ inputs.subcommand }}" --runtime_dir "${{ inputs.runtime_dir }}"
- name: Report failure
if: ${{ failure() }}
run: gh pr comment ${{ inputs.pr }} --body "<h2>Command failed ❌</h2> Run by @${{ github.actor }} for <code>${{ github.workflow }}</code> failed. See logs <a href=\"$RUN\">here</a>."
env:
RUN: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
GH_TOKEN: ${{ github.token }}
- run: git pull --rebase
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: cmd-action - ${{ github.workflow }}
branch: ${{ steps.gh.outputs.branch }}
- name: Report succeed
run: gh pr comment ${{ inputs.pr }} --body "<h2>Action completed 🎉🎉</h2> Run by @${{ github.actor }} for <code>${{ github.workflow }}</code> completed 🎉. See logs <a href=\"$RUN\">here</a>."
env:
RUN: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
GH_TOKEN: ${{ github.token }}
54 changes: 54 additions & 0 deletions .github/workflows/command-fmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Command FMT

on:
workflow_dispatch:
inputs:
pr:
description: Number of the Pull Request
required: true

jobs:
set-image:
runs-on: ubuntu-latest
outputs:
IMAGE: ${{ steps.set_image.outputs.IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
- id: set_image
run: cat .github/env >> $GITHUB_OUTPUT
cmd-fmt:
needs: [set-image]
runs-on: ubuntu-latest
container:
image: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Download repo
uses: actions/checkout@v4
- name: Install gh cli
id: gh
uses: ./.github/actions/set-up-gh
with:
pr-number: ${{ inputs.pr }}
GH_TOKEN: ${{ github.token }}
- name: Run FMT
run: |
# format toml.
# since paritytech/ci-unified:bullseye-1.73.0-2023-11-01-v20231204 includes taplo-cli
taplo format --config .config/taplo.toml
- name: Report failure
if: ${{ failure() }}
run: gh pr comment ${{ inputs.pr }} --body "<h2>Command failed ❌</h2> Run by @${{ github.actor }} for <code>${{ github.workflow }}</code> failed. See logs <a href=\"$RUN\">here</a>."
env:
RUN: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
GH_TOKEN: ${{ github.token }}
- run: git pull --rebase
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: cmd-action - ${{ github.workflow }}
branch: ${{ steps.gh.outputs.branch }}
- name: Report succeed
run: gh pr comment ${{ inputs.pr }} --body "<h2>Action completed 🎉🎉</h2> Run by @${{ github.actor }} for <code>${{ github.workflow }}</code> completed 🎉. See logs <a href=\"$RUN\">here</a>."
env:
RUN: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
GH_TOKEN: ${{ github.token }}
Loading
Loading