Skip to content

Commit 85fb7f6

Browse files
authored
chore: Refactor actions (#2045)
* refactor: lint checks ci, drop uneeded build and add dedicated node-setup step with caching * chore: add prettier check to packages * tun on latest ubuntu * refactor: add concurrency limits to canel linting if new things are pushed to PR * chore: add reusable workflow step * refactor: simplify checks to use reusable owrkflow * fix: to string * fix: try eliminating matrix
1 parent 6ff9320 commit 85fb7f6

File tree

10 files changed

+112
-20
lines changed

10 files changed

+112
-20
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: 'Cache restoration'
2+
description: 'Setup a NodeJS environment and restore cache if any, given a node version'
3+
4+
inputs:
5+
node-version:
6+
description: 'Node version to use, default to LTS'
7+
required: true
8+
default: 22
9+
outputs:
10+
cache-hit:
11+
description: 'Forward actions/cache cache-hit output'
12+
value: ${{ steps.node-cache.outputs.cache-hit }}
13+
14+
runs:
15+
using: 'composite' # Mandatory parameter
16+
steps:
17+
# Setup a Node environment given a node version
18+
- name: Use Node.js ${{ inputs.node-version }}
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: ${{ inputs.node-version }}
22+
23+
- name: Cache Node Modules
24+
id: node-cache
25+
uses: actions/cache@v4
26+
with:
27+
path: |
28+
**/node_modules
29+
~/.cache
30+
key: ${{ runner.os }}-${{ inputs.node-version }}-${{ hashFiles('package-lock.json') }}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Package Code Quality
2+
3+
on:
4+
pull_request:
5+
branches: [canary]
6+
paths-ignore:
7+
- '**/*.md'
8+
- '**/*.php'
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
setup-node:
16+
name: Setup Dependencies
17+
uses: ./.github/workflows/node-setup.yml
18+
strategy:
19+
matrix:
20+
node-version: [22]
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
check_lint:
24+
name: Validate package linting
25+
runs-on: ubuntu-latest
26+
needs: [setup-node]
27+
steps:
28+
- name: Checkout repo
29+
uses: actions/checkout@v4
30+
- name: Set up Node.js
31+
uses: ./.github/actions/cache-restore
32+
- name: Check Linting
33+
run: npm run lint
34+
check_format:
35+
name: Validate package formatting
36+
runs-on: ubuntu-latest
37+
needs: [setup-node]
38+
steps:
39+
- name: Checkout repo
40+
uses: actions/checkout@v4
41+
- name: Set up Node.js
42+
uses: ./.github/actions/cache-restore
43+
- name: Check Formatting
44+
run: npm run test:format

.github/workflows/lint-packages.yml

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

.github/workflows/lint-plugin.yml

Lines changed: 4 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.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
11+
812
jobs:
913
lint_plugin:
1014
runs-on: ubuntu-22.04

.github/workflows/node-setup.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: 'Node Workspace Setup'
2+
description: 'Setup a environment and restore cache if any, given a node version'
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
node-version:
8+
description: 'Node version to use, default to LTS'
9+
required: true
10+
type: string
11+
default: '22'
12+
13+
jobs:
14+
setup:
15+
name: Setup Dependencies
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout Repository
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Node.js ${{ inputs.node-version }}
22+
uses: ./.github/actions/cache-restore
23+
id: cache-node-modules
24+
with:
25+
node-version: ${{ inputs.node-version }}
26+
27+
- name: Install dependencies
28+
if: steps.cache-node-modules.outputs.cache-hit != 'true'
29+
run: npm ci

.github/workflows/notify-discord.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212

1313
jobs:
1414
release_plugin:
15-
runs-on: ubuntu-22.04
15+
runs-on: ubuntu-latest
1616
steps:
1717
- name: Discord Notification
1818
env:

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"dev:next:getting-started": "rimraf examples/next/faustwp-getting-started/.next && npm run dev ---workspace=examples/next/faustwp-getting-started",
2929
"test": "npm run build && npm test --workspace=@faustwp/core --workspace=@faustwp/cli --workspace=@faustwp/blocks --workspace=@faustwp/block-editor-utils",
3030
"test:coverage": "npm run build && npm run test:coverage --workspace=@faustwp/block-editor-utils",
31+
"test:format": "npm run test:format --workspace=@faustwp/cli --workspace=@faustwp/core --workspace=@faustwp/block-editor-utils",
3132
"wpe-build": "exit 1",
3233
"changeset": "changeset",
3334
"version": "changeset version && node scripts/versionPlugin.js",

packages/block-editor-utils/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"clean": "rimraf dist",
3939
"package": "node ../../scripts/package.js",
4040
"test": "",
41+
"test:format": "prettier . --check",
4142
"build": "npm run build-esm && npm run build-cjs",
4243
"build-esm": "tsc -p .",
4344
"build-cjs": "tsc -p tsconfig.cjs.json",

packages/faustwp-cli/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"test": "jest",
4343
"test:coverage:ci": "jest --ci --json --coverage --testLocationInResults --passWithNoTests --outputFile=report.json",
4444
"test:coverage": "jest --coverage",
45+
"test:format": "prettier . --check",
4546
"test:watch": "jest --watch"
4647
},
4748
"repository": {

packages/faustwp-core/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"prepublish": "npm run build",
6363
"test:coverage:ci": "jest --ci --json --coverage --testLocationInResults --outputFile=report.json",
6464
"test:coverage": "jest --coverage",
65+
"test:format": "prettier . --check",
6566
"test:watch": "jest --watch",
6667
"test": "jest",
6768
"build-cjs": "tsc -p tsconfig-cjs.json",

0 commit comments

Comments
 (0)