Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-esp32
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-esp32
Commits
2c398774
Unverified
Commit
2c398774
authored
Apr 19, 2024
by
Lucas Saavedra Vaz
Committed by
GitHub
Apr 19, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ci(pre-commit): Fix PR checks and cache (#9531)
parent
4960d86b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
30 deletions
+63
-30
.github/workflows/pre-commit-status.yml
.github/workflows/pre-commit-status.yml
+51
-28
.github/workflows/pre-commit.yml
.github/workflows/pre-commit.yml
+12
-2
No files found.
.github/workflows/pre-commit-status.yml
View file @
2c398774
# This needs to be in a separate workflow because it requires higher permissions than the calling workflow
name
:
Report Pre-commit Check Status
on
:
pull_request_target
:
types
:
[
opened
,
reopened
,
synchronize
,
labeled
,
unlabeled
]
workflow_run
:
workflows
:
[
Pre-commit hooks
]
types
:
-
completed
permissions
:
statuses
:
write
jobs
:
report-run
:
name
:
Check if the PR has run the pre-commit checks
report-success
:
name
:
Report pre-commit success
if
:
github.event.workflow_run.conclusion == 'success'
runs-on
:
ubuntu-latest
steps
:
-
name
:
Report pending
uses
:
conda/actions/set-commit-status@v24.2.0
with
:
context
:
"
Pre-commit
checks"
state
:
pending
description
:
The pre-commit checks need to be successful before merging
-
name
:
Wait for pre-commit checks to complete
uses
:
lucasssvaz/wait-on-workflow@v1
if
:
|
contains(github.event.pull_request.labels.*.name, 'Status: Pending Merge')
id
:
wait-on-workflow
-
name
:
Report success
uses
:
actions/github-script@v7
with
:
timeout
:
10
interval
:
30
workflow
:
pre-commit.yml
sha
:
${{ github.event.pull_request.head.sha || github.sha }}
script
:
|
const owner = '${{ github.repository_owner }}';
const repo = '${{ github.repository }}'.split('/')[1];
const sha = '${{ github.event.workflow_run.head_sha }}';
core.debug(`owner: ${owner}`);
core.debug(`repo: ${repo}`);
core.debug(`sha: ${sha}`);
const { context: name, state } = (await github.rest.repos.createCommitStatus({
context: 'Pre-commit checks',
description: 'Pre-commit checks successful',
owner: owner,
repo: repo,
sha: sha,
state: 'success',
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}'
})).data;
core.info(`${name} is ${state}`);
-
name
:
Report success
uses
:
conda/actions/set-commit-status@v24.2.0
if
:
|
contains(github.event.pull_request.labels.*.name, 'Status: Pending Merge') &&
steps.wait-on-workflow.outputs.conclusion == 'success'
report-pending
:
name
:
Report pre-commit pending
if
:
github.event.workflow_run.conclusion != 'success'
runs-on
:
ubuntu-latest
steps
:
-
name
:
Report pending
uses
:
actions/github-script@v7
with
:
context
:
"
Pre-commit
checks"
state
:
success
description
:
All pre-commit checks passed
script
:
|
const owner = '${{ github.repository_owner }}';
const repo = '${{ github.repository }}'.split('/')[1];
const sha = '${{ github.event.workflow_run.head_sha }}';
core.debug(`owner: ${owner}`);
core.debug(`repo: ${repo}`);
core.debug(`sha: ${sha}`);
const { context: name, state } = (await github.rest.repos.createCommitStatus({
context: 'Pre-commit checks',
description: 'The pre-commit checks need to be successful before merging',
owner: owner,
repo: repo,
sha: sha,
state: 'pending',
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}'
})).data;
core.info(`${name} is ${state}`);
.github/workflows/pre-commit.yml
View file @
2c398774
name
:
Pre-commit hooks
on
:
workflow_dispatch
:
push
:
branches
:
-
master
pull_request
:
types
:
[
opened
,
reopened
,
synchronize
,
labeled
,
unlabeled
]
concurrency
:
group
:
pre-commit-${{github.event.pull_request.number || github.ref}}
cancel-in-progress
:
true
jobs
:
lint
:
if
:
|
contains(github.event.pull_request.labels.*.name, 'Status: Pending Merge')
contains(github.event.pull_request.labels.*.name, 'Status: Pending Merge') ||
github.event_name != 'pull_request'
name
:
Check if fixes are needed
runs-on
:
ubuntu-latest
steps
:
...
...
@@ -57,6 +66,7 @@ jobs:
-
name
:
Push changes using pre-commit-ci-lite
uses
:
pre-commit-ci/lite-action@v1.0.2
if
:
always()
# Only push changes in PRs
if
:
${{ always() && github.event_name == 'pull_request' }}
with
:
msg
:
"
ci(pre-commit):
Apply
automatic
fixes"
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