Skip to content
This repository was archived by the owner on Jun 2, 2025. It is now read-only.

Commit 12d3063

Browse files
committed
Implement more robust plugin version definition and CI check
1 parent 6a641f9 commit 12d3063

File tree

5 files changed

+56
-7
lines changed

5 files changed

+56
-7
lines changed

.github/workflows/verify-version.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Verify plugin version
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
verify-version:
11+
name: Verify plugin version
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Extract version from "load.php"
17+
id: load_version
18+
run: |
19+
VERSION=$(grep "Version:" load.php | sed "s/.*Version: \([^ ]*\).*/\1/")
20+
echo "load_version=$VERSION" >> $GITHUB_OUTPUT
21+
22+
- name: Extract version from "version.php"
23+
id: const_version
24+
run: |
25+
VERSION=$(php -r "require 'version.php'; echo SQLITE_DRIVER_VERSION;")
26+
echo "const_version=$VERSION" >> $GITHUB_OUTPUT
27+
28+
- name: Compare versions
29+
run: |
30+
if [ "${{ steps.load_version.outputs.load_version }}" != "${{ steps.const_version.outputs.const_version }}" ]; then
31+
echo "Version mismatch detected!"
32+
echo " load.php version: ${{ steps.load_version.outputs.load_version }}"
33+
echo " version.php constant: ${{ steps.const_version.outputs.const_version }}"
34+
exit 1
35+
fi

load.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
* @package wp-sqlite-integration
1313
*/
1414

15-
define( 'SQLITE_DRIVER_VERSION', '2.1.17-alpha' );
15+
/**
16+
* Load the "SQLITE_DRIVER_VERSION" constant.
17+
* This constant needs to be updated whenever the plugin version changes!
18+
*/
19+
require_once __DIR__ . '/version.php';
20+
1621
define( 'SQLITE_MAIN_FILE', __FILE__ );
1722

1823
require_once __DIR__ . '/php-polyfills.php';

tests/bootstrap.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
require_once __DIR__ . '/wp-sqlite-schema.php';
4+
require_once __DIR__ . '/../version.php';
45
require_once __DIR__ . '/../wp-includes/parser/class-wp-parser-grammar.php';
56
require_once __DIR__ . '/../wp-includes/parser/class-wp-parser.php';
67
require_once __DIR__ . '/../wp-includes/parser/class-wp-parser-node.php';
@@ -14,12 +15,6 @@
1415
require_once __DIR__ . '/../wp-includes/sqlite/class-wp-sqlite-pdo-user-defined-functions.php';
1516
require_once __DIR__ . '/../wp-includes/sqlite/class-wp-sqlite-translator.php';
1617

17-
/*
18-
* The driver version needs to be defined and set to anything other than "0.0.0"
19-
* for the tests, so that the information schema and other tables are created.
20-
*/
21-
define( 'SQLITE_DRIVER_VERSION', '2.0.0-tests' );
22-
2318
/**
2419
* Polyfills for WordPress functions
2520
*/

version.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
/**
4+
* The version of the SQLite driver.
5+
*
6+
* This constant needs to be updated whenever the plugin version changes!
7+
*/
8+
define( 'SQLITE_DRIVER_VERSION', '2.1.17-alpha' );

wp-includes/sqlite/db.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
* @since 1.0.0
77
*/
88

9+
/**
10+
* Load the "SQLITE_DRIVER_VERSION" constant.
11+
* This constant needs to be updated whenever the plugin version changes!
12+
*/
13+
require_once dirname( __DIR__, 2 ) . '/version.php';
14+
915
// Require the constants file.
1016
require_once dirname( __DIR__, 2 ) . '/constants.php';
1117

0 commit comments

Comments
 (0)