From 4e34853b7b6e7081a7bf31e0885089f550f91827 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Jerosimi=C4=87?= Date: Fri, 7 Nov 2025 22:41:02 +0100 Subject: [PATCH 1/5] Reformat yml files --- .editorconfig | 4 ++ .github/workflows/test.yml | 88 +++++++++++++++++++------------------- 2 files changed, 48 insertions(+), 44 deletions(-) diff --git a/.editorconfig b/.editorconfig index f549ee8..2d3ea1f 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,3 +9,7 @@ indent_style = tab indent_size = 4 insert_final_newline = true trim_trailing_whitespace = true + +[*.{css,json,scss,xml,yml}] +indent_style = space +indent_size = 2 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a91ed5b..cdeddd9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,49 +1,49 @@ name: Tests on: - pull_request: - branches: [main] - push: - branches: [main] + pull_request: + branches: [main] + push: + branches: [main] jobs: - test: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v5 - - - name: Install PHP 8.4 - uses: shivammathur/setup-php@v2 - with: - php-version: "8.4" - ini-values: date.timezone='UTC' - extensions: posix, dom, curl, libxml, mbstring, zip, pcntl, pdo, pgsql, pdo_pgsql, bcmath, soap, intl, gd, exif, iconv, imagick - coverage: pcov - tools: composer:v2 - - - name: Add PHP symlink for php84 - run: sudo ln -s /usr/bin/php /usr/bin/php84 - - - name: Validate composer.json and composer.lock - run: composer validate --strict - - - name: Run PHP Lint - uses: overtrue/phplint@10.0 - with: - path: ./src - -# - name: Cache Composer packages -# uses: actions/cache@v3 -# with: -# path: vendor -# key: ${{ runner.os }}-php-${{ hashFiles('composer.lock') }} -# restore-keys: | -# ${{ runner.os }}-php- - - - name: Install dependencies - run: composer test-init - -# - name: Static analysis -# run: composer qa + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Install PHP 8.4 + uses: shivammathur/setup-php@v2 + with: + php-version: "8.4" + ini-values: date.timezone='UTC' + extensions: posix, dom, curl, libxml, mbstring, zip, pcntl, pdo, pgsql, pdo_pgsql, bcmath, soap, intl, gd, exif, iconv, imagick + coverage: pcov + tools: composer:v2 + + - name: Add PHP symlink for php84 + run: sudo ln -s /usr/bin/php /usr/bin/php84 + + - name: Validate composer.json and composer.lock + run: composer validate --strict + + - name: Run PHP Lint + uses: overtrue/phplint@10.0 + with: + path: ./src + + # - name: Cache Composer packages + # uses: actions/cache@v3 + # with: + # path: vendor + # key: ${{ runner.os }}-php-${{ hashFiles('composer.lock') }} + # restore-keys: | + # ${{ runner.os }}-php- + + - name: Install dependencies + run: composer test-init + + # - name: Static analysis + # run: composer qa From f7b66520b7439ee1b5fdbdf6159cc5013c7ecd5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Jerosimi=C4=87?= Date: Sat, 8 Nov 2025 09:48:25 +0100 Subject: [PATCH 2/5] Add version check --- .github/workflows/test.yml | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cdeddd9..350a551 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,55 @@ on: push: branches: [main] +concurrency: + group: {% raw %}${{ github.head_ref || github.run_id }}{% endraw %} + cancel-in-progress: true + jobs: + version_check: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Read plugin version + id: current_version + shell: bash + run: | + set -euo pipefail + + MAIN_FILE="src/i-order-terms.php" + PLUGIN_VERSION=$(grep -Po "^\s*\*\s*Version:\s*\K[^\s]+" "$MAIN_FILE" | head -n1) + echo "Plugin version: $PLUGIN_VERSION" + echo "version=$PLUGIN_VERSION" >> $GITHUB_ENV + + - name: Check plugin versions match + shell: bash + run: | + set -euo pipefail + + VERSION="${{ steps.current_version.outputs.version }}" + + CLASS_FILE="src/code/class-i-order-terms.php" + README_FILE="src/readme.txt" + CLASS_VER=$(grep -Po "const\s+PLUGIN_VERSION\s*=\s*'[^']+'" "$CLASS_FILE" | grep -Po "'\K[^']+(?=')") + README_VER=$(grep -Po "^\s*Stable tag:\s*\K[^\s]+" "$README_FILE" | head -n1) + + echo "Main plugin version: $VERSION" + echo "Class version: $CLASS_VER" + echo "Stable version: $README_VER" + + if [ -z "$CLASS_VER" ] || [ -z "$VERSION" ] || [ -z "$README_VER" ]; then + echo "Could not parse versions from files (class='$CLASS_VER', header='$FILE_VER', readme='$README_VER')." >&2 + exit 1 + fi + if [ "$VERSION" != "$CLASS_VER" ] || [ "$VERSION" != "$README_VER" ]; then + echo "Version mismatch: header=$VERSION, class=$CLASS_VER, readme_stable_tag=$README_VER" >&2 + exit 1 + fi + echo "All versions match!" + test: runs-on: ubuntu-latest From 21901a8624de3f9a23661ec76a06f86ae939cbfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Jerosimi=C4=87?= Date: Sat, 8 Nov 2025 09:50:08 +0100 Subject: [PATCH 3/5] Fix yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 350a551..521a2d0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,7 +7,7 @@ on: branches: [main] concurrency: - group: {% raw %}${{ github.head_ref || github.run_id }}{% endraw %} + group: ${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: From 0aa9c7e6d6628b8bbeabc52f655b0795e599dae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Jerosimi=C4=87?= Date: Sat, 8 Nov 2025 09:51:49 +0100 Subject: [PATCH 4/5] Fix version output --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 521a2d0..3236dd7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,7 +27,7 @@ jobs: MAIN_FILE="src/i-order-terms.php" PLUGIN_VERSION=$(grep -Po "^\s*\*\s*Version:\s*\K[^\s]+" "$MAIN_FILE" | head -n1) echo "Plugin version: $PLUGIN_VERSION" - echo "version=$PLUGIN_VERSION" >> $GITHUB_ENV + echo "version=$PLUGIN_VERSION" >> $GITHUB_OUTPUT - name: Check plugin versions match shell: bash From dc0be11e18e612ca30eeb2c31f740b7c4cabb08d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Jerosimi=C4=87?= Date: Sat, 8 Nov 2025 09:57:46 +0100 Subject: [PATCH 5/5] Fix message --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3236dd7..38c721a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,12 +45,12 @@ jobs: echo "Class version: $CLASS_VER" echo "Stable version: $README_VER" - if [ -z "$CLASS_VER" ] || [ -z "$VERSION" ] || [ -z "$README_VER" ]; then - echo "Could not parse versions from files (class='$CLASS_VER', header='$FILE_VER', readme='$README_VER')." >&2 + if [ -z "$VERSION" ] || [ -z "$CLASS_VER" ] || [ -z "$README_VER" ]; then + echo "Could not parse versions from files (v='$VERSION', class='$CLASS_VER', readme='$README_VER')." >&2 exit 1 fi if [ "$VERSION" != "$CLASS_VER" ] || [ "$VERSION" != "$README_VER" ]; then - echo "Version mismatch: header=$VERSION, class=$CLASS_VER, readme_stable_tag=$README_VER" >&2 + echo "Version mismatch: v=$VERSION, class=$CLASS_VER, readme=$README_VER" >&2 exit 1 fi echo "All versions match!"