diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 66d26df8cf20..34235009a792 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -330,6 +330,16 @@ jobs: cd src/github.com/goharbor/harbor bash ./tests/showtime.sh ./tests/ci/ui_ut_run.sh df -h + - name: Check for formatting issues + run: | + cd src/github.com/goharbor/harbor + git diff --exit-code + continue-on-error: true # continue workflow + - 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 1a1ff395c65b..ec71dec4725b 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 -