-
Notifications
You must be signed in to change notification settings - Fork 1
99 lines (79 loc) · 2.85 KB
/
Copy pathtest.yml
File metadata and controls
99 lines (79 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Tests
on:
pull_request:
branches: [main]
push:
branches: [main]
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
version_check:
name: Check plugin version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- 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:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- 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@9.7.2
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