Repository navigation
113 lines (104 loc) · 4.08 KB
/
Copy pathcodeception.yml
File metadata and controls
113 lines (104 loc) · 4.08 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
# This does the following:
# 1. Detects modified plugins that have codeception.dist.yml configuration setup
# 2. Runs Codeception tests on those plugins using the custom action
# 3. Creates a matrix job for each plugin that has a quality configuration
# Bonus: This means you can have plugin specific badges e.g.
# [](https://github.com/wpengine/hwptoolkit/actions)
name: Testing Integration
on:
push:
branches:
- main
paths:
- 'plugins/*/**.php'
pull_request:
paths:
- 'plugins/*/**.php'
# Cancel previous workflow run groups that have not completed.
concurrency:
# Group workflow runs by workflow name, along with the head branch ref of the pull request
# or otherwise the branch or tag ref.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
detect-plugins:
runs-on: ubuntu-latest
name: Detect plugins with test config
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 directory
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: Detect changed plugins with test config
id: detect
env:
PLUGINS: ${{ steps.plugin.outputs.plugins }}
run: |
# Test every changed plugin that has a codeception.dist.yml, not just the first one.
WITH_TESTS="[]"
for plugin in $(echo "${PLUGINS:-[]}" | jq -r '.[]'); do
if [ -f "plugins/$plugin/codeception.dist.yml" ]; then
echo "✅ Found codeception.dist.yml for plugin: $plugin"
WITH_TESTS=$(echo "$WITH_TESTS" | jq -c --arg p "$plugin" '. + [$p]')
else
echo "ℹ️ No codeception.dist.yml found for plugin: $plugin, skipping automated tests"
fi
done
echo "plugins=$WITH_TESTS" >> "$GITHUB_OUTPUT"
if [ "$WITH_TESTS" = "[]" ]; then
echo "has-plugins=false" >> "$GITHUB_OUTPUT"
else
echo "has-plugins=true" >> "$GITHUB_OUTPUT"
fi
continuous_integration:
needs: detect-plugins
if: needs.detect-plugins.outputs.has-plugins == 'true'
runs-on: ubuntu-latest
name: ${{ matrix.plugin }} integration tests (WP ${{ matrix.wordpress }}, PHP ${{ matrix.php }})
strategy:
matrix:
plugin: ${{ fromJson(needs.detect-plugins.outputs.plugins) }}
php: ["8.4","8.2"]
wordpress: ["7.1","7.0","6.9"]
include:
- php: "8.2"
wordpress: "7.1"
coverage: 1
fail-fast: false
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: ${{ matrix.plugin }} codeception tests
uses: ./.github/actions/codeception
with:
working-directory: plugins/${{ matrix.plugin }}
php: ${{ matrix.php }}
wordpress: ${{ matrix.wordpress }}
extensions: json,mbstring