-
Notifications
You must be signed in to change notification settings - Fork 0
Version check #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Version check #11
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,49 +1,97 @@ | ||
| name: Tests | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [main] | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
| push: | ||
| branches: [main] | ||
|
|
||
| concurrency: | ||
| group: ${{ github.head_ref || github.run_id }} | ||
| cancel-in-progress: true | ||
|
|
||
| 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 | ||
| 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_OUTPUT | ||
|
|
||
| - 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 "$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: v=$VERSION, class=$CLASS_VER, readme=$README_VER" >&2 | ||
| exit 1 | ||
| fi | ||
| echo "All versions match!" | ||
|
|
||
| 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 | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.