Skip to content
Open
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1216212
[ci] use GItHub built-in token (fixes #7012)
jameslamb Sep 16, 2025
de45d8f
avoid other CI runs
jameslamb Sep 16, 2025
a11d408
run on push
jameslamb Sep 16, 2025
9a2b5e2
try more permissions
jameslamb Sep 16, 2025
3c9a20e
does the token interfere with actions/checkout?
jameslamb Sep 16, 2025
e3a3192
hmmm
jameslamb Sep 16, 2025
a3bd0ce
ah, use API URL
jameslamb Sep 16, 2025
d9e0503
try a reusable workflow instead of repository_dispatch
jameslamb Sep 16, 2025
43a3ced
try just running valgrind directly
jameslamb Sep 17, 2025
7007ff8
more permissions stuff
jameslamb Sep 17, 2025
36983b6
change image
jameslamb Sep 17, 2025
42e07a6
arg not argjson
jameslamb Sep 17, 2025
258db78
update script
jameslamb Sep 17, 2025
46f383b
stricter permissions
jameslamb Sep 17, 2025
e32a7b0
more permissions fiddling
jameslamb Sep 17, 2025
23e6a74
more permissions tightening
jameslamb Sep 17, 2025
09eed1e
actually, fully run valgrind
jameslamb Sep 18, 2025
617cb11
test r_configure
jameslamb Sep 20, 2025
ad6eded
update r_configure
jameslamb Sep 20, 2025
6c681d6
more changes
jameslamb Sep 20, 2025
db2dce3
Auto-update configure
github-actions[bot] Sep 20, 2025
c97b4b2
move get-workflow-status to a shell script
jameslamb Sep 20, 2025
0413fb9
submodules not necessary for configure
jameslamb Sep 20, 2025
16c52fc
Merge branch 'fix/comment-triggered-jobs' of github.com:microsoft/Lig…
jameslamb Sep 20, 2025
5439e43
change step name
jameslamb Sep 20, 2025
d411062
more updates
jameslamb Sep 20, 2025
b4dde79
restore CI
jameslamb Sep 20, 2025
d10de26
docs, rename
jameslamb Sep 20, 2025
8a6dd73
merge master
jameslamb Oct 13, 2025
5a9d95c
Merge branch 'master' into fix/comment-triggered-jobs
jameslamb Oct 15, 2025
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
30 changes: 12 additions & 18 deletions .ci/append-comment.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/bash
#
# [description]
# Update comment appending a given body to the specified original comment.
# Post a comment to a pull request.
#
# [usage]
# append-comment.sh <COMMENT_ID> <BODY>
# append-comment.sh <PULL_REQUEST_ID> <BODY>
#
# COMMENT_ID: ID of comment that should be modified.
# PULL_REQUEST_ID: ID of PR to post the comment on.
#
# BODY: Text that will be appended to the original comment body.
# BODY: Text of the comment to be posted.

set -e -E -u -o pipefail

Expand All @@ -18,33 +18,27 @@ if [ -z "$GITHUB_ACTIONS" ]; then
fi

if [ $# -ne 2 ]; then
echo "Usage: $0 <COMMENT_ID> <BODY>"
echo "Usage: $0 <PULL_REQUEST_ID> <BODY>"
exit 1
fi

comment_id=$1
pr_id=$1
body=$2

old_comment_body=$(
curl -sL \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token $SECRETS_WORKFLOW" \
"${GITHUB_API_URL}/repos/microsoft/LightGBM/issues/comments/$comment_id" | \
jq '.body'
)
body=${body/failure/failure ❌}
body=${body/error/failure ❌}
body=${body/cancelled/failure ❌}
body=${body/timed_out/failure ❌}
body=${body/success/success ✔️}
data=$(
jq -n \
--argjson body "${old_comment_body%?}\r\n\r\n$body\"" \
'{"body":$body}'
--argjson body "\"$body\"" \
'{"body": $body}'
)
curl -sL \
-X PATCH \
--fail \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token $SECRETS_WORKFLOW" \
-H "Authorization: token ${GITHUB_TOKEN}" \
-d "$data" \
"${GITHUB_API_URL}/repos/microsoft/LightGBM/issues/comments/$comment_id"
"${GITHUB_API_URL}/repos/microsoft/LightGBM/issues/${pr_id}/comments"
97 changes: 0 additions & 97 deletions .ci/get-workflow-status.py

This file was deleted.

32 changes: 32 additions & 0 deletions .ci/get-workflow-status.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

#
# ./.ci/get-workflow-status.sh 'fix/comment-triggered-jobs' 'r_valgrind.yml'
#

set -e -u -o pipefail

BRANCH="${1}"
WORKFLOW_FILE="${2}"

echo "Searching for latest run of '${WORKFLOW_FILE}' on branch '${BRANCH}'"

LATEST_RUN_ID=$(
gh run list \
--repo "microsoft/LightGBM" \
--branch "${BRANCH}" \
--workflow "${WORKFLOW_FILE}" \
--json 'createdAt,databaseId' \
--jq 'sort_by(.createdAt) | reverse | .[0] | .databaseId'
)

if [[ "${LATEST_RUN_ID}" == "" ]]; then
echo "No runs of '${WORKFLOW_FILE}' found on branch '${BRANCH}'"
exit 0
fi

echo "Checking status of workflow run '${LATEST_RUN_ID}'"
gh run view \
--repo "microsoft/LightGBM" \
--exit-status \
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ensures a non-0 exit code if the last run was not successful.

"${LATEST_RUN_ID}"
4 changes: 2 additions & 2 deletions .ci/rerun-workflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pr_branch=$3
runs=$(
curl -sL \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token $SECRETS_WORKFLOW" \
-H "Authorization: token ${GITHUB_TOKEN}" \
"${GITHUB_API_URL}/repos/microsoft/LightGBM/actions/workflows/${workflow_id}/runs?event=pull_request&branch=${pr_branch}" | \
jq '.workflow_runs'
)
Expand All @@ -42,6 +42,6 @@ if [[ $(echo "${runs}" | jq 'length') -gt 0 ]]; then
curl -sL \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token $SECRETS_WORKFLOW" \
-H "Authorization: token ${GITHUB_TOKEN}" \
"${GITHUB_API_URL}/repos/microsoft/LightGBM/actions/runs/$(echo "${runs}" | jq '.[0].id')/rerun"
fi
3 changes: 2 additions & 1 deletion .ci/set-commit-status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ data=$(
)

curl -sL \
--fail \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token $SECRETS_WORKFLOW" \
-H "Authorization: token ${GITHUB_TOKEN}" \
-d "$data" \
"${GITHUB_API_URL}/repos/microsoft/LightGBM/statuses/$sha"
51 changes: 0 additions & 51 deletions .ci/trigger-dispatch-run.sh

This file was deleted.

25 changes: 10 additions & 15 deletions .github/workflows/optional_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,22 @@ on:

jobs:
all-optional-checks-successful:
timeout-minutes: 120
timeout-minutes: 30
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ github.token }}
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 5
submodules: false
- name: Check that all tests succeeded
- name: Check valgrind workflow
shell: bash
run: |
workflows=(
"R valgrind tests;r-valgrind"
)
for i in "${workflows[@]}"; do
workflow_name=${i%;*}
comment="The last reported status from workflow \"$workflow_name\" is failure."
comment="${comment} Commit fixes and rerun the workflow."
trigger_phrase=${i#*;}
python \
"$GITHUB_WORKSPACE/.ci/get-workflow-status.py" \
"$trigger_phrase" \
|| { echo "${comment}"; exit 1; }
done
# ref: https://docs.github.com/en/actions/reference/workflows-and-actions/contexts#github-context
PR_BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
echo "checking status for branch '${PR_BRANCH}'"
./.ci/get-workflow-status.sh \
"${PR_BRANCH}" \
'r_valgrind.yml'
34 changes: 27 additions & 7 deletions .github/workflows/r_configure.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
name: R generate configure

on:
repository_dispatch:
types: [gha_run_r_configure]
workflow_dispatch:
inputs:
pr-branch:
type: string
description: |
Branch in microsoft/LightGBM to update.

permissions:
actions: none
checks: none
contents: write
deployments: none
discussions: none
id-token: write
issues: none
packages: none
pages: none
pull-requests: read
repository-projects: none
security-events: none
statuses: none

jobs:
r-configure:
Expand All @@ -24,18 +43,19 @@ jobs:
uses: actions/checkout@v5
with:
fetch-depth: 5
submodules: true
submodules: false
repository: microsoft/LightGBM
ref: "refs/heads/${{ fromJSON(github.event.client_payload.pr_branch) }}"
token: ${{ secrets.WORKFLOW }}
ref: "refs/heads/${{ inputs.pr-branch }}"
token: ${{ github.token }}
persist-credentials: true
- name: Update configure
shell: bash
run: ./R-package/recreate-configure.sh || exit 1
- name: Push changes
run: |
git config --global user.name "GitHub Actions Bot"
git config --global user.email "[email protected]"
# source for this user and email: https://github.com/orgs/community/discussions/160496
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add "./R-package/configure"
git commit --allow-empty -m "Auto-update configure"
git push
Loading
Loading