From 51dc32f8186b42228d8bdf680ceec499ef901a6e Mon Sep 17 00:00:00 2001 From: bupd Date: Thu, 10 Oct 2024 08:21:09 +0530 Subject: [PATCH] update ui format github action * Updated 'ui_ut_run.sh' script to enforce formatting Signed-off-by: bupd --- .github/workflows/CI.yml | 5 +++++ tests/ci/ui_ut_run.sh | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 66d26df8cf2..3d7ca7da233 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -330,6 +330,11 @@ jobs: cd src/github.com/goharbor/harbor bash ./tests/showtime.sh ./tests/ci/ui_ut_run.sh df -h + - name: Fail if format changes are detected + if: ${{ failure() }} + run: | + echo "Code formatting issues detected. Please run 'npm run format' locally and commit the changes." + exit 1 - name: Codecov For UI uses: codecov/codecov-action@v4 with: diff --git a/tests/ci/ui_ut_run.sh b/tests/ci/ui_ut_run.sh index 1a1ff395c65..ec71dec4725 100755 --- a/tests/ci/ui_ut_run.sh +++ b/tests/ci/ui_ut_run.sh @@ -6,7 +6,17 @@ cd ./src/portal npm install -g -q --no-progress @angular/cli npm install -g -q --no-progress karma npm install -q --no-progress -# check code lint first then run ut test + +# Run format and check for changes +npm run format + +# Check if any files were changed by formatting +if [[ -n $(git status --porcelain) ]]; then + echo "Formatting issues found. Please run 'npm run format' and commit the changes." + exit 1 +fi + +# Lint and run tests npm run lint npm run lint:style npm run test && cd -