From 99eb214c72a48965c4ef3b62ed7b0ad014aff651 Mon Sep 17 00:00:00 2001 From: Piotr Jurczynski <619650+pjurczynski@users.noreply.github.com> Date: Wed, 9 Jul 2025 11:53:22 +0200 Subject: [PATCH 1/5] Replace separate lint step with quality checks in CI workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The quality script already includes linting along with other comprehensive code quality checks (complexity, duplication, code smells, etc.), so the separate lint step is redundant. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 37919f4..b7e7bfc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,8 +25,8 @@ jobs: - name: Install dependencies run: npm ci - - name: Run linter - run: npm run lint + - name: Run quality checks + run: npm run quality:baseline:status - name: Run tests run: npm test From 21b663c5e6906ec60f069e7942ee95013cf07d8a Mon Sep 17 00:00:00 2001 From: Piotr Jurczynski <619650+pjurczynski@users.noreply.github.com> Date: Wed, 9 Jul 2025 23:34:09 +0200 Subject: [PATCH 2/5] Run quality checks only on changed files in CI workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/workflows/ci.yml | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b7e7bfc..ab000f9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,8 +25,27 @@ jobs: - name: Install dependencies run: npm ci - - name: Run quality checks - run: npm run quality:baseline:status + - name: Run quality checks on changed files + run: | + if [ "${{ github.event_name }}" == "pull_request" ]; then + # Get changed .ts files in the PR + CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep '\.ts$' | tr '\n' ' ') + if [ -n "$CHANGED_FILES" ]; then + echo "Running quality checks on changed files: $CHANGED_FILES" + npm run quality -- $CHANGED_FILES + else + echo "No TypeScript files changed, skipping quality checks" + fi + else + # For push events, run on files changed in the current commit + CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD | grep '\.ts$' | tr '\n' ' ') + if [ -n "$CHANGED_FILES" ]; then + echo "Running quality checks on files changed in current commit: $CHANGED_FILES" + npm run quality -- $CHANGED_FILES + else + echo "No TypeScript files changed in current commit, skipping quality checks" + fi + fi - name: Run tests run: npm test From 23225c6b8cc37cde3fd4f413191b814faba899c3 Mon Sep 17 00:00:00 2001 From: Piotr Jurczynski <619650+pjurczynski@users.noreply.github.com> Date: Wed, 9 Jul 2025 23:40:59 +0200 Subject: [PATCH 3/5] Extract quality check logic to dedicated shell script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/scripts/run-quality-checks.sh | 21 +++++++++++++++++++++ .github/workflows/ci.yml | 25 +++++-------------------- 2 files changed, 26 insertions(+), 20 deletions(-) create mode 100755 .github/scripts/run-quality-checks.sh diff --git a/.github/scripts/run-quality-checks.sh b/.github/scripts/run-quality-checks.sh new file mode 100755 index 0000000..bf471e8 --- /dev/null +++ b/.github/scripts/run-quality-checks.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then + # Get changed .ts files in the PR + CHANGED_FILES=$(git diff --name-only $PR_BASE_SHA $PR_HEAD_SHA | grep '\.ts$' | tr '\n' ' ') + if [ -n "$CHANGED_FILES" ]; then + echo "Running quality checks on changed files: $CHANGED_FILES" + npm run quality -- $CHANGED_FILES + else + echo "No TypeScript files changed, skipping quality checks" + fi +else + # For push events, run on files changed in the current commit + CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD | grep '\.ts$' | tr '\n' ' ') + if [ -n "$CHANGED_FILES" ]; then + echo "Running quality checks on files changed in current commit: $CHANGED_FILES" + npm run quality -- $CHANGED_FILES + else + echo "No TypeScript files changed in current commit, skipping quality checks" + fi +fi \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab000f9..d62c1a4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,26 +26,11 @@ jobs: run: npm ci - name: Run quality checks on changed files - run: | - if [ "${{ github.event_name }}" == "pull_request" ]; then - # Get changed .ts files in the PR - CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep '\.ts$' | tr '\n' ' ') - if [ -n "$CHANGED_FILES" ]; then - echo "Running quality checks on changed files: $CHANGED_FILES" - npm run quality -- $CHANGED_FILES - else - echo "No TypeScript files changed, skipping quality checks" - fi - else - # For push events, run on files changed in the current commit - CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD | grep '\.ts$' | tr '\n' ' ') - if [ -n "$CHANGED_FILES" ]; then - echo "Running quality checks on files changed in current commit: $CHANGED_FILES" - npm run quality -- $CHANGED_FILES - else - echo "No TypeScript files changed in current commit, skipping quality checks" - fi - fi + env: + GITHUB_EVENT_NAME: ${{ github.event_name }} + PR_BASE_SHA: ${{ github.event.pull_request.base.sha }} + PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} + run: ./.github/scripts/run-quality-checks.sh - name: Run tests run: npm test From 34a1f4660f3902946befd1d73565ce49960ef244 Mon Sep 17 00:00:00 2001 From: Piotr Jurczynski <619650+pjurczynski@users.noreply.github.com> Date: Wed, 9 Jul 2025 23:58:26 +0200 Subject: [PATCH 4/5] Refactor shell script to use arrays and fix shellcheck warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/scripts/run-quality-checks.sh | 56 ++++++++++++++++++--------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/.github/scripts/run-quality-checks.sh b/.github/scripts/run-quality-checks.sh index bf471e8..6d96607 100755 --- a/.github/scripts/run-quality-checks.sh +++ b/.github/scripts/run-quality-checks.sh @@ -1,21 +1,39 @@ #!/bin/bash -if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then - # Get changed .ts files in the PR - CHANGED_FILES=$(git diff --name-only $PR_BASE_SHA $PR_HEAD_SHA | grep '\.ts$' | tr '\n' ' ') - if [ -n "$CHANGED_FILES" ]; then - echo "Running quality checks on changed files: $CHANGED_FILES" - npm run quality -- $CHANGED_FILES - else - echo "No TypeScript files changed, skipping quality checks" - fi -else - # For push events, run on files changed in the current commit - CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD | grep '\.ts$' | tr '\n' ' ') - if [ -n "$CHANGED_FILES" ]; then - echo "Running quality checks on files changed in current commit: $CHANGED_FILES" - npm run quality -- $CHANGED_FILES - else - echo "No TypeScript files changed in current commit, skipping quality checks" - fi -fi \ No newline at end of file +set -e + +get_changed_ts_files() { + local base_ref="$1" + local head_ref="$2" + + if [ -n "$base_ref" ] && [ -n "$head_ref" ]; then + git diff --name-only "$base_ref" "$head_ref" | grep '\.ts$' || true + else + git diff --name-only HEAD~1 HEAD | grep '\.ts$' || true + fi +} + +run_quality_checks() { + local event_type="$1" + local changed_files_raw + + if [ "$event_type" == "pull_request" ]; then + changed_files_raw=$(get_changed_ts_files "$PR_BASE_SHA" "$PR_HEAD_SHA") + local context_message="changed files in the PR" + else + changed_files_raw=$(get_changed_ts_files) + local context_message="files changed in current commit" + fi + + if [ -n "$changed_files_raw" ]; then + # Convert to array + readarray -t changed_files <<< "$changed_files_raw" + + echo "Running quality checks on $context_message: ${changed_files[*]}" + npm run quality -- "${changed_files[@]}" + else + echo "No TypeScript files changed, skipping quality checks" + fi +} + +run_quality_checks "$GITHUB_EVENT_NAME" \ No newline at end of file From ff4cbea61e4bb5bec2d3227e278b9cf35b85187b Mon Sep 17 00:00:00 2001 From: Piotr Jurczynski <619650+pjurczynski@users.noreply.github.com> Date: Thu, 10 Jul 2025 00:13:14 +0200 Subject: [PATCH 5/5] Add fetch-depth: 2 to checkout action to fix git diff in quality checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GitHub Actions uses shallow clones by default (fetch-depth: 1) which only fetches the latest commit. Our quality check script uses `git diff --name-only HEAD~1 HEAD` to identify changed files in push events, but HEAD~1 doesn't exist in a shallow clone with only one commit. Setting fetch-depth: 2 ensures that both HEAD and HEAD~1 are available, allowing the script to compare the current commit with its parent to determine which TypeScript files have changed and need quality checking. This prevents the "fatal: bad object [SHA]" error that occurs when the script tries to reference HEAD~1 in a shallow clone environment. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d62c1a4..df705c5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + fetch-depth: 2 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4