-
Notifications
You must be signed in to change notification settings - Fork 198
73 lines (67 loc) · 3 KB
/
build.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
name: Plugin Build
on:
- pull_request
- workflow_call
jobs:
build:
name: Plugin Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get npm cache directory
id: npm-cache
run: |
echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install JS dependencies
run: npm ci
- name: Install PHP dependencies and generate the third-party directory
uses: ./.github/actions/install-php
- name: Build Plugin
run: npm run build
- name: Decompress plugin
run: unzip sensei-lms.zip -d sensei-lms
- name: Store Artifact
uses: actions/upload-artifact@v3
with:
name: sensei-lms-${{ github.event.pull_request.head.sha }}
path: ${{ github.workspace }}/sensei-lms/
retention-days: 7
playground-preview:
if: github.event_name == 'pull_request'
name: Playground Preview
needs: build
runs-on: ubuntu-latest
steps:
- name: Create comment with Playground preview
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
Test the previous changes of this PR with [WordPress Playground](https://playground.wordpress.net/#{"landingPage":"/wp-admin/admin.php?page=sensei","phpExtensionBundles":["kitchen-sink"],"steps":[{"step":"setSiteOptions","options":{"site_intent":"sensei"}},{"step":"login","username":"admin","password":"password"},{"step":"installPlugin","pluginZipFile":{"resource":"url","url":"https://playground.wordpress.net/plugin-proxy.php?org=Automattic&repo=sensei&workflow=Plugin%20Build&artifact=sensei-lms-${{ github.event.pull_request.head.sha }}&pr=${{ github.event.pull_request.number }}"}},{"step":"installTheme","themeZipFile":{"resource":"wordpress.org\/themes","slug":"course"}}]}).
syntax-check:
name: PHP Syntax Check
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [7.4, 8.2]
steps:
- name: Download Build Artifact
uses: actions/download-artifact@v3
with:
name: sensei-lms-${{ github.event.pull_request.head.sha }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: phplint
coverage: none
- name: Check Syntax
run: phplint ./sensei-lms