Skip to content

Commit 350cbc7

Browse files
committed
Added CI tests
1 parent e78c23a commit 350cbc7

2 files changed

Lines changed: 142 additions & 0 deletions

File tree

.github/workflows/deploy-wporg.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
jobs:
99
deploy:
1010
runs-on: ubuntu-latest
11+
if: false # TODO: Uncomment this when the plugin is ready for deployment
1112
steps:
1213
- name: Checkout
1314
uses: actions/checkout@v4

.github/workflows/test.yml

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
php:
13+
name: PHP
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup PHP
20+
uses: shivammathur/setup-php@v2
21+
with:
22+
php-version: "8.2"
23+
extensions: dom, json, libxml, mbstring
24+
coverage: none
25+
26+
- name: Get composer cache dir
27+
id: composer-cache
28+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
29+
30+
- name: Cache composer
31+
uses: actions/cache@v4
32+
with:
33+
path: ${{ steps.composer-cache.outputs.dir }}
34+
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
35+
restore-keys: ${{ runner.os }}-composer-
36+
37+
- name: Install dependencies
38+
run: composer install --no-progress --prefer-dist
39+
40+
- name: PHPUnit
41+
run: php vendor/bin/phpunit
42+
43+
- name: PHPStan
44+
run: php vendor/bin/phpstan analyse -c phpstan.neon
45+
46+
- name: PHPCS
47+
run: php vendor/bin/phpcs --standard=phpcs.xml
48+
49+
e2e:
50+
name: E2E
51+
runs-on: ubuntu-latest
52+
steps:
53+
- name: Checkout
54+
uses: actions/checkout@v4
55+
56+
- name: Start WordPress
57+
run: docker compose up -d
58+
59+
- name: Wait for WordPress
60+
run: |
61+
for i in $(seq 1 60); do
62+
if curl -sf -o /dev/null http://localhost:8071/; then
63+
echo "WordPress ready"
64+
break
65+
fi
66+
if [ $i -eq 60 ]; then exit 1; fi
67+
sleep 5
68+
done
69+
70+
- name: Install WordPress
71+
run: |
72+
docker compose exec -T wordpress bash -c 'cd /var/www/html && \
73+
curl -sO https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && chmod +x wp-cli.phar && mv wp-cli.phar /usr/local/bin/wp && \
74+
wp core install --url=http://localhost:8071 --title=Test --admin_user=test --admin_password=asdf123jkl --admin_email=test@test.test --skip-email --allow-root 2>/dev/null || true && \
75+
wp plugin activate fapi-signals --allow-root 2>/dev/null || true'
76+
77+
- name: Setup Node
78+
uses: actions/setup-node@v4
79+
with:
80+
node-version: "20"
81+
cache: "npm"
82+
83+
- name: Install npm dependencies
84+
run: npm ci
85+
86+
- name: Install Playwright browsers
87+
run: npx playwright install --with-deps
88+
89+
- name: Playwright E2E
90+
env:
91+
WP_BASE_URL: http://localhost:8071
92+
WP_ADMIN_USER: test
93+
WP_ADMIN_PASS: asdf123jkl
94+
run: npm run test:e2e
95+
96+
- name: Stop WordPress
97+
if: always()
98+
run: docker compose down
99+
100+
deploy-wporg:
101+
name: Deploy to WordPress.org
102+
runs-on: ubuntu-latest
103+
if: false
104+
needs: [php]
105+
steps:
106+
- name: Checkout
107+
uses: actions/checkout@v4
108+
109+
- name: Prepare build directory
110+
run: |
111+
mkdir -p wporg/trunk wporg/assets wporg/tags
112+
rsync -av --delete \
113+
--exclude "wporg/" \
114+
--exclude ".git/" \
115+
--exclude ".github/" \
116+
--exclude "node_modules/" \
117+
--exclude "tests/" \
118+
--exclude "e2e/" \
119+
--exclude "test-results/" \
120+
--exclude "docker-compose.yml" \
121+
--exclude "Dockerfile" \
122+
--exclude "README.md" \
123+
--exclude "SPECIFICATION.md" \
124+
--exclude "package.json" \
125+
--exclude "package-lock.json" \
126+
--exclude "playwright.config.js" \
127+
--exclude "phpunit.xml" \
128+
--exclude ".phpunit.result.cache" \
129+
--exclude ".env" \
130+
--exclude ".gitignore" \
131+
--exclude ".cursorignore" \
132+
./ wporg/trunk/
133+
134+
- name: Deploy to WordPress.org SVN
135+
uses: 10up/action-wordpress-plugin-deploy@stable
136+
env:
137+
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
138+
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
139+
SLUG: fapi-signals
140+
BUILD_DIR: wporg/trunk
141+
ASSETS_DIR: wporg/assets

0 commit comments

Comments
 (0)