Skip to content

Commit

Permalink
Merge pull request #1014 from lemeurherve/run-tests-if-gha-modified
Browse files Browse the repository at this point in the history
chore(GHA/test): run tests on all charts if this workflow is modified
  • Loading branch information
dduportal authored Jan 11, 2024
2 parents 5bea4cc + c24d10f commit a4a4f82
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,19 @@ jobs:
env:
GH_TOKEN: ${{ github.token }}
run: |
allChartsPaths=$(find . -maxdepth 2 -type d | grep "charts/" | cut -d "/" -f2-3 | sort --unique)
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
# Retrieve the list of modified chart names in the pull request
modifiedChartPaths=$(gh pr view ${{ github.event.pull_request.number }} --json files -q '.files[].path' | xargs dirname | grep "^charts/" | cut -d "/" -f1-2 | sort --unique)
else
# Retrieve all charts
modifiedChartPaths=$(find . -maxdepth 2 -type d | grep "charts/" | cut -d "/" -f2-3 | sort --unique)
modifiedChartPaths=$allChartsPaths
fi
# Test all charts if this workflow is modified
modifiedWorkflow=$(gh pr view ${{ github.event.pull_request.number }} --json files -q '.files[].path' | grep ".github/workflows/test.yml")
if [ -n "${modifiedWorkflow}" ]; then
modifiedChartPaths=$allChartsPaths
fi
# Keep only modified charts with unit tests
Expand Down

0 comments on commit a4a4f82

Please sign in to comment.