Repository navigation
132 lines (111 loc) · 3.97 KB
/
Copy pathci.yml
File metadata and controls
132 lines (111 loc) · 3.97 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Least privilege: this workflow only reads the repository to lint, build and
# test. It never writes commits, comments or releases.
permissions:
contents: read
jobs:
js:
name: Types · Vitest · Bundles
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# Don't leave the GITHUB_TOKEN in .git/config; later steps run
# PR-authored code (npm scripts, the Vite build) and nothing here
# needs git auth after checkout.
persist-credentials: false
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: package-lock.json
- name: Install dependencies
run: npm ci
- name: TypeScript (no emit)
run: npm run typecheck
- name: Vitest
run: npm run test
# assets/js is committed on purpose: the plugin installs straight from a
# checkout with no npm install, which is what makes "download the zip from
# a tag" work. That only holds while the committed bundles match their
# source, so rebuild and fail if the tree moves. Catches a TypeScript
# change that was never rebuilt — which is invisible until somebody
# installs the release and gets last week's behaviour.
- name: Committed bundles match source
run: |
npm run build:bundles
git diff --exit-code -- assets/js/ || {
echo "::error::assets/js is out of date. Run 'npm run build' and commit the result."
exit 1
}
php:
name: PHPUnit · PHPCS
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: package-lock.json
- name: Install dependencies
run: npm ci
# .wp-env.json mounts the sibling `../alcazaba-plugin` checkout so a local
# QA site has OpenStation to host the desktop windows. That path does not
# exist on a runner and wp-env treats a missing mapping as fatal. The
# override file is merged last and replaces `mappings` wholesale, so this
# drops the sibling and keeps this plugin. Nothing is lost: the PHP suite
# tests this plugin's own code, and every shell call goes through
# `atf_shell_has()`, which is false when no shell is installed.
- name: Point wp-env at this repository only
run: |
cat > .wp-env.override.json <<'JSON'
{
"mappings": {
"wp-content/plugins/allterrain-forms": "."
}
}
JSON
- name: Start wp-env
run: npm run env:start
- name: Install PHP dev dependencies
run: npm run test:php:install
- name: PHPUnit
run: npm run test:php
- name: Coding standards
run: npx wp-env run cli --env-cwd=wp-content/plugins/allterrain-forms vendor/bin/phpcs
package:
name: Zip builds
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: package-lock.json
- name: Install dependencies
run: npm ci
# The release path, exercised on every push. A packaging script that is
# only ever run at release time is a script that breaks at release time,
# when the tag already exists and cannot be taken back.
- name: Build the package
run: npm run plugin:package
- name: Upload the zip
uses: actions/upload-artifact@v4
with:
name: allterrain-forms-zip
path: dist/allterrain-forms.zip
if-no-files-found: error