Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ColossalAI
Commits
57b6157b
"git@developer.sourcefind.cn:OpenDAS/colossalai.git" did not exist on "50cdf5430ed41e9a01128c9424bfbffe28ee4a78"
Unverified
Commit
57b6157b
authored
Jan 10, 2023
by
Frank Lee
Committed by
GitHub
Jan 10, 2023
Browse files
[workflow] auto comment if precommit check fails (#2417)
parent
2445279a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
6 deletions
+80
-6
.github/workflows/auto_example_check.yml
.github/workflows/auto_example_check.yml
+0
-3
.github/workflows/build.yml
.github/workflows/build.yml
+0
-1
.github/workflows/comment.yml
.github/workflows/comment.yml
+67
-0
.github/workflows/pre_commit.yml
.github/workflows/pre_commit.yml
+13
-2
No files found.
.github/workflows/auto_example_check.yml
View file @
57b6157b
...
...
@@ -28,9 +28,6 @@ jobs:
-
name
:
Get all changed example files
id
:
changed-files
uses
:
tj-actions/changed-files@v35
# Using this can trigger action each time a PR is submitted.
with
:
since_last_remote_commit
:
true
-
name
:
setup matrix
id
:
setup-matrix
run
:
|
...
...
.github/workflows/build.yml
View file @
57b6157b
...
...
@@ -25,7 +25,6 @@ jobs:
id
:
find-changed-files
uses
:
tj-actions/changed-files@v35
with
:
since_last_remote_commit
:
true
files
:
|
op_builder/**
colossalai/kernel/**
...
...
.github/workflows/comment.yml
0 → 100644
View file @
57b6157b
name
:
Auto Workflow Comment
on
:
workflow_run
:
workflows
:
[
pre-commit
]
types
:
-
completed
jobs
:
# comment with a message on how to do pre-commit
# if the pre-commit check was not passed
report-precommit-failure
:
runs-on
:
ubuntu-latest
if
:
${{ github.event.workflow_run.name }} == "pre-commit" && ${{ github.event.workflow_run.conclusion == 'failure' }}
steps
:
-
name
:
'
Download
artifact'
uses
:
actions/github-script@v6
with
:
script
:
|
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "pr_number"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr_number.zip`, Buffer.from(download.data));
-
name
:
'
Unzip
artifact'
run
:
unzip pr_number.zip
-
name
:
'
Comment
on
PR'
uses
:
actions/github-script@v6
with
:
github-token
:
${{ secrets.GITHUB_TOKEN }}
script
:
|
let fs = require('fs');
let issue_number = Number(fs.readFileSync('./pr_number'));
let owner = context.repo.owner;
let repo = context.repo.repo;
let run_id = context.payload.workflow_run.id;
let run_url = `https://github.com/${owner}/${repo}/actions/runs/${run_id}`
let body = `
Your pre-commit check failed, follow the steps to run pre-commit on your file for code style consistency.
1. install pre-commit via "pip install pre-commit"
2. install pre-commit hooks via "pre-commit install"
3. run pre-commit on file with format error via "pre-commit run --files path" by replacing "path" with the actual file path
4. commit and push to your branch
View your job at ${run_url}.
Read our "CONTRIBUTING.md" for more reference to the code style.
`;
await github.rest.issues.createComment({
owner: owner,
repo: repo,
issue_number: issue_number,
body: body
});
.github/workflows/pre_commit.yml
View file @
57b6157b
...
...
@@ -15,8 +15,6 @@ jobs:
-
name
:
Find the changed files
id
:
find-changed-files
uses
:
tj-actions/changed-files@v35
with
:
since_last_remote_commit
:
true
-
name
:
List all changed files
run
:
|
...
...
@@ -44,3 +42,16 @@ jobs:
echo "======= running pre-commit on ${file} ======="
pre-commit run --files $file
done
-
name
:
Save PR number
if
:
always()
env
:
PR_NUMBER
:
${{ github.event.number }}
run
:
|
mkdir -p ./pr
echo $PR_NUMBER > ./pr/pr_number
-
uses
:
actions/upload-artifact@v3
if
:
always()
with
:
name
:
pr_number
path
:
pr/
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment