Skip to content

Commit 8f5378f

Browse files
authored
Merge pull request #428 from wpengine/chore/ci-cd-audit-and-simplification
chore(ci): audit and simplify CI/CD workflows
2 parents ed34e19 + 449846d commit 8f5378f

10 files changed

Lines changed: 85 additions & 101 deletions

File tree

.github/actions/setup-wordpress/action.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: Set up WordPress
22
description: Sets up WordPress. Assumes mariadb is available as a service.
33

44
inputs:
5+
php-version:
6+
description: 'PHP version to use'
7+
required: false
8+
default: '8.2'
59
wp-version:
610
description: 'WordPress version to install'
711
required: false
@@ -13,15 +17,27 @@ runs:
1317
- name: Setup PHP w/ Composer & WP-CLI
1418
uses: shivammathur/setup-php@v2
1519
with:
16-
php-version: 8.0
20+
php-version: ${{ inputs.php-version }}
1721
extensions: mbstring, intl, bcmath, exif, gd, mysqli, opcache, zip, pdo_mysql
1822
coverage: none
1923
tools: composer:v2, wp-cli
2024

2125
- name: Setup Node.js
2226
uses: actions/setup-node@v4
2327
with:
24-
node-version: 18.x
28+
node-version-file: '.nvmrc'
29+
30+
- name: Get Composer cache directory
31+
id: composer-cache
32+
shell: bash
33+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
34+
35+
- name: Cache Composer dependencies
36+
uses: actions/cache@v4
37+
with:
38+
path: ${{ steps.composer-cache.outputs.dir }}
39+
key: ${{ runner.os }}-composer-no-dev-${{ hashFiles('**/composer.lock') }}
40+
restore-keys: ${{ runner.os }}-composer-no-dev-
2541

2642
- name: Install dependencies
2743
shell: bash

.github/workflows/phpstan.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
paths-ignore:
66
- '**/*.md'
77

8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
812
jobs:
913
phpstan:
1014
runs-on: ubuntu-22.04
@@ -17,6 +21,17 @@ jobs:
1721
with:
1822
php-version: '8.2'
1923

24+
- name: Get Composer cache directory
25+
id: composer-cache
26+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
27+
28+
- name: Cache Composer dependencies
29+
uses: actions/cache@v4
30+
with:
31+
path: ${{ steps.composer-cache.outputs.dir }}
32+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
33+
restore-keys: ${{ runner.os }}-composer-
34+
2035
- name: Install Dependencies
2136
run: composer install
2237

.github/workflows/release.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ jobs:
2828
- name: Checkout Repo
2929
uses: actions/checkout@v4
3030

31-
- name: Setup Node.js 18.x
31+
- name: Setup Node.js
3232
uses: actions/setup-node@v4
3333
with:
34-
node-version: 18.x
34+
node-version-file: '.nvmrc'
35+
cache: 'npm'
3536

3637
- name: Install Dependencies
3738
run: npm ci

.github/workflows/schema-linter.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ on:
1010
- develop
1111
- main
1212

13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
16+
1317
jobs:
1418
run:
1519
runs-on: ubuntu-22.04
1620
name: Lint WPGraphQL Schema
17-
if: contains(github.event.pull_request.labels.*.name, 'safe to test ✔') || github.repository == github.event.repository.full_name || github.event_name == 'push'
21+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
1822

1923
services:
2024
mariadb:
@@ -27,10 +31,6 @@ jobs:
2731
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
2832

2933
steps:
30-
- name: Cancel previous runs of this workflow (pull requests only)
31-
if: ${{ github.event_name == 'pull_request_target' }}
32-
uses: styfle/cancel-workflow-action@0.11.0
33-
3434
- name: Checkout
3535
uses: actions/checkout@v4
3636
with:

.github/workflows/sonar.yml

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,38 @@
11
on:
2-
# Trigger analysis when pushing to main or pull requests, and when creating a pull request.
32
push:
43
branches:
54
- main
65
pull_request:
76
types: [opened, synchronize, reopened]
87

98
name: SonarQube Analysis
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
1014
jobs:
1115
sonarqube:
16+
# Only run for pushes or same-repo PRs (fork PRs can't access secrets)
17+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
1218
runs-on: ubuntu-22.04
1319
steps:
14-
- name: Check if PR author is an org member
15-
id: check-member
16-
uses: actions/github-script@v6.3.0 # Updated version to support Node 20
17-
with:
18-
script: |
19-
const org = 'wpengine';
20-
const username = context.payload.pull_request.user.login;
21-
22-
try {
23-
const { data: membership } = await github.rest.orgs.getMembershipForUser({
24-
org,
25-
username,
26-
});
27-
console.log({ username, membership });
28-
return { isMember: membership.state === 'active' };
29-
} catch (error) {
30-
console.log(`Error checking membership: ${error}`);
31-
return { isMember: false }; // Treat as not a member if any error occurs
32-
}
33-
env:
34-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35-
36-
# Set an output for the job based on the result of the membership check
37-
- name: Set output for isMember
38-
run: echo "isMember=${{ steps.check-member.outputs.isMember }}" >> $GITHUB_ENV
39-
40-
- name: Skip if not an org member
41-
if: env.isMember == 'false'
42-
run: echo "Skipping workflow because PR author is not an org member" && exit 0
43-
4420
- uses: actions/checkout@v4
4521
with:
4622
# Disabling shallow clone is recommended for improving relevancy of reporting
4723
fetch-depth: 0
4824

