Skip to content
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
6 changes: 3 additions & 3 deletions src/commands/monorepo/set-if-file-changed.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
description: |
Set the given env var to true if a changed file matches one of the given patterns.
The `CHANGED_FILES` environment variable must be set with the `get_changes_files` command prior
to running this command.
The `CHANGED_FILES_FILE` environment variable (a path to the changed-files list, set by the
`get_changed_files` command) must be set prior to running this command.
parameters:
file-patterns:
description: |
Expand All @@ -22,7 +22,7 @@ steps:

<< parameters.target-env-var >>=false
for FILE_PATTERN in ${FILE_PATTERNS?}; do
if egrep "^.\s+$FILE_PATTERN\$" \<<< "$CHANGED_FILES"; then
if egrep "^.\s+$FILE_PATTERN\$" "${CHANGED_FILES_FILE:?}"; then
<< parameters.target-env-var >>=true
echo "Found $FILE_PATTERN in changed files, setting << parameters.target-env-var >> to true"
break
Expand Down
6 changes: 3 additions & 3 deletions src/commands/monorepo/set-service-data-json.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
description: |
Set the service metadata array in a json file.
The `CHANGED_FILES` environment variable must be set with the `get_changes_files` command prior
to running this command.
The `CHANGED_FILES_FILE` environment variable (a path to the changed-files list, set by the
`get_changed_files` command) must be set prior to running this command.
parameters:
service-directories:
description: |
Expand Down Expand Up @@ -36,7 +36,7 @@ steps:

echo "Checking if $SERVICE was modified..."
MODIFIED=false
if grep "$DIRECTORY/$SERVICE" \<<< "${CHANGED_FILES?}"; then
if grep "$DIRECTORY/$SERVICE" "${CHANGED_FILES_FILE:?}"; then
MODIFIED=true
fi
COMPONENT_NAME=$(jq --raw-output ".serviceName" $DIRECTORY/$SERVICE/package.json)
Expand Down
14 changes: 7 additions & 7 deletions src/commands/utils/get_changed_files.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
parameters:
target_env_var:
description: Environment variable to set with the list of changed files
type: env_var_name
default: CHANGED_FILES
target_file:
description: Absolute path to write the list of changed files to. Absolute so it survives consumers that set a custom working_directory (e.g. helm).
type: string
default: /tmp/changed_files.txt
steps:
- run:
name: Put list of changed files in << parameters.target_env_var >> environment variable
name: Write list of changed files to << parameters.target_file >>
command: |
if [[ -z $COMPUTED_BASE_REVISION ]]; then
BASE_REVISION="master"
Expand All @@ -19,5 +19,5 @@ steps:
if [[ $BASE == $CIRCLE_SHA1 ]]; then
BASE="$(git rev-parse HEAD~1)"
fi
FILE_CHANGES="$(git diff --name-status --no-commit-id -r $BASE...$CIRCLE_SHA1)"
echo "export << parameters.target_env_var >>=\"$FILE_CHANGES\"" >> "$BASH_ENV"
git diff --name-status --no-commit-id -r $BASE...$CIRCLE_SHA1 > "<< parameters.target_file >>"
echo "export CHANGED_FILES_FILE=\"<< parameters.target_file >>\"" >> "$BASH_ENV"
6 changes: 3 additions & 3 deletions src/scripts/helm/get_modified_charts.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Expected environment variables:
echo "CHANGED_FILES: ${CHANGED_FILES?}"
echo "CHANGED_FILES_FILE: ${CHANGED_FILES_FILE:?}"
echo "CHART_DIR: ${CHART_DIR:?}"
echo "MODIFIED_CHARTS_ENV: ${MODIFIED_CHARTS_ENV:?}"

Expand All @@ -26,12 +26,12 @@ done
# Extract only modified charts
MODIFIED_CHARTS=()
for CHART in "${ALL_CHARTS[@]}"; do
if grep -q -oP "(M|A)\s*${CHART_DIR}${CHART}/${CHART}/.*" <<< "${CHANGED_FILES?}"; then
if grep -q -oP "(M|A)\s*${CHART_DIR}${CHART}/${CHART}/.*" "${CHANGED_FILES_FILE:?}"; then
MODIFIED_CHARTS+=("$CHART")
fi;
done

echo "${MODIFIED_CHARTS[@]}"

# shellcheck disable=SC2145
echo "export ${MODIFIED_CHARTS_ENV:?}=\"${MODIFIED_CHARTS[@]}\"" >> "$BASH_ENV"
echo "export ${MODIFIED_CHARTS_ENV:?}=\"${MODIFIED_CHARTS[@]}\"" >> "$BASH_ENV"