Skip to content

Commit

Permalink
fix: Use plugin executable name to dispatch commands (#1945)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon authored Feb 10, 2025
1 parent dfd5c50 commit e41b572
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
23 changes: 14 additions & 9 deletions .github/workflows/test-plugin-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ on:
description: The pip_url for the plugin
required: false
default: ''
executable:
description: The executable name for the plugin
required: false
default: ''
prepend-text:
description: Text to be prepended to the command output
required: false
Expand All @@ -39,6 +43,7 @@ jobs:
env:
PLUGIN_NAME: ${{ github.event.inputs.name }}
PIP_URL: ${{ github.event.inputs.pip-url }}
EXECUTABLE: ${{ github.event.inputs.executable || github.event.inputs.name }}

steps:

Expand All @@ -53,7 +58,7 @@ jobs:
token: ${{ secrets.MELTYBOT_GITHUB_AUTH_TOKEN }}
repository: ${{ github.event.inputs.repository }}
comment-id: ${{ github.event.inputs.comment-id }}
reaction-type: eyes
reactions: eyes

- name: Set initial edit mode (to conditionally clear previous comment)
id: initial-edit-mode
Expand Down Expand Up @@ -109,31 +114,31 @@ jobs:
- name: Print plugin help
id: plugin-help
run: |
${{ env.PLUGIN_NAME }} --help 2>&1 | tee help-output.txt
${{ env.EXECUTABLE }} --help 2>&1 | tee help-output.txt
- name: Print plugin version
id: plugin-version
continue-on-error: true
run: |
${{ env.PLUGIN_NAME }} --version | tee version-output.txt
${{ env.EXECUTABLE }} --version | tee version-output.txt
- name: Print plugin about
id: plugin-about
continue-on-error: true
run: |
${{ env.PLUGIN_NAME }} --about --format=json | tee about-result.json
${{ env.EXECUTABLE }} --about --format=json | tee about-result.json
- name: Print plugin markdown
id: plugin-markdown
continue-on-error: true
run: |
${{ env.PLUGIN_NAME }} --about --format=markdown | tee markdown-result.md
${{ env.EXECUTABLE }} --about --format=markdown | tee markdown-result.md
- name: Print discovery output
id: plugin-catalog
continue-on-error: true
run: |
${{ env.PLUGIN_NAME }} --discover | tee catalog.json
${{ env.EXECUTABLE }} --discover | tee catalog.json
# Generates the JOB_OUTPUT env var, accessible via '${{ env.JOB_OUTPUT }}''
# Ref: https://trstringer.com/github-actions-multiline-strings/
Expand All @@ -155,7 +160,7 @@ jobs:
fi
echo "<details><summary>Usage info</summary>" >> $GITHUB_ENV
echo -e "\n\`\`\`" >> $GITHUB_ENV
echo "melty-bot % ${{ env.PLUGIN_NAME }} --help" >> $GITHUB_ENV
echo "melty-bot % ${{ env.EXECUTABLE }} --help" >> $GITHUB_ENV
cat help-output.txt >> $GITHUB_ENV
echo -e "\`\`\`\n" >> $GITHUB_ENV
echo "</details>" >> $GITHUB_ENV
Expand Down Expand Up @@ -219,7 +224,7 @@ jobs:
token: ${{ secrets.MELTYBOT_GITHUB_AUTH_TOKEN }}
repository: ${{ github.event.inputs.repository }}
comment-id: ${{ github.event.inputs.comment-id }}
reaction-type: hooray
reactions: hooray

- name: Add reaction (failure)
uses: peter-evans/create-or-update-comment@v4
Expand All @@ -228,4 +233,4 @@ jobs:
token: ${{ secrets.MELTYBOT_GITHUB_AUTH_TOKEN }}
repository: ${{ github.event.inputs.repository }}
comment-id: ${{ github.event.inputs.comment-id }}
reaction-type: confused
reactions: confused
13 changes: 12 additions & 1 deletion .github/workflows/test_dispatcher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ jobs:
name="$(basename "$(dirname "${{ matrix.changed_file }}")")"
pip_url="$(./yq '.pip_url // ""' "${{ matrix.changed_file }}")"
variant="$(./yq '.variant' "${{ matrix.changed_file }}")"
executable="$(./yq '.executable' "${{ matrix.changed_file }}")"
echo "name=${name}" >> $GITHUB_ENV
echo "pip_url=${pip_url}" >> $GITHUB_ENV
echo "executable=${executable}" >> $GITHUB_ENV
echo "prelude=Testing plugin \`${name}\` (\`${variant}\` variant):" >> $GITHUB_ENV
- name: Find the MeltyBot test-command comment if it exists
Expand All @@ -84,6 +86,15 @@ jobs:
with:
route: "POST /repos/${{ github.repository }}/actions/workflows/test-plugin-command.yml/dispatches"
ref: 'main'
inputs: "{\"repository\":\"${{ github.repository }}\",\"comment-id\":\"${{ steps.find_comment.outputs.comment-id }}\",\"issue-number\":\"${{ github.event.pull_request.number }}\",\"name\":\"${{ env.name }}\",\"pip-url\":\"${{ env.pip_url }}\",\"prepend-text\":\"${{ env.prelude }}\"}"
inputs: |
{
"repository": "${{ github.repository }}",
"comment-id": "${{ steps.find_comment.outputs.comment-id }}",
"issue-number": "${{ github.event.pull_request.number }}",
"name": "${{ env.name }}",
"pip-url": "${{ env.pip_url }}",
"executable": "${{ env.executable }}",
"prepend-text": "${{ env.prelude }}"
}
env:
GITHUB_TOKEN: ${{ secrets.MELTYBOT_GITHUB_AUTH_TOKEN }}

0 comments on commit e41b572

Please sign in to comment.