From be35714b1046c0c4ec78fe82a2e0459623d53a98 Mon Sep 17 00:00:00 2001 From: Andrea Bueide Date: Fri, 8 May 2026 15:31:37 -0500 Subject: [PATCH 1/2] fix(ci): use direct script invocation for paths-filter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Composite actions don't propagate dynamic step outputs to the caller — only explicitly declared outputs are visible. Since filter keys are dynamic, switch to calling paths-filter.sh directly in the workflow step so outputs write to the caller's GITHUB_OUTPUT natively. --- .github/actions/paths-filter/action.yml | 89 +++++--------------- .github/actions/paths-filter/paths-filter.sh | 82 ++++++++++++++++++ .github/workflows/pr-checks.yml | 7 +- 3 files changed, 105 insertions(+), 73 deletions(-) create mode 100755 .github/actions/paths-filter/paths-filter.sh diff --git a/.github/actions/paths-filter/action.yml b/.github/actions/paths-filter/action.yml index a31faba..87a6eb1 100644 --- a/.github/actions/paths-filter/action.yml +++ b/.github/actions/paths-filter/action.yml @@ -1,5 +1,20 @@ name: Paths Filter -description: Detect which paths changed between the PR base and HEAD using native git diff. Drop-in replacement for dorny/paths-filter without external dependencies. +description: | + Detect which paths changed between the PR base and HEAD using native git diff. + Drop-in replacement for dorny/paths-filter without external dependencies. + + NOTE: For outputs to propagate correctly, prefer calling the script directly + in your workflow step rather than using this as a composite action: + + - name: Detect changed paths + id: filter + env: + FILTER_DEFINITIONS: | + src: + - '^src/' + run: bash .github/actions/paths-filter/paths-filter.sh + + Each filter key becomes a step output with value 'true' or 'false'. inputs: filters: @@ -17,11 +32,6 @@ inputs: required: false default: '' -outputs: - result: - description: JSON object of all filter results - value: ${{ steps.filter.outputs.result }} - runs: using: composite steps: @@ -29,67 +39,6 @@ runs: id: filter shell: bash env: - INPUT_FILTERS: ${{ inputs.filters }} - INPUT_BASE: ${{ inputs.base }} - run: | - set -euo pipefail - - # Determine base commit - if [ -n "$INPUT_BASE" ]; then - BASE="$INPUT_BASE" - elif [ "${{ github.event_name }}" = "pull_request" ]; then - BASE="${{ github.event.pull_request.base.sha }}" - else - BASE="HEAD~1" - fi - - # Get list of changed files - CHANGED_FILES=$(git diff --name-only "$BASE"...HEAD 2>/dev/null || git diff --name-only "$BASE" HEAD) - - if [ -z "$CHANGED_FILES" ]; then - echo "No changed files detected" - else - echo "Changed files (first 50):" - echo "$CHANGED_FILES" | head -50 - fi - - # Parse filters and collect results - declare -A RESULTS - CURRENT_KEY="" - - while IFS= read -r line; do - [ -z "$(echo "$line" | tr -d '[:space:]')" ] && continue - - if echo "$line" | grep -qE '^[a-zA-Z_][a-zA-Z0-9_-]*:'; then - CURRENT_KEY=$(echo "$line" | sed 's/:.*$//' | tr -d '[:space:]') - RESULTS["$CURRENT_KEY"]="false" - continue - fi - - if [ -n "$CURRENT_KEY" ] && echo "$line" | grep -qE '^\s*-'; then - PATTERN=$(echo "$line" | sed "s/^[[:space:]]*-[[:space:]]*//;s/^['\"]//;s/['\"]$//") - PATTERN=$(echo "$PATTERN" | tr -d '[:space:]') - [ -z "$PATTERN" ] && continue - - if [ -n "$CHANGED_FILES" ] && echo "$CHANGED_FILES" | grep -qE "$PATTERN"; then - RESULTS["$CURRENT_KEY"]="true" - fi - fi - done <<< "$INPUT_FILTERS" - - # Write outputs - JSON="{" - FIRST=true - for key in "${!RESULTS[@]}"; do - echo "${key}=${RESULTS[$key]}" >> "$GITHUB_OUTPUT" - if [ "$FIRST" = true ]; then - FIRST=false - else - JSON="$JSON," - fi - JSON="$JSON\"$key\":\"${RESULTS[$key]}\"" - done - JSON="$JSON}" - - echo "result=$JSON" >> "$GITHUB_OUTPUT" - echo "Filter results: $JSON" + FILTER_DEFINITIONS: ${{ inputs.filters }} + FILTER_BASE: ${{ inputs.base }} + run: bash ${{ github.action_path }}/paths-filter.sh diff --git a/.github/actions/paths-filter/paths-filter.sh b/.github/actions/paths-filter/paths-filter.sh new file mode 100755 index 0000000..1f1c09e --- /dev/null +++ b/.github/actions/paths-filter/paths-filter.sh @@ -0,0 +1,82 @@ +#!/usr/bin/env bash +# Detect which paths changed between a base ref and HEAD. +# Writes each filter key as a GITHUB_OUTPUT with value 'true' or 'false'. +# +# Required env: +# FILTER_DEFINITIONS - YAML-style filter block (key: \n - 'pattern') +# GITHUB_OUTPUT - set by GitHub Actions runner +# +# Optional env: +# FILTER_BASE - explicit base ref to diff against +# +# Usage in a workflow step: +# - name: Detect changes +# id: filter +# env: +# FILTER_DEFINITIONS: | +# android: +# - '^plugins/android/' +# - '^examples/android/' +# ios: +# - '^plugins/ios/' +# run: bash .github/actions/paths-filter/paths-filter.sh +set -euo pipefail + +# Determine base commit +if [ -n "${FILTER_BASE:-}" ]; then + BASE="$FILTER_BASE" +elif [ "${GITHUB_EVENT_NAME:-}" = "pull_request" ]; then + BASE=$(jq -r '.pull_request.base.sha' "$GITHUB_EVENT_PATH") +else + BASE="HEAD~1" +fi + +# Get list of changed files +CHANGED_FILES=$(git diff --name-only "$BASE"...HEAD 2>/dev/null || git diff --name-only "$BASE" HEAD) + +if [ -z "$CHANGED_FILES" ]; then + echo "No changed files detected" +else + echo "Changed files (first 50):" + echo "$CHANGED_FILES" | head -50 +fi + +# Parse filters and collect results +declare -A RESULTS +CURRENT_KEY="" + +while IFS= read -r line; do + [ -z "$(echo "$line" | tr -d '[:space:]')" ] && continue + + if echo "$line" | grep -qE '^[a-zA-Z_][a-zA-Z0-9_-]*:'; then + CURRENT_KEY=$(echo "$line" | sed 's/:.*$//' | tr -d '[:space:]') + RESULTS["$CURRENT_KEY"]="false" + continue + fi + + if [ -n "$CURRENT_KEY" ] && echo "$line" | grep -qE '^\s*-'; then + PATTERN=$(echo "$line" | sed "s/^[[:space:]]*-[[:space:]]*//;s/^['\"]//;s/['\"]$//") + PATTERN=$(echo "$PATTERN" | tr -d '[:space:]') + [ -z "$PATTERN" ] && continue + + if [ -n "$CHANGED_FILES" ] && echo "$CHANGED_FILES" | grep -qE "$PATTERN"; then + RESULTS["$CURRENT_KEY"]="true" + fi + fi +done <<< "$FILTER_DEFINITIONS" + +# Write outputs +JSON="{" +FIRST=true +for key in "${!RESULTS[@]}"; do + echo "${key}=${RESULTS[$key]}" >> "$GITHUB_OUTPUT" + if [ "$FIRST" = true ]; then + FIRST=false + else + JSON="$JSON," + fi + JSON="$JSON\"$key\":\"${RESULTS[$key]}\"" +done +JSON="$JSON}" + +echo "Filter results: $JSON" diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index b7445ea..1f9f58a 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -26,10 +26,10 @@ jobs: - uses: actions/checkout@v6 with: fetch-depth: 0 - - uses: ./.github/actions/paths-filter + - name: Detect changed paths id: filter - with: - filters: | + env: + FILTER_DEFINITIONS: | segkit: - '^segkit/' android: @@ -48,6 +48,7 @@ jobs: - '^plugins/.*/scripts/' ci: - '^\.github/' + run: bash .github/actions/paths-filter/paths-filter.sh # Linting and formatting checks (always runs) lint: From 20f7e5bd409c1f2236f04d0eb9980b33b35cdd93 Mon Sep 17 00:00:00 2001 From: Andrea Bueide Date: Fri, 8 May 2026 15:43:02 -0500 Subject: [PATCH 2/2] fix(ci): correct segkit path in rewrite-plugin-urls.sh The script was rewriting the segkit flake ref to path:./segkit which resolves relative to the plugin directory (plugins/android/). Since segkit/ lives at repo root, the correct relative path is ../../segkit. --- scripts/dev/rewrite-plugin-urls.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/dev/rewrite-plugin-urls.sh b/scripts/dev/rewrite-plugin-urls.sh index de067f6..97c7abc 100755 --- a/scripts/dev/rewrite-plugin-urls.sh +++ b/scripts/dev/rewrite-plugin-urls.sh @@ -71,8 +71,9 @@ case "$mode" in if [ -f "$plugin_file" ] && grep -q "$segkit_github" "$plugin_file"; then echo " Rewriting segkit ref in: $plugin_file" # Replace the github flake ref with a local path ref + # segkit/ is at repo root, plugins are at plugins// jq --arg gh "$segkit_github" '.packages = (.packages | to_entries | map( - if .key == $gh then .key = "path:./segkit" else . end + if .key == $gh then .key = "path:../../segkit" else . end ) | from_entries)' "$plugin_file" > "$plugin_file.tmp" \ && mv "$plugin_file.tmp" "$plugin_file" fi @@ -133,10 +134,10 @@ case "$mode" in # Restore segkit package references in plugin.json files segkit_github="github:segment-integrations/mobile-devtools?dir=segkit&ref=main" for plugin_file in plugins/android/plugin.json plugins/ios/plugin.json; do - if [ -f "$plugin_file" ] && grep -q "path:./segkit" "$plugin_file"; then + if [ -f "$plugin_file" ] && grep -q "path:../../segkit" "$plugin_file"; then echo " Restoring segkit ref in: $plugin_file" jq --arg gh "$segkit_github" '.packages = (.packages | to_entries | map( - if .key == "path:./segkit" then .key = $gh else . end + if .key == "path:../../segkit" then .key = $gh else . end ) | from_entries)' "$plugin_file" > "$plugin_file.tmp" \ && mv "$plugin_file.tmp" "$plugin_file" fi