From c50bf420b4eef02cb5058b3608afe183b5025982 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Wed, 7 Aug 2024 12:31:55 +0800 Subject: [PATCH] Add composer validate and normalize checks --- .github/workflows/static-code-analysis.yml | 31 +++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/.github/workflows/static-code-analysis.yml b/.github/workflows/static-code-analysis.yml index 8b43819..4a17cb6 100644 --- a/.github/workflows/static-code-analysis.yml +++ b/.github/workflows/static-code-analysis.yml @@ -42,6 +42,11 @@ jobs: run: | echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_OUTPUT + - name: Get packages' directories + id: components + run: | + echo COMPONENTS=$(find src/Nexus -mindepth 2 -type f -name composer.json | cut -d '/' -f 1-3 | sort -fh) >> $GITHUB_OUTPUT + - name: Cache Composer dependencies uses: actions/cache@v4 with: @@ -51,7 +56,31 @@ jobs: ${{ github.workflow }}-PHP_${{ matrix.php-version }}- - name: Install dependencies - run: composer update --ansi + run: | + composer update --ansi + composer global require --ansi ergebnis/composer-normalize + + - name: Check - Composer validate + run: | + COMPONENTS=$( + find src/Nexus -mindepth 2 -type f -name composer.json \ + | cut -d '/' -f 1-3 \ + | sort -fh + ) + + composer validate --strict --ansi + echo "$COMPONENTS" | xargs -I {} bash -xc "composer validate --strict --ansi --working-dir {}" + + - name: Check - Composer normalize + run: | + COMPONENTS=$( + find src/Nexus -mindepth 2 -type f -name composer.json \ + | cut -d '/' -f 1-3 \ + | sort -fh + ) + + composer normalize --dry-run --diff --ansi + echo "$COMPONENTS" | xargs -I {} bash -xc "composer normalize --dry-run --diff --ansi --working-dir {}" - name: Check - file permissions run: bin/check-file-permissions