Syntax Error only on Actions?
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 25/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- github-actions, javascript, typescript
研究方向
Start with the inline workflow and its actions/github-script@v7 step, then inspect the linked Actions run for the syntax-error location and compare it with Node 20 parsing. Done means the workflow executes the step successfully and posts the intended comment.
由索引模型根據 Issue 內容生成。
描述
Describe the bug
I've been testing very thoroughly some code that only has a Syntax Error on an actions/github-script@v7 run.
To Reproduce
The following script fails:
Full file
name: Clippy changelog check
on:
merge_group:
pull_request:
types: [opened, reopened, synchronize, edited]
concurrency:
# For a given workflow, if we push to the same PR, cancel all previous builds on that PR.
# If the push is not attached to a PR, we will cancel all builds on the same branch.
group: "${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}"
cancel-in-progress: true
jobs:
changelog:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
# Run
- name: Check Changelog
if: ${{ github.event_name == 'pull_request' }}
run: |
body=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -s "https://api.github.com/repos/blyxyas/rust-clippy/pulls/$PR_NUMBER" | \
python -c "import sys, json; print(json.load(sys.stdin)['body'])")
output=$(awk '/^changelog:\s*\S/ && !/changelog: \[.*\]: your change/' <<< "$body" | sed "s/changelog:\s*//g")
if [ -z "$output" ]; then
echo "ERROR: pull request message must contain 'changelog: ...' with your changelog. Please add it."
exit 1
else
echo "changelog: $output"
if [[ "${output}" == \[\`* ]]; then
echo "LINT_CHANGELOG=\"${output}\"" >> $GITHUB_ENV
else
echo "LINT_CHANGELOG=\"meowmeow\"" >> $GITHUB_ENV
fi
fi
env:
PYTHONIOENCODING: 'utf-8'
PR_NUMBER: '${{ github.event.number }}'
- name: New Lint Label
uses: actions/github-script@v7
with:
script: |
let res = await github.rest.issues.listLabelsOnIssue({
owner: 'blyxyas',
repo: 'rust-clippy',
issue_number: ${{ github.event.number }}
})
let names = res.data.map((element) => element.name);
// We've already visited this PR
if (!names.includes('A-new-lint')) {
// Check if we're with a new lint (there are 0 mentions of this lint on the codebase
if (${{ env.LINT_CHANGELOG }} != "") {
const lint_name = /\[`(.*)`\]/g.exec(${{ env.LINT_CHANGELOG }}).slice(1);
let lint_name_upper = lint_name.toString().toUpperCase();
let res = await octokit.rest.search.code({
q: `${lint_name_upper} repo:rust-lang/rust-clippy`,
per_page: 1,
});
if (res.data.items.length == 0) {
await octokit.rest.issues.createComment({
owner: "blyxyas",
repo: "rust-clippy",
issue_number: ${{ github.event.number }},
body: "Seems that you are trying to add a new lint! We are currently in a feature freeze, I'll add it to a milestone."
});
}
}
}
# We need to have the "conclusion" job also on PR CI, to make it possible
# to add PRs to a merge queue.
conclusion_changelog:
needs: [ changelog ]
# We need to ensure this job does *not* get skipped if its dependencies fail,
# because a skipped job is considered a success by GitHub. So we have to
# overwrite `if:`. We use `!cancelled()` to ensure the job does still not get run
# when the workflow is canceled manually.
#
# ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
steps:
# Manually check the status of all dependencies. `if: failure()` does not work.
- name: Conclusion
run: |
# Print the dependent jobs to see them in the CI log
jq -C <<< '${{ toJson(needs) }}'
# Check if all jobs that we depend on (in the needs array) were successful.
jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'
let res = await github.rest.issues.listLabelsOnIssue({
owner: 'blyxyas',
repo: 'rust-clippy',
issue_number: ${{ github.event.number }}
})
let names = res.data.map((element) => element.name);
// We've already visited this PR
if (!names.includes('A-new-lint')) {
// Check if we're with a new lint (there are 0 mentions of this lint on the codebase
if (${{ env.LINT_CHANGELOG }} != "") {
const lint_name = /\[`(.*)`\]/g.exec(${{ env.LINT_CHANGELOG }}).slice(1);
let lint_name_upper = lint_name.toString().toUpperCase();
let res = await octokit.rest.search.code({
q: `${lint_name_upper} repo:rust-lang/rust-clippy`,
per_page: 1,
});
if (res.data.items.length == 0) {
await octokit.rest.issues.createComment({
owner: "blyxyas",
repo: "rust-clippy",
issue_number: ${{ github.event.number }},
body: "Seems that you are trying to add a new lint! We are currently in a feature freeze, I'll add it to a milestone."
});
}
}
}
Expected behavior
It actually running and posting the comment as desired, it runs correctly on my local PC's Node
Desktop (please complete the following information):
- OS: ubuntu-latest
- Version: Node 20, action/github-script@v7
Example
https://github.com/blyxyas/rust-clippy/actions/runs/14022377377/job/39255988671?pr=6
- 主要語言
- TypeScript
- 星號
- 5k
- 分支
- 586
- PR 合併指標
- 30 天內沒有已合併 PR
貢獻指南
這個儲存庫沒有索引到貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
actions/github-script 的其他 Issue
-
難度 3/5 1-2 天 新手友好度 48/100
actions/github-script#728 ·
-
難度 3/5 1-2 天 新手友好度 52/100
actions/github-script#727 · 1 個 reaction ·
-
{ 未關閉
難度 5/5 一週以上 新手友好度 10/100
actions/github-script#724 ·
-
難度 3/5 1-2 天 新手友好度 55/100
actions/github-script#723 · 1 則留言 ·
-
難度 3/5 1-2 天 新手友好度 55/100
actions/github-script#714 · 1 則留言 · 4 個 reaction ·
查看 actions/github-script 的全部 Issue
相似的 Issue
-
blocklist removal
難度 2/5 1-3 小時 新手友好度 65/100
MetaMask/eth-phishing-detect#296544 ·
-
難度 2/5 1-3 小時 新手友好度 70/100
pastelsky/bundlephobia#1122 ·
-
難度 2/5 1-3 小時 新手友好度 70/100
-
category/development priority/P2 scope/file-operations scope/testing type/enhancement
難度 2/5 1-3 小時 新手友好度 75/100
-
難度 2/5 1-3 小時 新手友好度 75/100