mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
feat: Added pre-commit hook of PowerShell scrip checker
This commit is contained in:
parent
aa27fbd231
commit
8f383060dd
2
.github/workflows/pre_commit_check.yml
vendored
2
.github/workflows/pre_commit_check.yml
vendored
@ -40,3 +40,5 @@ jobs:
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
# Run pre-commit for PowerShell scripts check
|
||||
pre-commit run --hook-stage manual check-powershell-scripts --from-ref base_ref --to-ref pr_ref --show-diff-on-failure
|
||||
|
@ -170,6 +170,7 @@
|
||||
/docs/**/api-reference/system/ @esp-idf-codeowners/system
|
||||
/docs/**/security/ @esp-idf-codeowners/security
|
||||
/docs/**/migration-guides/ @esp-idf-codeowners/docs @esp-idf-codeowners/all-maintainers
|
||||
/docs/**/contribute/install-pre-commit-hook.rst @esp-idf-codeowners/ci @esp-idf-codeowners/tools
|
||||
|
||||
/examples/README.md @esp-idf-codeowners/docs @esp-idf-codeowners/ci
|
||||
/examples/**/*.py @esp-idf-codeowners/ci @esp-idf-codeowners/tools
|
||||
|
@ -45,3 +45,36 @@ check_pre_commit:
|
||||
paths:
|
||||
- .cache/submodule_archives
|
||||
policy: pull
|
||||
|
||||
check_powershell:
|
||||
extends:
|
||||
- .before_script:minimal
|
||||
stage: pre_check
|
||||
image: docker:latest
|
||||
services:
|
||||
- docker:dind
|
||||
tags:
|
||||
- dind
|
||||
- amd64
|
||||
needs:
|
||||
- pipeline_variables
|
||||
variables:
|
||||
# cache pre_commit
|
||||
PRE_COMMIT_HOME: "$CI_PROJECT_DIR/.cache/pre-commit"
|
||||
rules:
|
||||
- changes:
|
||||
- "*.ps1"
|
||||
script:
|
||||
- apk add python3
|
||||
- apk add py3-pip
|
||||
- pip install pre-commit --break-system-packages
|
||||
- pre-commit run --hook-stage manual check-powershell-scripts --files $MODIFIED_FILES
|
||||
cache:
|
||||
- key: pre_commit-cache-${LATEST_GIT_TAG}
|
||||
paths:
|
||||
- .cache/pre-commit
|
||||
policy: pull
|
||||
- key: submodule-cache-${LATEST_GIT_TAG}
|
||||
paths:
|
||||
- .cache/submodule_archives
|
||||
policy: pull
|
||||
|
@ -224,6 +224,11 @@ repos:
|
||||
name: shellcheck dash (export.sh)
|
||||
args: ['--shell', 'dash', '-x']
|
||||
files: 'export.sh'
|
||||
- repo: https://github.com/espressif/esp-pwsh-check
|
||||
rev: v1.0.1
|
||||
hooks:
|
||||
- id: check-powershell-scripts
|
||||
stages: [manual]
|
||||
- repo: https://github.com/espressif/esp-idf-sbom.git
|
||||
rev: v0.13.0
|
||||
hooks:
|
||||
|
@ -3,13 +3,6 @@ Install Pre-commit Hook for ESP-IDF Project
|
||||
|
||||
:link_to_translation:`zh_CN:[中文]`
|
||||
|
||||
Required Dependency
|
||||
-------------------
|
||||
|
||||
Python 3.8.* or above. This is our recommended Python version for ESP-IDF developers.
|
||||
|
||||
If you still have Python versions not compatible, update your Python versions before installing the pre-commit hook.
|
||||
|
||||
Install ``pre-commit``
|
||||
----------------------
|
||||
|
||||
|
@ -3,12 +3,6 @@
|
||||
|
||||
:link_to_translation:`en:[English]`
|
||||
|
||||
环境依赖
|
||||
---------------
|
||||
|
||||
我们向 IDF 开发人员推荐 Python 3.8.* 及以上版本。
|
||||
|
||||
如果你已安装了不兼容的 Python 版本,应在安装 pre-commit 工具前进行更新。
|
||||
|
||||
安装 ``pre-commit`` 工具
|
||||
---------------------------
|
||||
|
@ -26,10 +26,10 @@ foreach ($line in $envars_raw) {
|
||||
$envars_array += (, ($var_name, $var_val))
|
||||
}
|
||||
|
||||
if ($IsWindows -eq $null) {
|
||||
if ($null -eq $IsWindows) {
|
||||
# $IsWindows was added in PowerShell Core 6 and PowerShell 7 together with multi-platform support. # I.E. if this
|
||||
# internal variable is not set then PowerShell 5 is used and # the platform cannot be # anything else than Windows.
|
||||
$IsWindows = $true
|
||||
$Windows = $true
|
||||
}
|
||||
|
||||
foreach ($pair in $envars_array) {
|
||||
@ -38,7 +38,7 @@ foreach ($pair in $envars_array) {
|
||||
$var_val = $pair[1].Trim() # trim spaces on the ends of the val
|
||||
if ($var_name -eq "PATH") {
|
||||
# trim "%PATH%" or "`$PATH"
|
||||
if ($IsWindows) {
|
||||
if ($IsWindows || $Windows) {
|
||||
$var_val = $var_val.Trim($S + "%PATH%")
|
||||
} else {
|
||||
$var_val = $var_val.Trim($S + "`$PATH")
|
||||
@ -60,7 +60,7 @@ function parttool.py { &python "$IDF_PATH\components\partition_table\parttool.py
|
||||
#Compare Path's OLD vs. NEW
|
||||
$NEW_PATH = $env:PATH.split($S) | Select-Object -Unique # array without duplicates
|
||||
$dif_Path = Compare-Object -ReferenceObject $OLD_PATH -DifferenceObject $NEW_PATH -PassThru
|
||||
if ($dif_Path -ne $null) {
|
||||
if ($null -ne $dif_Path) {
|
||||
Write-Output "`nAdded to PATH`n-------------"
|
||||
Write-Output $dif_Path
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user