From 422a73ad7dc033b7e5e24a44a3b136351b86da1e Mon Sep 17 00:00:00 2001 From: "Aaron (\"AJ\") Steers" Date: Tue, 29 Apr 2025 18:11:25 -0700 Subject: [PATCH] chore: add poe `get-modified-connectors` task (#59130) --- poe-tasks/README.md | 5 ++++ poe-tasks/get-modified-connectors.sh | 41 ++++++++++++++++++++++++++++ poe_tasks.toml | 5 ++++ 3 files changed, 51 insertions(+) create mode 100644 poe-tasks/README.md create mode 100755 poe-tasks/get-modified-connectors.sh diff --git a/poe-tasks/README.md b/poe-tasks/README.md new file mode 100644 index 00000000000..681d07e9cc0 --- /dev/null +++ b/poe-tasks/README.md @@ -0,0 +1,5 @@ +# Poe Tasks Directory + +This directory stores scripts and task definitions that are intended to be executed from the PoeThePoet task manager. + +You may be able to run them directly, although it is probably easier to run via `poe`. diff --git a/poe-tasks/get-modified-connectors.sh b/poe-tasks/get-modified-connectors.sh new file mode 100755 index 00000000000..ffa459f9e42 --- /dev/null +++ b/poe-tasks/get-modified-connectors.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +# This script is used to find all modified connector directories in the Airbyte repository. +# It compares the current branch with the default branch and filters out files that match certain ignore patterns. + +DEFAULT_BRANCH="master" + +# 1) update remote default branch quietly +git fetch --quiet origin $DEFAULT_BRANCH + +# 2) set up ignore patterns +ignore_patterns=( + 'README.md' + '.coveragerc' +) +# join with | into a grouped regex +ignore_globs="($(IFS='|'; echo "${ignore_patterns[*]}"))$" +# 3) collect all file changes +committed=$(git diff --name-only origin/$DEFAULT_BRANCH...HEAD) +staged=$(git diff --cached --name-only) +unstaged=$(git diff --name-only) +untracked=$(git ls-files --others --exclude-standard) + +# 4) merge into one list +all_changes=$(printf '%s\n%s\n%s\n%s' "$committed" "$staged" "$unstaged" "$untracked") + +# 5) drop ignored files +filtered=$(printf '%s\n' "$all_changes" | grep -v -E "/${ignore_globs}") + +# 6) keep only connector paths +connectors=$(printf '%s\n' "$filtered" | grep -E '^airbyte-integrations/connectors/[^/]+' ) + +# 7) extract just the connector directory name +dirs=$(printf '%s\n' "$connectors" \ + | sed -E 's|airbyte-integrations/connectors/([^/]+).*|\1|' +) + +# 8) output sorted, unique list +if [ "$dirs" ]; then + printf '%s\n' "$dirs" | sort -u +fi diff --git a/poe_tasks.toml b/poe_tasks.toml index 3a739169345..1e2124697ec 100644 --- a/poe_tasks.toml +++ b/poe_tasks.toml @@ -22,6 +22,11 @@ pnpm install pnpm build ''' +[tasks.get-modified-connectors] +help = """List Airbyte connectors modified. This considers all committed, staged, unstaged, and untracked files. +""" +shell = "./poe-tasks/get-modified-connectors.sh" + [tasks.connector] help = "Run a poe task in a connector's directory. Usage: poe connector [args...]"