-
Notifications
You must be signed in to change notification settings - Fork 7
111 lines (96 loc) · 3.49 KB
/
standards-and-tests.yml
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
name: Run Standards & Tests
on:
push:
branches: [dev, production]
tags:
- '*.*.*'
pull_request:
branches: [dev]
jobs:
tests:
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
php: [ 8.1, 8.2 ]
os: [ ubuntu-20.04 ]
wordpress: [ '6.5', latest ]
include:
- experimental: true
- experimental: false
php: 8.1
wordpress: '6.5'
name: Test - PHP ${{ matrix.php }} - WP ${{ matrix.wordpress }}
env:
WP_VERSION: ${{ matrix.wordpress }}
WP_MULTISITE: 1
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Start required services
run: sudo systemctl start mysql.service
- name: Cache PHP dependencies
uses: actions/cache@v4
with:
path: vendor
key: php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
- name: Setup PHP with Composer 2
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: phpcs, composer
coverage: pcov
- name: Install PHP dependencies
run: |
export PATH="$HOME/.composer/vendor/bin:$PATH"
composer install --no-interaction
- name: Run PHP CodeSniffer
run: composer standards
- name: Install WP tests
run: bash bin/install-wp-tests.sh wordpress_test root root localhost ${{ matrix.wordpress }}
- name: Run PHP Tests
run: composer test
if: matrix.experimental == true
- name: Run PHP Tests and PCOV
run: composer test-coverage
if: matrix.experimental == false
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3
if: matrix.experimental == false
- name: Prepare Build
if: startsWith(github.ref, 'refs/tags/')
run: |
export GITHUB_BUILD_PATH=${{github.workspace}}
export GITHUB_REPO_SLUG="$(basename ${{github.workspace}})"
export GITHUB_TAG="$(basename ${{github.ref}})"
echo "File to be created : $GITHUB_BUILD_PATH/$GITHUB_REPO_SLUG-$GITHUB_TAG.zip"
curl -O 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
wp package install wp-cli/dist-archive-command
npm ci
npm run build
composer install --no-dev --optimize-autoloader
cd ..
wp dist-archive $GITHUB_REPO_SLUG $GITHUB_BUILD_PATH/$GITHUB_REPO_SLUG-$GITHUB_TAG.zip
cd $GITHUB_BUILD_PATH
ls $GITHUB_BUILD_PATH
- name: Deploy
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files:
${{github.workspace}}/*.zip
- name: Trigger Bedrock Update
if: (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/production') && matrix.experimental == false
uses: pressbooks/composer-autoupdate-bedrock@main
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_SNS_ARN_DEV: ${{ secrets.AWS_SNS_ARN_DEV }}
AWS_SNS_ARN_STAGING: ${{ secrets.AWS_SNS_ARN_STAGING }}
INPUT_TRIGGERED_BY: ${{ github.repository }}
BRANCH: ${{ github.ref }}