ci(actions): Replace changed-files (#11130)
This commit is contained in:
parent
f7c1efccaa
commit
ba2ab1e4bb
4 changed files with 120 additions and 62 deletions
93
.github/scripts/set_push_chunks.sh
vendored
93
.github/scripts/set_push_chunks.sh
vendored
|
|
@ -2,6 +2,93 @@
|
|||
|
||||
build_all=false
|
||||
chunks_count=0
|
||||
last_check_files=""
|
||||
last_check_result=""
|
||||
gh_output=""
|
||||
|
||||
# Define the file patterns
|
||||
core_files=(
|
||||
'\.github/.*'
|
||||
'cores/.*'
|
||||
'package/.*'
|
||||
'tools/.*'
|
||||
'platform\.txt'
|
||||
'programmers\.txt'
|
||||
'variants/esp32/.*'
|
||||
'variants/esp32c3/.*'
|
||||
'variants/esp32c6/.*'
|
||||
'variants/esp32h2/.*'
|
||||
'variants/esp32p4/.*'
|
||||
'variants/esp32s2/.*'
|
||||
'variants/esp32s3/.*'
|
||||
)
|
||||
library_files=(
|
||||
'libraries/.*/examples/.*'
|
||||
'libraries/.*/src/.*'
|
||||
)
|
||||
networking_files=(
|
||||
'libraries/Network/src/.*'
|
||||
)
|
||||
fs_files=(
|
||||
'libraries/FS/src/.*'
|
||||
)
|
||||
static_sketches_files=(
|
||||
'libraries/NetworkClientSecure/examples/WiFiClientSecure/WiFiClientSecure\.ino'
|
||||
'libraries/BLE/examples/Server/Server\.ino'
|
||||
'libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer\.ino'
|
||||
'libraries/Insights/examples/MinimalDiagnostics/MinimalDiagnostics\.ino'
|
||||
'libraries/NetworkClientSecure/src/.*'
|
||||
'libraries/BLE/src/.*'
|
||||
'libraries/Insights/src/.*'
|
||||
)
|
||||
idf_files=(
|
||||
'idf_component\.yml'
|
||||
'Kconfig\.projbuild'
|
||||
'CMakeLists\.txt'
|
||||
'variants/esp32c2/.*'
|
||||
)
|
||||
|
||||
# Function to check if any files match the patterns
|
||||
check_files() {
|
||||
local patterns=("$@")
|
||||
local files_found=""
|
||||
for pattern in "${patterns[@]}"; do
|
||||
echo "Checking pattern: $pattern"
|
||||
matched_files=$(echo "$gh_output" | grep -E "$pattern")
|
||||
echo "matched_files: $matched_files"
|
||||
files_found+="$matched_files "
|
||||
done
|
||||
|
||||
last_check_files=$(echo "$files_found" | xargs)
|
||||
if [[ -n $last_check_files ]]; then
|
||||
last_check_result="true"
|
||||
else
|
||||
last_check_result="false"
|
||||
fi
|
||||
echo "last_check_result: $last_check_result"
|
||||
}
|
||||
|
||||
if [[ $IS_PR != 'true' ]]; then
|
||||
gh_output=$(gh api repos/espressif/arduino-esp32/commits/"$GITHUB_SHA" --jq '.files[].filename')
|
||||
else
|
||||
gh_output=$(gh pr diff "$PR_NUM" --name-only)
|
||||
fi
|
||||
echo "gh_output: $gh_output"
|
||||
|
||||
# Output the results
|
||||
check_files "${core_files[@]}"
|
||||
CORE_CHANGED=$last_check_result
|
||||
check_files "${library_files[@]}"
|
||||
LIB_CHANGED=$last_check_result
|
||||
LIB_FILES=$last_check_files
|
||||
check_files "${networking_files[@]}"
|
||||
NETWORKING_CHANGED=$last_check_result
|
||||
check_files "${fs_files[@]}"
|
||||
FS_CHANGED=$last_check_result
|
||||
check_files "${static_sketches_files[@]}"
|
||||
STATIC_SKETCHES_CHANGED=$last_check_result
|
||||
check_files "${idf_files[@]}"
|
||||
IDF_CHANGED=$last_check_result
|
||||
|
||||
if [[ $CORE_CHANGED == 'true' ]] || [[ $IS_PR != 'true' ]]; then
|
||||
echo "Core files changed or not a PR. Building all."
|
||||
|
|
@ -76,9 +163,9 @@ chunks+="]"
|
|||
|
||||
{
|
||||
echo "build_all=$build_all"
|
||||
echo "build_libraries=$BUILD_LIBRARIES"
|
||||
echo "build_static_sketches=$BUILD_STATIC_SKETCHES"
|
||||
echo "build_idf=$BUILD_IDF"
|
||||
echo "build_libraries=$LIB_CHANGED"
|
||||
echo "build_static_sketches=$STATIC_SKETCHES_CHANGED"
|
||||
echo "build_idf=$IDF_CHANGED"
|
||||
echo "chunk_count=$chunks_count"
|
||||
echo "chunks=$chunks"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
|
|
|
|||
18
.github/workflows/build_py_tools.yml
vendored
18
.github/workflows/build_py_tools.yml
vendored
|
|
@ -30,16 +30,16 @@ jobs:
|
|||
echo "Make sure you are using a branch inside the repository and not a fork."
|
||||
|
||||
- name: Verify Python Tools Changed
|
||||
uses: tj-actions/changed-files@v41
|
||||
id: verify-changed-files
|
||||
with:
|
||||
fetch_depth: "2"
|
||||
since_last_remote_commit: "true"
|
||||
files: |
|
||||
tools/get.py
|
||||
tools/espota.py
|
||||
tools/gen_esp32part.py
|
||||
tools/gen_insights_package.py
|
||||
run: |
|
||||
CHANGED_FILES=$(git diff-tree --no-commit-id --name-only -r ^HEAD -- tools/get.py tools/espota.py tools/gen_esp32part.py tools/gen_insights_package.py | xargs)
|
||||
echo "all_changed_files=$CHANGED_FILES" >> $GITHUB_OUTPUT
|
||||
if [ -n "$CHANGED_FILES" ]; then
|
||||
echo "any_changed=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "any_changed=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: List all changed files
|
||||
shell: bash
|
||||
run: |
|
||||
|
|
|
|||
17
.github/workflows/pre-commit.yml
vendored
17
.github/workflows/pre-commit.yml
vendored
|
|
@ -58,7 +58,22 @@ jobs:
|
|||
|
||||
- name: Get changed files
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@v42.0.2
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
PR_NUM: ${{ github.event.pull_request.number }}
|
||||
IS_PR: ${{ github.event_name == 'pull_request' }}
|
||||
GITHUB_SHA: ${{ github.sha }}
|
||||
run: |
|
||||
if [[ $IS_PR != 'true' ]]; then
|
||||
files_changed=$(gh api repos/espressif/arduino-esp32/commits/"$GITHUB_SHA" --jq '.files[].filename' | xargs)
|
||||
else
|
||||
files_changed=$(gh pr diff "$PR_NUM" --name-only | xargs)
|
||||
fi
|
||||
echo "all_changed_files=$files_changed" >> $GITHUB_OUTPUT
|
||||
echo "Changed files:"
|
||||
for file in $files_changed; do
|
||||
echo " $file"
|
||||
done
|
||||
|
||||
- name: Run pre-commit hooks in changed files
|
||||
run: pre-commit run --color=always --show-diff-on-failure --files ${{ steps.changed-files.outputs.all_changed_files }}
|
||||
|
|
|
|||
54
.github/workflows/push.yml
vendored
54
.github/workflows/push.yml
vendored
|
|
@ -45,12 +45,13 @@ on:
|
|||
- "!.github/scripts/tests_*"
|
||||
- "!.github/scripts/upload_*"
|
||||
- "variants/esp32/**/*"
|
||||
- "variants/esp32s2/**/*"
|
||||
- "variants/esp32s3/**/*"
|
||||
- "variants/esp32c2/**/*"
|
||||
- "variants/esp32c3/**/*"
|
||||
- "variants/esp32c6/**/*"
|
||||
- "variants/esp32h2/**/*"
|
||||
- "variants/esp32p4/**/*"
|
||||
- "variants/esp32s2/**/*"
|
||||
- "variants/esp32s3/**/*"
|
||||
|
||||
concurrency:
|
||||
group: build-${{github.event.pull_request.number || github.ref}}
|
||||
|
|
@ -85,58 +86,13 @@ jobs:
|
|||
with:
|
||||
fetch-depth: 2
|
||||
|
||||
- name: Get changed files
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@v44
|
||||
with:
|
||||
files_yaml: |
|
||||
core:
|
||||
- '.github/**'
|
||||
- 'cores/**'
|
||||
- 'package/**'
|
||||
- 'tools/**'
|
||||
- 'platform.txt'
|
||||
- 'programmers.txt'
|
||||
- "variants/esp32/**/*"
|
||||
- "variants/esp32s2/**/*"
|
||||
- "variants/esp32s3/**/*"
|
||||
- "variants/esp32c3/**/*"
|
||||
- "variants/esp32c6/**/*"
|
||||
- "variants/esp32h2/**/*"
|
||||
libraries:
|
||||
- 'libraries/**/examples/**'
|
||||
- 'libraries/**/src/**'
|
||||
networking:
|
||||
- 'libraries/Network/src/**'
|
||||
fs:
|
||||
- 'libraries/FS/src/**'
|
||||
static_sketeches:
|
||||
- 'libraries/NetworkClientSecure/examples/WiFiClientSecure/WiFiClientSecure.ino'
|
||||
- 'libraries/BLE/examples/Server/Server.ino'
|
||||
- 'libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino'
|
||||
- 'libraries/Insights/examples/MinimalDiagnostics/MinimalDiagnostics.ino'
|
||||
- 'libraries/NetworkClientSecure/src/**'
|
||||
- 'libraries/BLE/src/**'
|
||||
- 'libraries/Insights/src/**'
|
||||
idf:
|
||||
- 'idf_component.yml'
|
||||
- 'Kconfig.projbuild'
|
||||
- 'CMakeLists.txt'
|
||||
- "variants/esp32c2/**/*"
|
||||
|
||||
- name: Set chunks
|
||||
id: set-chunks
|
||||
env:
|
||||
LIB_FILES: ${{ steps.changed-files.outputs.libraries_all_changed_files }}
|
||||
IS_PR: ${{ github.event_name == 'pull_request' }}
|
||||
PR_NUM: ${{ github.event.pull_request.number }}
|
||||
MAX_CHUNKS: ${{ env.MAX_CHUNKS }}
|
||||
BUILD_IDF: ${{ steps.changed-files.outputs.idf_any_changed == 'true' }}
|
||||
BUILD_LIBRARIES: ${{ steps.changed-files.outputs.libraries_any_changed == 'true' }}
|
||||
BUILD_STATIC_SKETCHES: ${{ steps.changed-files.outputs.static_sketeches_any_changed == 'true' }}
|
||||
FS_CHANGED: ${{ steps.changed-files.outputs.fs_any_changed == 'true' }}
|
||||
NETWORKING_CHANGED: ${{ steps.changed-files.outputs.networking_any_changed == 'true' }}
|
||||
CORE_CHANGED: ${{ steps.changed-files.outputs.core_any_changed == 'true' }}
|
||||
LIB_CHANGED: ${{ steps.changed-files.outputs.libraries_any_changed == 'true' }}
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
bash ./.github/scripts/set_push_chunks.sh
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue