Skip to content

Commit 9bea996

Browse files
committed
ci: Bring GitHub Actions up to parity with the other SDKs
Replace the bespoke test workflow with a Check workflow modelled on the Ruby and Python SDKs. It runs on pushes to main as well as pull requests, has test, lint, build and install jobs, sets job timeouts and drops the SEAM_API_KEY secret the suite no longer needs, so checks now run on forks. Add a real PHP setup composite action that installs PHP, validates the lockfile and installs Composer dependencies from a cache. The existing action only set up Node.js, so rename it to setup-node and repoint the generate and version workflows at it. Add a reusable build workflow that packages the library with composer build and uploads the archive, an install job that requires that archive from a path repository and constructs a SeamClient, and wire the archive into the Publish workflow, which previously created a release with no files. Add a Format workflow so pushes are formatted with Prettier and committed, and widen Semantic Release to all branches so the prerelease branches declared in .releaserc.json can actually release. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RFK47311nWtbd3gHmjdknR
1 parent c3d93de commit 9bea996

10 files changed

Lines changed: 291 additions & 54 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
name: Setup Node.js
3+
description: Setup Node.js and install dependencies.
4+
5+
inputs:
6+
node_version:
7+
description: The Node.js version.
8+
required: false
9+
default: '24'
10+
registry_url:
11+
description: The Node.js package registry URL.
12+
required: false
13+
default: https://registry.npmjs.org
14+
install_dependencies:
15+
description: Install dependencies.
16+
required: false
17+
default: 'true'
18+
19+
runs:
20+
using: composite
21+
steps:
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v7
24+
if: inputs.install_dependencies == 'true'
25+
with:
26+
node-version: ${{ inputs.node_version }}
27+
registry-url: ${{ inputs.registry_url }}
28+
- name: Setup Node.js without cache
29+
uses: actions/setup-node@v7
30+
if: inputs.install_dependencies == 'false'
31+
with:
32+
node-version: ${{ inputs.node_version }}
33+
registry-url: ${{ inputs.registry_url }}
34+
- name: Install dependencies
35+
if: inputs.install_dependencies == 'true'
36+
shell: bash
37+
run: npm ci --ignore-scripts
38+
- name: Rebuild Node.js modules
39+
shell: bash
40+
run: npm rebuild
41+
- name: Run postinstall script
42+
shell: bash
43+
run: npm run postinstall --if-present
44+
- name: Run prepare script
45+
shell: bash
46+
run: npm run prepare --if-present

.github/actions/setup/action.yml

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
---
22
name: Setup
3-
description: Setup Node.js and install dependencies.
3+
description: Setup PHP and install dependencies.
4+
45
inputs:
5-
node_version:
6-
description: The Node.js version.
7-
required: false
8-
default: '24'
9-
registry_url:
10-
description: The Node.js package registry URL.
6+
php_version:
7+
description: The PHP version.
118
required: false
12-
default: https://registry.npmjs.org
9+
default: '8.4'
1310
install_dependencies:
1411
description: Install dependencies.
1512
required: false
@@ -18,28 +15,30 @@ inputs:
1815
runs:
1916
using: composite
2017
steps:
21-
- name: Setup Node.js
22-
uses: actions/setup-node@v7
23-
if: inputs.install_dependencies == 'true'
18+
- name: Setup PHP
19+
uses: shivammathur/setup-php@v2
2420
with:
25-
node-version: ${{ inputs.node_version }}
26-
registry-url: ${{ inputs.registry_url }}
27-
- name: Setup Node.js without cache
28-
uses: actions/setup-node@v7
29-
if: inputs.install_dependencies == 'false'
30-
with:
31-
node-version: ${{ inputs.node_version }}
32-
registry-url: ${{ inputs.registry_url }}
33-
- name: Install dependencies
21+
php-version: ${{ inputs.php_version }}
22+
tools: composer:v2
23+
coverage: none
24+
- name: Check lockfile
3425
if: inputs.install_dependencies == 'true'
3526
shell: bash
36-
run: npm ci --ignore-scripts
37-
- name: Rebuild Node.js modules
38-
shell: bash
39-
run: npm rebuild
40-
- name: Run postinstall script
27+
run: composer validate --strict
28+
- name: Get Composer cache directory
29+
id: composer_cache
30+
if: inputs.install_dependencies == 'true'
4131
shell: bash
42-
run: npm run postinstall --if-present
43-
- name: Run prepare script
32+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
33+
- name: Setup Composer cache
34+
uses: actions/cache@v4
35+
if: inputs.install_dependencies == 'true'
36+
with:
37+
key: composer-${{ inputs.php_version }}-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('composer.lock') }}
38+
restore-keys: |
39+
composer-${{ inputs.php_version }}-${{ runner.os }}-${{ runner.arch }}-
40+
path: ${{ steps.composer_cache.outputs.dir }}
41+
- name: Install dependencies
42+
if: inputs.install_dependencies == 'true'
4443
shell: bash
45-
run: npm run prepare --if-present
44+
run: composer install --no-interaction --no-progress

