Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(actions): Replace changed-files #11130

Merged
merged 1 commit into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
93 changes: 90 additions & 3 deletions .github/scripts/set_push_chunks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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 changes: 9 additions & 9 deletions .github/workflows/build_py_tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
54 changes: 5 additions & 49 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down Expand Up @@ -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

Expand Down