b3d2a1837c
Bumps the ci_dependencies group with 14 updates in the / directory: | Package | From | To | | --- | --- | --- | | [actions/checkout](https://github.com/actions/checkout) | `5.0.0` | `6.0.2` | | [actions/upload-artifact](https://github.com/actions/upload-artifact) | `4.3.1` | `6.0.0` | | [actions/download-artifact](https://github.com/actions/download-artifact) | `6.0.0` | `7.0.0` | | [actions/create-github-app-token](https://github.com/actions/create-github-app-token) | `2.1.4` | `2.2.1` | | [docker/build-push-action](https://github.com/docker/build-push-action) | `6.18.0` | `6.19.2` | | [docker/login-action](https://github.com/docker/login-action) | `3.6.0` | `3.7.0` | | [actions/setup-node](https://github.com/actions/setup-node) | `5.0.0` | `6.2.0` | | [actions/cache](https://github.com/actions/cache) | `4.3.0` | `5.0.3` | | [lycheeverse/lychee-action](https://github.com/lycheeverse/lychee-action) | `2.7.0` | `2.8.0` | | [actions-rust-lang/setup-rust-toolchain](https://github.com/actions-rust-lang/setup-rust-toolchain) | `1.13.0` | `1.15.2` | | [Swatinem/rust-cache](https://github.com/swatinem/rust-cache) | `2.7.8` | `2.8.2` | | [actions/attest-build-provenance](https://github.com/actions/attest-build-provenance) | `2.4.0` | `3.2.0` | | [tj-actions/changed-files](https://github.com/tj-actions/changed-files) | `47.0.0` | `47.0.4` | | [codecov/codecov-action](https://github.com/codecov/codecov-action) | `5.5.1` | `5.5.2` | Updates `actions/checkout` from 5.0.0 to 6.0.2 - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/08c6903cd8c0fde910a37f88322edcfb5dd907a8...de0fac2e4500dabe0009e67214ff5f5447ce83dd) Updates `actions/upload-artifact` from 4.3.1 to 6.0.0 - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v4.3.1...b7c566a772e6b6bfb58ed0dc250532a479d7789f) Updates `actions/download-artifact` from 6.0.0 to 7.0.0 - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/018cc2cf5baa6db3ef3c5f8a56943fffe632ef53...37930b1c2abaa49bbe596cd826c3c89aef350131) Updates `actions/create-github-app-token` from 2.1.4 to 2.2.1 - [Release notes](https://github.com/actions/create-github-app-token/releases) - [Commits](https://github.com/actions/create-github-app-token/compare/67018539274d69449ef7c02e8e71183d1719ab42...29824e69f54612133e76f7eaac726eef6c875baf) Updates `docker/build-push-action` from 6.18.0 to 6.19.2 - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/263435318d21b8e681c14492fe198d362a7d2c83...10e90e3645eae34f1e60eeb005ba3a3d33f178e8) Updates `docker/login-action` from 3.6.0 to 3.7.0 - [Release notes](https://github.com/docker/login-action/releases) - [Commits](https://github.com/docker/login-action/compare/5e57cd118135c172c3672efd75eb46360885c0ef...c94ce9fb468520275223c153574b00df6fe4bcc9) Updates `actions/setup-node` from 5.0.0 to 6.2.0 - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](https://github.com/actions/setup-node/compare/v5...6044e13b5dc448c55e2357c09f80417699197238) Updates `actions/cache` from 4.3.0 to 5.0.3 - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/0057852bfaa89a56745cba8c7296529d2fc39830...cdf6c1fa76f9f475f3d7449005a359c84ca0f306) Updates `lycheeverse/lychee-action` from 2.7.0 to 2.8.0 - [Release notes](https://github.com/lycheeverse/lychee-action/releases) - [Commits](https://github.com/lycheeverse/lychee-action/compare/a8c4c7cb88f0c7386610c35eb25108e448569cb0...8646ba30535128ac92d33dfc9133794bfdd9b411) Updates `actions-rust-lang/setup-rust-toolchain` from 1.13.0 to 1.15.2 - [Release notes](https://github.com/actions-rust-lang/setup-rust-toolchain/releases) - [Changelog](https://github.com/actions-rust-lang/setup-rust-toolchain/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions-rust-lang/setup-rust-toolchain/compare/v1.13...1780873c7b576612439a134613cc4cc74ce5538c) Updates `Swatinem/rust-cache` from 2.7.8 to 2.8.2 - [Release notes](https://github.com/swatinem/rust-cache/releases) - [Changelog](https://github.com/Swatinem/rust-cache/blob/master/CHANGELOG.md) - [Commits](https://github.com/swatinem/rust-cache/compare/v2.7.8...779680da715d629ac1d338a641029a2f4372abb5) Updates `actions/attest-build-provenance` from 2.4.0 to 3.2.0 - [Release notes](https://github.com/actions/attest-build-provenance/releases) - [Changelog](https://github.com/actions/attest-build-provenance/blob/main/RELEASE.md) - [Commits](https://github.com/actions/attest-build-provenance/compare/v2.4.0...96278af6caaf10aea03fd8d33a09a777ca52d62f) Updates `tj-actions/changed-files` from 47.0.0 to 47.0.4 - [Release notes](https://github.com/tj-actions/changed-files/releases) - [Changelog](https://github.com/tj-actions/changed-files/blob/main/HISTORY.md) - [Commits](https://github.com/tj-actions/changed-files/compare/24d32ffd492484c1d75e0c0b894501ddb9d30d62...7dee1b0c1557f278e5c7dc244927139d78c0e22a) Updates `codecov/codecov-action` from 5.5.1 to 5.5.2 - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/5a1091511ad55cbe89839c7260b706298ca349f7...671740ac38dd9b0130fbe1cec585b89eea48d3de) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: 6.0.2 dependency-type: direct:production update-type: version-update:semver-major dependency-group: ci_dependencies - dependency-name: actions/upload-artifact dependency-version: 6.0.0 dependency-type: direct:production update-type: version-update:semver-major dependency-group: ci_dependencies - dependency-name: actions/download-artifact dependency-version: 7.0.0 dependency-type: direct:production update-type: version-update:semver-major dependency-group: ci_dependencies - dependency-name: actions/create-github-app-token dependency-version: 2.2.1 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: ci_dependencies - dependency-name: docker/build-push-action dependency-version: 6.19.2 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: ci_dependencies - dependency-name: docker/login-action dependency-version: 3.7.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: ci_dependencies - dependency-name: actions/setup-node dependency-version: 6.2.0 dependency-type: direct:production update-type: version-update:semver-major dependency-group: ci_dependencies - dependency-name: actions/cache dependency-version: 5.0.3 dependency-type: direct:production update-type: version-update:semver-major dependency-group: ci_dependencies - dependency-name: lycheeverse/lychee-action dependency-version: 2.8.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: ci_dependencies - dependency-name: actions-rust-lang/setup-rust-toolchain dependency-version: 1.15.2 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: ci_dependencies - dependency-name: Swatinem/rust-cache dependency-version: 2.8.2 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: ci_dependencies - dependency-name: actions/attest-build-provenance dependency-version: 3.2.0 dependency-type: direct:production update-type: version-update:semver-major dependency-group: ci_dependencies - dependency-name: tj-actions/changed-files dependency-version: 47.0.4 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: ci_dependencies - dependency-name: codecov/codecov-action dependency-version: 5.5.2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: ci_dependencies ... Signed-off-by: dependabot[bot] <support@github.com>
508 lines
19 KiB
YAML
508 lines
19 KiB
YAML
name: Command - Run
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
cmd:
|
|
description: "Command to run"
|
|
required: true
|
|
pr_num:
|
|
description: "PR number"
|
|
required: true
|
|
pr_branch:
|
|
description: "PR branch"
|
|
required: true
|
|
runner:
|
|
description: "Runner to use"
|
|
required: true
|
|
image:
|
|
description: "Image to use"
|
|
required: true
|
|
is_org_member:
|
|
description: "Is the user an org member"
|
|
required: true
|
|
is_pr_author:
|
|
description: "Is the user the PR author"
|
|
required: true
|
|
repo:
|
|
description: "Repository to use"
|
|
required: true
|
|
comment_id:
|
|
description: "Comment ID"
|
|
required: true
|
|
is_quiet:
|
|
description: "Quiet mode"
|
|
required: false
|
|
default: "false"
|
|
|
|
permissions: # allow the action to comment on the PR
|
|
contents: read
|
|
issues: write
|
|
pull-requests: write
|
|
actions: read
|
|
|
|
jobs:
|
|
before-cmd:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
JOB_NAME: "cmd"
|
|
CMD: ${{ github.event.inputs.cmd }}
|
|
PR_BRANCH: ${{ github.event.inputs.pr_branch }}
|
|
PR_NUM: ${{ github.event.inputs.pr_num }}
|
|
outputs:
|
|
job_url: ${{ steps.build-link.outputs.job_url }}
|
|
run_url: ${{ steps.build-link.outputs.run_url }}
|
|
steps:
|
|
- name: Build workflow link
|
|
if: ${{ github.event.inputs.is_quiet == 'false' }}
|
|
id: build-link
|
|
run: |
|
|
# Get exactly the CMD job link, filtering out the other jobs
|
|
jobLink=$(curl -s \
|
|
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
|
-H "Accept: application/vnd.github.v3+json" \
|
|
https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs | jq '.jobs[] | select(.name | contains("${{ env.JOB_NAME }}")) | .html_url')
|
|
|
|
runLink=$(curl -s \
|
|
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
|
-H "Accept: application/vnd.github.v3+json" \
|
|
https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }} | jq '.html_url')
|
|
|
|
echo "job_url=${jobLink}"
|
|
echo "run_url=${runLink}"
|
|
echo "job_url=$jobLink" >> $GITHUB_OUTPUT
|
|
echo "run_url=$runLink" >> $GITHUB_OUTPUT
|
|
|
|
- name: Comment PR (Start)
|
|
# No need to comment on prdoc start or if --quiet
|
|
if: ${{ github.event.inputs.is_quiet == 'false' && !startsWith(github.event.inputs.cmd, 'prdoc') && !startsWith(github.event.inputs.cmd, 'fmt') && !startsWith(github.event.inputs.cmd, 'label')}}
|
|
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
script: |
|
|
let job_url = ${{ steps.build-link.outputs.job_url }}
|
|
let cmd = process.env.CMD;
|
|
github.rest.issues.createComment({
|
|
issue_number: ${{ env.PR_NUM }},
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
body: `Command "${cmd}" has started 🚀 [See logs here](${job_url})`
|
|
})
|
|
|
|
- name: Debug info
|
|
env:
|
|
CMD: ${{ github.event.inputs.cmd }}
|
|
PR_BRANCH: ${{ github.event.inputs.pr_branch }}
|
|
PR_NUM: ${{ github.event.inputs.pr_num }}
|
|
RUNNER: ${{ github.event.inputs.runner }}
|
|
IMAGE: ${{ github.event.inputs.image }}
|
|
IS_ORG_MEMBER: ${{ github.event.inputs.is_org_member }}
|
|
REPO: ${{ github.event.inputs.repo }}
|
|
COMMENT_ID: ${{ github.event.inputs.comment_id }}
|
|
IS_QUIET: ${{ github.event.inputs.is_quiet }}
|
|
run: |
|
|
echo "Running command: $CMD"
|
|
echo "PR number: $PR_NUM"
|
|
echo "PR branch: $PR_BRANCH"
|
|
echo "Runner: $RUNNER"
|
|
echo "Image: $IMAGE"
|
|
echo "Is org member: $IS_ORG_MEMBER"
|
|
echo "Repository: $REPO"
|
|
echo "Comment ID: $COMMENT_ID"
|
|
echo "Is quiet: $IS_QUIET"
|
|
|
|
cmd:
|
|
needs: [before-cmd]
|
|
env:
|
|
CMD: ${{ github.event.inputs.cmd }}
|
|
PR_BRANCH: ${{ github.event.inputs.pr_branch }}
|
|
PR_NUM: ${{ github.event.inputs.pr_num }}
|
|
REPO: ${{ github.event.inputs.repo }}
|
|
runs-on: ${{ github.event.inputs.runner }}
|
|
container:
|
|
image: ${{ github.event.inputs.image }}
|
|
timeout-minutes: 1440 # 24 hours per runtime
|
|
# lowerdown permissions to separate permissions context for executable parts by contributors
|
|
permissions:
|
|
contents: read
|
|
pull-requests: none
|
|
actions: none
|
|
issues: none
|
|
outputs:
|
|
cmd_output: ${{ steps.cmd.outputs.cmd_output }}
|
|
subweight: ${{ steps.subweight.outputs.result }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
repository: ${{ env.REPO }}
|
|
ref: ${{ env.PR_BRANCH }}
|
|
|
|
# In order to run prdoc without specifying the PR number, we need to add the PR number as an argument automatically
|
|
- name: Prepare PR Number argument
|
|
id: pr-arg
|
|
run: |
|
|
CMD="${CMD}"
|
|
if echo "$CMD" | grep -q "prdoc" && ! echo "$CMD" | grep -qE "\-\-pr[[:space:]=][0-9]+"; then
|
|
echo "arg=--pr ${PR_NUM}" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "arg=" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Run cmd
|
|
id: cmd
|
|
env:
|
|
PR_ARG: ${{ steps.pr-arg.outputs.arg }}
|
|
IS_ORG_MEMBER: ${{ github.event.inputs.is_org_member }}
|
|
IS_PR_AUTHOR: ${{ github.event.inputs.is_pr_author }}
|
|
RUNNER: ${{ github.event.inputs.runner }}
|
|
IMAGE: ${{ github.event.inputs.image }}
|
|
run: |
|
|
echo "Running command: '${CMD} ${PR_ARG}' on '${RUNNER}' runner, container: '${IMAGE}'"
|
|
echo "RUST_NIGHTLY_VERSION: ${RUST_NIGHTLY_VERSION}"
|
|
echo "IS_ORG_MEMBER: ${IS_ORG_MEMBER}"
|
|
|
|
git config --global --add safe.directory $GITHUB_WORKSPACE
|
|
git config user.name "cmd[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
|
|
# if the user is not an org member, we need to use the bot's path from master to avoid unwanted modifications
|
|
if [ "${IS_ORG_MEMBER}" = "true" ]; then
|
|
# safe to run commands from current branch
|
|
BOT_PATH=.github
|
|
else
|
|
# going to run commands from master
|
|
TMP_DIR=/tmp/pezkuwi-sdk
|
|
git clone --depth 1 --branch master https://github.com/pezkuwichain/pezkuwi-sdk $TMP_DIR
|
|
BOT_PATH=$TMP_DIR/.github
|
|
fi
|
|
|
|
# install deps and run a command from master
|
|
python3 -m pip install -r $BOT_PATH/scripts/generate-prdoc.requirements.txt
|
|
python3 $BOT_PATH/scripts/cmd/cmd.py $CMD $PR_ARG
|
|
git status > /tmp/cmd/git_status.log
|
|
git diff > /tmp/cmd/git_diff.log
|
|
|
|
if [ -f /tmp/cmd/command_output.log ]; then
|
|
CMD_OUTPUT=$(cat /tmp/cmd/command_output.log)
|
|
# export to summary to display in the PR
|
|
echo "$CMD_OUTPUT" >> $GITHUB_STEP_SUMMARY
|
|
# should be multiline, otherwise it captures the first line only
|
|
echo 'cmd_output<<EOF' >> $GITHUB_OUTPUT
|
|
echo "$CMD_OUTPUT" >> $GITHUB_OUTPUT
|
|
echo 'EOF' >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
git add -A
|
|
git diff HEAD > /tmp/cmd/command_diff.patch -U0
|
|
git commit -m "tmp cmd: $CMD" || true
|
|
# without push, as we're saving the diff to an artifact and subweight will compare the local branch with the remote branch
|
|
|
|
- name: Upload command output
|
|
if: ${{ always() }}
|
|
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
|
|
with:
|
|
name: command-output
|
|
path: /tmp/cmd/command_output.log
|
|
|
|
- name: Upload command diff
|
|
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
|
|
with:
|
|
name: command-diff
|
|
path: /tmp/cmd/command_diff.patch
|
|
|
|
- name: Upload git status
|
|
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
|
|
with:
|
|
name: git-status
|
|
path: /tmp/cmd/git_status.log
|
|
|
|
- name: Upload git diff
|
|
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
|
|
with:
|
|
name: git-diff
|
|
path: /tmp/cmd/git_diff.log
|
|
|
|
- name: Install subweight for bench
|
|
if: startsWith(github.event.inputs.cmd, 'bench')
|
|
run: cargo install subweight
|
|
|
|
- name: Run Subweight for bench
|
|
id: subweight
|
|
if: startsWith(github.event.inputs.cmd, 'bench')
|
|
shell: bash
|
|
run: |
|
|
git fetch
|
|
git remote -v
|
|
echo $(git log -n 2 --oneline)
|
|
|
|
result=$(subweight compare commits \
|
|
--path-pattern "./**/weights/**/*.rs,./**/weights.rs" \
|
|
--method asymptotic \
|
|
--format markdown \
|
|
--no-color \
|
|
--change added changed \
|
|
--ignore-errors \
|
|
refs/remotes/origin/master $PR_BRANCH)
|
|
|
|
echo $result
|
|
|
|
echo $result > /tmp/cmd/subweight.log
|
|
# Though github claims that it supports 1048576 bytes in GITHUB_OUTPUT in fact it only supports ~200000 bytes of a multiline string
|
|
if [ $(wc -c < "/tmp/cmd/subweight.log") -gt 200000 ]; then
|
|
echo "Subweight result is too large, truncating..."
|
|
echo "Please check subweight.log for the full output"
|
|
result="Please check subweight.log for the full output"
|
|
fi
|
|
echo "Trying to save subweight result to GITHUB_OUTPUT"
|
|
# Save the multiline result to the output
|
|
{
|
|
echo "result<<EOF"
|
|
echo "$result"
|
|
echo "EOF"
|
|
} >> $GITHUB_OUTPUT
|
|
|
|
- name: Upload Subweight
|
|
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
|
|
if: startsWith(github.event.inputs.cmd, 'bench')
|
|
with:
|
|
name: subweight
|
|
path: /tmp/cmd/subweight.log
|
|
|
|
after-cmd:
|
|
needs: [cmd, before-cmd]
|
|
env:
|
|
CMD: ${{ github.event.inputs.cmd }}
|
|
PR_BRANCH: ${{ github.event.inputs.pr_branch }}
|
|
PR_NUM: ${{ github.event.inputs.pr_num }}
|
|
REPO: ${{ github.event.inputs.repo }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
# needs to be able to trigger CI, as default token does not retrigger
|
|
- uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
|
|
id: generate_token
|
|
with:
|
|
app-id: ${{ secrets.CMD_BOT_APP_ID }}
|
|
private-key: ${{ secrets.CMD_BOT_APP_KEY }}
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
token: ${{ steps.generate_token.outputs.token }}
|
|
repository: ${{ env.REPO }}
|
|
ref: ${{ env.PR_BRANCH }}
|
|
|
|
- name: Download all artifacts
|
|
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
|
|
with:
|
|
name: command-diff
|
|
path: command-diff
|
|
|
|
- name: Apply labels for label command
|
|
if: startsWith(github.event.inputs.cmd, 'label')
|
|
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
|
with:
|
|
github-token: ${{ steps.generate_token.outputs.token }}
|
|
script: |
|
|
// Read the command output to get validated labels
|
|
const fs = require('fs');
|
|
let labels = [];
|
|
|
|
try {
|
|
const output = fs.readFileSync('/tmp/cmd/command_output.log', 'utf8');
|
|
|
|
// Parse JSON labels from output - look for "LABELS_JSON: {...}"
|
|
const jsonMatch = output.match(/LABELS_JSON: (.+)/);
|
|
if (jsonMatch) {
|
|
const labelsData = JSON.parse(jsonMatch[1]);
|
|
labels = labelsData.labels || [];
|
|
}
|
|
} catch (error) {
|
|
console.error(`Error reading command output: ${error.message}`);
|
|
throw new Error('Label validation failed. Check the command output for details.');
|
|
}
|
|
|
|
if (labels.length > 0) {
|
|
try {
|
|
await github.rest.issues.addLabels({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: ${{ env.PR_NUM }},
|
|
labels: labels
|
|
});
|
|
} catch (error) {
|
|
console.error(`Error adding labels: ${error.message}`);
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
- name: Comment PR (Label Error)
|
|
if: ${{ failure() && startsWith(github.event.inputs.cmd, 'label') }}
|
|
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
|
env:
|
|
CMD_OUTPUT: "${{ needs.cmd.outputs.cmd_output }}"
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
script: |
|
|
let runUrl = ${{ needs.before-cmd.outputs.run_url }};
|
|
let cmdOutput = process.env.CMD_OUTPUT || '';
|
|
|
|
// Try to parse JSON error for better formatting
|
|
let errorMessage = 'Label validation failed. Please check the error details below and try again.';
|
|
let errorDetails = '';
|
|
|
|
try {
|
|
const errorMatch = cmdOutput.match(/ERROR_JSON: (.+)/);
|
|
if (errorMatch) {
|
|
const errorData = JSON.parse(errorMatch[1]);
|
|
errorMessage = errorData.message || errorMessage;
|
|
errorDetails = errorData.details || '';
|
|
}
|
|
} catch (e) {
|
|
// Fallback to raw output
|
|
errorDetails = cmdOutput;
|
|
}
|
|
|
|
let cmdOutputCollapsed = errorDetails.trim() !== ''
|
|
? `<details>\n\n<summary>Error details:</summary>\n\n${errorDetails}\n\n</details>`
|
|
: '';
|
|
|
|
github.rest.issues.createComment({
|
|
issue_number: ${{ env.PR_NUM }},
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
body: `❌ ${errorMessage}\n\n${cmdOutputCollapsed}\n\n[See full logs here](${runUrl})`
|
|
})
|
|
|
|
- name: Apply & Commit changes
|
|
if: ${{ !startsWith(github.event.inputs.cmd, 'label') }}
|
|
run: |
|
|
ls -lsa .
|
|
|
|
git config --global --add safe.directory $GITHUB_WORKSPACE
|
|
git config user.name "cmd[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git config --global pull.rebase false
|
|
|
|
echo "Applying $file"
|
|
git apply "command-diff/command_diff.patch" --unidiff-zero --allow-empty
|
|
|
|
rm -rf command-diff
|
|
|
|
git status
|
|
|
|
if [ -n "$(git status --porcelain)" ]; then
|
|
|
|
git remote -v
|
|
|
|
push_changes() {
|
|
git push origin "HEAD:$PR_BRANCH"
|
|
}
|
|
|
|
git add .
|
|
git restore --staged Cargo.lock # ignore changes in Cargo.lock
|
|
git commit -m "Update from ${{ github.actor }} running command '$CMD'" || true
|
|
|
|
# Attempt to push changes
|
|
if ! push_changes; then
|
|
echo "Push failed, trying to rebase..."
|
|
git pull --rebase origin $PR_BRANCH
|
|
# After successful rebase, try pushing again
|
|
push_changes
|
|
fi
|
|
else
|
|
echo "Nothing to commit";
|
|
fi
|
|
|
|
|
|
- name: Comment PR (End)
|
|
# No need to comment on prdoc success or --quiet
|
|
#TODO: return "&& !contains(github.event.comment.body, '--quiet')"
|
|
if: ${{ github.event.inputs.is_quiet == 'false' && needs.cmd.result == 'success' && !startsWith(github.event.inputs.cmd, 'prdoc') && !startsWith(github.event.inputs.cmd, 'fmt') && !startsWith(github.event.inputs.cmd, 'label') }}
|
|
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
|
env:
|
|
SUBWEIGHT: "${{ needs.cmd.outputs.subweight }}"
|
|
CMD_OUTPUT: "${{ needs.cmd.outputs.cmd_output }}"
|
|
PR_NUM: ${{ github.event.inputs.pr_num }}
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
script: |
|
|
let runUrl = ${{ needs.before-cmd.outputs.run_url }};
|
|
let subweight = process.env.SUBWEIGHT || '';
|
|
let cmdOutput = process.env.CMD_OUTPUT || '';
|
|
let cmd = process.env.CMD;
|
|
console.log(cmdOutput);
|
|
|
|
let subweightCollapsed = subweight.trim() !== ''
|
|
? `<details>\n\n<summary>Subweight results:</summary>\n\n${subweight}\n\n</details>`
|
|
: '';
|
|
|
|
let cmdOutputCollapsed = cmdOutput.trim() !== ''
|
|
? `<details>\n\n<summary>Command output:</summary>\n\n${cmdOutput}\n\n</details>`
|
|
: '';
|
|
|
|
github.rest.issues.createComment({
|
|
issue_number: ${{ env.PR_NUM }},
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
body: `Command "${cmd}" has finished ✅ [See logs here](${runUrl})${subweightCollapsed}${cmdOutputCollapsed}`
|
|
})
|
|
|
|
|
|
finish:
|
|
needs: [before-cmd, cmd, after-cmd]
|
|
if: ${{ always() }}
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
CMD_OUTPUT: "${{ needs.cmd.outputs.cmd_output }}"
|
|
CMD: ${{ github.event.inputs.cmd }}
|
|
PR_NUM: ${{ github.event.inputs.pr_num }}
|
|
COMMENT_ID: ${{ github.event.inputs.comment_id }}
|
|
steps:
|
|
- name: Comment PR (Failure)
|
|
if: ${{ needs.cmd.result == 'failure' || needs.after-cmd.result == 'failure' || needs.before-cmd.result == 'failure' }}
|
|
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
script: |
|
|
let jobUrl = ${{ needs.before-cmd.outputs.job_url }};
|
|
let cmdOutput = process.env.CMD_OUTPUT;
|
|
let cmd = process.env.CMD;
|
|
let cmdOutputCollapsed = '';
|
|
if (cmdOutput && cmdOutput.trim() !== '') {
|
|
cmdOutputCollapsed = `<details>\n\n<summary>Command output:</summary>\n\n${cmdOutput}\n\n</details>`
|
|
}
|
|
|
|
github.rest.issues.createComment({
|
|
issue_number: ${{ env.PR_NUM }},
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
body: `Command "${cmd}" has failed ❌! [See logs here](${jobUrl})${cmdOutputCollapsed}`
|
|
})
|
|
|
|
- name: Add 😕 reaction on failure
|
|
if: ${{ needs.cmd.result == 'failure' || needs.after-cmd.result == 'failure' || needs.before-cmd.result == 'failure' }}
|
|
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
script: |
|
|
github.rest.reactions.createForIssueComment({
|
|
comment_id: ${{ env.COMMENT_ID }},
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
content: 'confused'
|
|
})
|
|
|
|
- name: Add 👍 reaction on success
|
|
if: ${{ needs.cmd.result == 'success' && needs.after-cmd.result == 'success' && needs.before-cmd.result == 'success' }}
|
|
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
script: |
|
|
github.rest.reactions.createForIssueComment({
|
|
comment_id: ${{ env.COMMENT_ID }},
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
content: '+1'
|
|
})
|