Repository navigation
125 lines (115 loc) · 4.17 KB
/
Copy pathplugin-check.yml
File metadata and controls
125 lines (115 loc) · 4.17 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
# Runs WordPress Plugin Check on modified plugins to ensure compliance with
# WordPress.org guidelines and coding standards.
#
# https://wordpress.org/plugins/plugin-check/
name: Plugin Check
on:
push:
branches:
- main
paths:
- 'plugins/**'
pull_request:
branches:
- main
paths:
- 'plugins/**'
# Read-only, so plugin-check-action can't post its report as a PR comment. Results stay
# in the job log and the uploaded artifact.
permissions:
contents: read
jobs:
detect-plugins:
runs-on: ubuntu-latest
name: Detect modified plugins
outputs:
plugins: ${{ steps.detect.outputs.plugins }}
has-plugins: ${{ steps.detect.outputs.has-plugins }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# get_plugin_slug.sh diffs against history, so fetch all of it without file contents.
fetch-depth: 0
# Skip the example sites' uploads.zip files (590 MB), which plugin jobs don't use.
filter: blob:none
sparse-checkout-cone-mode: false
sparse-checkout: |
/*
!**/wp-env/uploads.zip
- name: Get changed plugin directories
id: plugin
run: |
if [ "${{ github.event_name }}" = "push" ]; then
bash .github/scripts/get_plugin_slug.sh main
else
bash .github/scripts/get_plugin_slug.sh \
${{ github.event.pull_request.base.sha }} \
${{ github.event.pull_request.head.sha }}
fi
- name: Set output
id: detect
# Pass the values through env so the shell doesn't strip the quotes in
# the JSON array.
env:
SLUG: ${{ steps.plugin.outputs.slug }}
PLUGINS: ${{ steps.plugin.outputs.plugins }}
HAS_PLUGINS: ${{ steps.plugin.outputs.has-plugins }}
run: |
# get_plugin_slug.sh outputs: slug, plugins (JSON array), has-plugins
if [ -z "$SLUG" ]; then
echo "plugins=[]" >> "$GITHUB_OUTPUT"
echo "has-plugins=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "plugins=$PLUGINS" >> "$GITHUB_OUTPUT"
echo "has-plugins=$HAS_PLUGINS" >> "$GITHUB_OUTPUT"
plugin-check:
needs: detect-plugins
if: needs.detect-plugins.outputs.has-plugins == 'true'
runs-on: ubuntu-latest
strategy:
matrix:
plugin: ${{ fromJson(needs.detect-plugins.outputs.plugins) }}
fail-fast: false
name: ${{ matrix.plugin }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Skip the example sites' uploads.zip files (590 MB), which plugin jobs don't use.
filter: blob:none
sparse-checkout-cone-mode: false
sparse-checkout: |
/*
!**/wp-env/uploads.zip
- name: Setup PHP and install production dependencies
uses: ./.github/actions/setup-php-composer
with:
php-version: '8.2' # Note: All plugins are compatible with PHP 8.2
working-directory: plugins/${{ matrix.plugin }}
composer-options: '--no-progress --optimize-autoloader --no-dev'
# Check what ships, not the source tree. composer archive applies the plugin's
# archive.exclude list, the same as release-plugin.yml.
- name: Build plugin archive
working-directory: plugins/${{ matrix.plugin }}
env:
SLUG: ${{ matrix.plugin }}
run: |
composer archive --format=zip --file="plugin-build/$SLUG" --dir="."
mkdir -p "$RUNNER_TEMP/plugin-check/$SLUG"
unzip -q "plugin-build/$SLUG.zip" -d "$RUNNER_TEMP/plugin-check/$SLUG"
- name: Run Plugin Check
uses: wordpress/plugin-check-action@v1
with:
build-dir: ${{ runner.temp }}/plugin-check/${{ matrix.plugin }}
# No token, no PR comment.
repo-token: ''
exclude-directories: |
vendor
# The plugins ship through GitHub Releases and Composer, not WordPress.org,
# so the Update URI header is intentional.
ignore-codes: |
plugin_updater_detected
ignore-warnings: true
include-experimental: false