.github/workflows/_build.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
name: _build
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
php_version:
8+
description: The PHP version.
9+
type: string
10+
required: false
11+
default: '8.4'
12+
outputs:
13+
artifact_name:
14+
description: The artifact name.
15+
value: build-${{ github.sha }}
16+
17+
jobs:
18+
build:
19+
name: Package
20+
runs-on: ubuntu-latest
21+
timeout-minutes: 30
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v7
25+
- name: Setup
26+
uses: ./.github/actions/setup
27+
with:
28+
php_version: ${{ inputs.php_version }}
29+
- name: Build
30+
run: composer build
31+
- name: Upload artifact
32+
uses: actions/upload-artifact@v7
33+
with:
34+
name: build-${{ github.sha }}
35+
if-no-files-found: error
36+
path: pkg/

.github/workflows/check.yml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
---
2+
name: Check
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
branches:
10+
- '**'
11+
12+
jobs:
13+
test:
14+
name: Test (PHP ${{ matrix.php }} on ${{ matrix.os_name }})
15+
runs-on: ${{ matrix.os }}
16+
timeout-minutes: 30
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
os:
21+
- ubuntu-latest
22+
php:
23+
- '8.4'
24+
- '8.5'
25+
include:
26+
- os: ubuntu-latest
27+
os_name: Linux
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v7
31+
- name: Setup
32+
uses: ./.github/actions/setup
33+
with:
34+
php_version: ${{ matrix.php }}
35+
- name: Setup Node.js
36+
uses: ./.github/actions/setup-node
37+
- name: Test
38+
run: composer test
39+
lint:
40+
name: Lint (PHP ${{ matrix.php }})
41+
runs-on: ubuntu-latest
42+
timeout-minutes: 30
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
php:
47+
- '8.4'
48+
- '8.5'
49+
steps:
50+
- name: Checkout
51+
uses: actions/checkout@v7
52+
- name: Setup
53+
uses: ./.github/actions/setup
54+
with:
55+
php_version: ${{ matrix.php }}
56+
- name: Setup Node.js
57+
uses: ./.github/actions/setup-node
58+
- name: Lint
59+
run: composer lint
60+
- name: Lint with ESLint and Prettier
61+
run: npm run lint
62+
build:
63+
name: Build
64+
uses: ./.github/workflows/_build.yml
65+
install:
66+
name: Install (PHP ${{ matrix.php }} on ${{ matrix.os_name }})
67+
runs-on: ${{ matrix.os }}
68+
timeout-minutes: 30
69+
needs: build
70+
strategy:
71+
fail-fast: false
72+
matrix:
73+
os:
74+
- ubuntu-latest
75+
php:
76+
- '8.4'
77+
- '8.5'
78+
include:
79+
- os: ubuntu-latest
80+
os_name: Linux
81+
steps:
82+
- name: Setup PHP
83+
uses: shivammathur/setup-php@v2
84+
with:
85+
php-version: ${{ matrix.php }}
86+
tools: composer:v2
87+
coverage: none
88+
- name: Download artifact
89+
uses: actions/download-artifact@v8
90+
with:
91+
name: ${{ needs.build.outputs.artifact_name }}
92+
path: pkg/
93+
- name: Extract package
94+
run: unzip -q pkg/seam.zip -d package
95+
- name: Create composer.json
96+
uses: DamianReeves/write-file-action@v1.3
97+
with:
98+
write-mode: overwrite
99+
path: composer.json
100+
contents: |
101+
{
102+
"repositories": [
103+
{
104+
"type": "path",
105+
"url": "./package",
106+
"options": { "symlink": false }
107+
}
108+
],
109+
"require": { "seamapi/seam": "*" },
110+
"minimum-stability": "dev"
111+
}
112+
- name: Create main.php
113+
uses: DamianReeves/write-file-action@v1.3
114+
with:
115+
write-mode: overwrite
116+
path: main.php
117+
contents: |
118+
<?php
119+
require __DIR__ . '/vendor/autoload.php';
120+
new Seam\SeamClient('seam_apikey1_token');
121+
- name: Install
122+
run: composer install --no-interaction --no-progress
123+
- name: Run
124+
run: php main.php

.github/workflows/format.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
name: Format
3+
4+
on:
5+
push:
6+
branches-ignore:
7+
- main
8+
workflow_dispatch: {}
9+
10+
jobs:
11+
commit:
12+
name: Format code
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 30
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v7
18+
with:
19+
ref: ${{ github.head_ref }}
20+
token: ${{ secrets.GH_TOKEN }}
21+
- name: Import GPG key
22+
uses: crazy-max/ghaction-import-gpg@v7
23+
with:
24+
git_user_signingkey: true
25+
git_commit_gpgsign: true
26+
git_committer_name: ${{ secrets.GIT_USER_NAME }}
27+
git_committer_email: ${{ secrets.GIT_USER_EMAIL }}
28+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
29+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
30+
- name: Setup Node.js
31+
uses: ./.github/actions/setup-node
32+
- name: Format with Prettier
33+
run: npm run format
34+
- name: Commit
35+
uses: stefanzweifel/git-auto-commit-action@v7
36+
if: always()
37+
with:
38+
commit_message: 'ci: Format code'
39+
commit_user_name: ${{ secrets.GIT_USER_NAME }}
40+
commit_user_email: ${{ secrets.GIT_USER_EMAIL }}
41+
commit_author: ${{ secrets.GIT_USER_NAME }} <${{ secrets.GIT_USER_EMAIL }}>

.github/workflows/generate.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ jobs:
2727
git_committer_email: ${{ secrets.GIT_USER_EMAIL }}
2828
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
2929
passphrase: ${{ secrets.GPG_PASSPHRASE }}
30-
- name: Setup
31-
uses: ./.github/actions/setup
30+
- name: Setup Node.js
31+
uses: ./.github/actions/setup-node
3232
with:
3333
install_dependencies: 'false'
3434
- name: Normalize package-lock.json

.github/workflows/publish.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
name: Publish
23

34
run-name: Publish ${{ github.ref_name }}
@@ -8,16 +9,24 @@ on:
89
- v*
910

1011
jobs:
12+
build:
13+
name: Build
14+
uses: ./.github/workflows/_build.yml
1115
release:
1216
name: GitHub Releases
1317
runs-on: ubuntu-latest
1418
timeout-minutes: 30
19+
needs: build
1520
steps:
1621
- name: Checkout
1722
uses: actions/checkout@v7
1823
with:
1924
fetch-depth: 0
20-
25+
- name: Download artifact
26+
uses: actions/download-artifact@v8
27+
with:
28+
name: ${{ needs.build.outputs.artifact_name }}
29+
path: pkg/
2130
- name: Generate release notes
2231
id: changelog
2332
run: |
@@ -26,11 +35,11 @@ jobs:
2635
echo "outfile=${outfile}" >> $GITHUB_OUTPUT
2736
npx standard-changelog@^5.0.0 --release-count 2 --infile $outfile.tmp --outfile $outfile.tmp
2837
sed '1,3d' $outfile.tmp > $outfile
29-
3038
- name: Create GitHub release
3139
uses: softprops/action-gh-release@v3
3240
with:
3341
token: ${{ secrets.GH_TOKEN }}
42+
fail_on_unmatched_files: true
3443
prerelease: ${{ contains(github.ref_name, '-') }}
35-
files: ''
44+
files: pkg/*
3645
body_path: ${{ github.workspace }}/${{ steps.changelog.outputs.outfile }}

.github/workflows/semantic-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ run-name: Semantic Release from ${{ github.ref_name }}
66
on:
77
push:
88
branches:
9-
- main
9+
- '**'
1010

1111
concurrency:
1212
group: ${{ github.workflow }}-${{ github.ref_name }}

0 commit comments

Comments
 (0)