4925
- name: SonarQube Scan
50-
uses: sonarsource/sonarqube-scan-action@master
26+
uses: sonarsource/sonarqube-scan-action@v4
5127
env:
5228
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
5329
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
5430

5531
- name: SonarQube Quality Gate check
56-
uses: sonarsource/sonarqube-quality-gate-action@master
57-
# Force to fail step after specific time
32+
uses: sonarsource/sonarqube-quality-gate-action@v1
5833
timeout-minutes: 5
5934
env:
6035
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
6136
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
6237
with:
6338
scanMetadataReportFile: .scannerwork/report-task.txt
64-
65-
- name: "Display Quality gate result"
66-
run: echo "Front Quality Gate status ${{ toJSON(steps.sonarqube-result-front) }}"

.github/workflows/test-plugin-nightly.yml

Lines changed: 0 additions & 53 deletions
This file was deleted.

.github/workflows/test-plugin.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,24 @@ on:
66
paths-ignore:
77
- '**/*.md'
88

9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
913
jobs:
1014
test_plugin:
1115
runs-on: ubuntu-22.04
1216
strategy:
1317
matrix:
1418
php: [ '8.3', '8.1' ]
1519
wordpress: [ '6.9', '6.8', '6.7', '6.6' ]
20+
wp-nightly: [ false ]
21+
include:
22+
- php: '8.2'
23+
wordpress: '6.9'
24+
wp-nightly: true
1625
fail-fast: false
17-
name: WordPress ${{ matrix.wordpress }}, PHP ${{ matrix.php }}
26+
name: WordPress ${{ matrix.wp-nightly && 'Nightly' || matrix.wordpress }}, PHP ${{ matrix.php }}
1827
steps:
1928
- name: Checkout
2029
uses: actions/checkout@v4
@@ -23,6 +32,8 @@ jobs:
2332
env:
2433
PHP_VERSION: ${{ matrix.php }}
2534
WP_VERSION: ${{ matrix.wordpress }}
35+
DOCKER_BUILDKIT: 1
36+
COMPOSE_DOCKER_CLI_BUILD: 1
2637
working-directory: ./
2738
run: |
2839
docker compose build \
@@ -40,6 +51,12 @@ jobs:
4051
working-directory: ./
4152
run: docker exec -e COVERAGE=1 $(docker compose ps -q wordpress) init-testing-environment.sh
4253

54+
- name: Upgrade to WordPress nightly
55+
if: matrix.wp-nightly
56+
run: |
57+
docker exec --workdir=/var/www/html/wp-content/plugins/wp-graphql-content-blocks \
58+
$(docker compose ps -q wordpress) wp core upgrade --version=nightly --force --allow-root
59+
4360
- name: Install and activate WP GraphQL
4461
working-directory: ./
4562
run: docker exec --workdir=/var/www/html/wp-content/plugins/wp-graphql-content-blocks $(docker compose ps -q wordpress) wp plugin install wp-graphql --activate --allow-root

.github/workflows/wpcs.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ name: WordPress Coding Standards
33
on:
44
pull_request:
55

6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}
8+
cancel-in-progress: true
9+
610
jobs:
711
wpcs:
812
runs-on: ubuntu-22.04
@@ -15,6 +19,17 @@ jobs:
1519
with:
1620
php-version: '8.1'
1721

22+
- name: Get Composer cache directory
23+
id: composer-cache
24+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
25+
26+
- name: Cache Composer dependencies
27+
uses: actions/cache@v4
28+
with:
29+
path: ${{ steps.composer-cache.outputs.dir }}
30+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
31+
restore-keys: ${{ runner.os }}-composer-
32+
1833
- name: Install Dependencies
1934
run: composer install
2035

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
18

bin/run-docker.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ case "$subcommand" in
3939
esac
4040
done
4141
docker build $BUILD_NO_CACHE \
42-
-t faustwp:${TAG}-wp-${WP_VERSION} \
42+
-t wp-graphql-content-blocks:${TAG}-wp-${WP_VERSION} \
4343
--build-arg WP_VERSION=${WP_VERSION} \
4444
./.docker;
4545
;;

0 commit comments

Comments
 (0)