Skip to content

Commit 70bc0b1

Browse files
ci: create GitHub workflows and configurations (#99)
- Add CI, conventional commits, nightly, release-please, and test workflows - Add pre-commit configuration for code quality checks - Add release-please manifest set to version 0.4.0 - Configure workflows to run tests on PHP 8.2-8.5 - Enable code style checking with PHP CS Fixer
2 parents 740e921 + 72ccbee commit 70bc0b1

7 files changed

Lines changed: 206 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test:
14+
uses: ./.github/workflows/test.yml
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Conventional Commits
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, edited]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: read
10+
11+
jobs:
12+
commits:
13+
runs-on: ubuntu-24.04
14+
steps:
15+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
16+
with:
17+
fetch-depth: 0
18+
- uses: webiny/action-conventional-commits@8bc41ff4e7d423d56fa4905f6ff79209a78776c7 # v1.3.0
19+
with:
20+
allowed-commit-types: "feat,fix,docs,style,refactor,perf,test,build,ci,chore,revert"
21+
22+
pr-title:
23+
runs-on: ubuntu-24.04
24+
steps:
25+
- uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v6
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
with:
29+
types: |
30+
feat
31+
fix
32+
docs
33+
style
34+
refactor
35+
perf
36+
test
37+
build
38+
ci
39+
chore
40+
revert
41+
requireScope: false
42+
subjectPattern: ^(?![A-Z]).+$
43+
subjectPatternError: |
44+
The subject "{subject}" found in the pull request title "{title}"
45+
didn't match the configured pattern. Please ensure that the subject
46+
doesn't start with an uppercase character.

.github/workflows/nightly.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Nightly
2+
3+
on:
4+
schedule:
5+
# Run every Monday at 12 AM UTC
6+
- cron: '0 0 * * 1'
7+
workflow_dispatch: # Allow manual trigger
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test:
14+
uses: ./.github/workflows/test.yml
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Release Please
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
issues: write
12+
13+
jobs:
14+
release-please:
15+
name: Create Release PR
16+
runs-on: ubuntu-24.04
17+
outputs:
18+
release_created: ${{ steps.release.outputs.release_created }}
19+
tag_name: ${{ steps.release.outputs.tag_name }}
20+
steps:
21+
- uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38 # v4
22+
id: release
23+
with:
24+
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
25+
# This should match the configuration of your conventional commits
26+
release-type: php

.github/workflows/test.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Test
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
tests:
11+
name: Tests (PHP ${{ matrix.php }})
12+
runs-on: ubuntu-24.04
13+
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
php: ['8.2', '8.3', '8.4', '8.5']
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
22+
23+
- name: Setup PHP
24+
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2
25+
with:
26+
php-version: ${{ matrix.php }}
27+
extensions: json
28+
coverage: xdebug
29+
tools: composer:v2
30+
31+
- name: Get composer cache directory
32+
id: composer-cache
33+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
34+
35+
- name: Cache dependencies
36+
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5
37+
with:
38+
path: ${{ steps.composer-cache.outputs.dir }}
39+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
40+
restore-keys: ${{ runner.os }}-composer-
41+
42+
- name: Install dependencies
43+
run: composer update -n --prefer-dist
44+
45+
- name: Create build directory
46+
run: mkdir -p build/logs
47+
48+
- name: Run tests
49+
run: vendor/bin/phpunit
50+
51+
- name: Upload test results
52+
if: always()
53+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5
54+
with:
55+
name: test-results-php-${{ matrix.php }}
56+
path: build/logs/
57+
retention-days: 7
58+
59+
code-style:
60+
name: Code Style
61+
runs-on: ubuntu-24.04
62+
63+
steps:
64+
- name: Checkout code
65+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
66+
67+
- name: Setup PHP
68+
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2
69+
with:
70+
php-version: '8.2'
71+
tools: composer:v2
72+
73+
- name: Get composer cache directory
74+
id: composer-cache
75+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
76+
77+
- name: Cache dependencies
78+
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5
79+
with:
80+
path: ${{ steps.composer-cache.outputs.dir }}
81+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
82+
restore-keys: ${{ runner.os }}-composer-
83+
84+
- name: Install dependencies
85+
run: composer update -n --prefer-dist
86+
87+
- name: Run PHP CS Fixer
88+
run: vendor/bin/php-cs-fixer fix -v --dry-run --using-cache=no

.pre-commit-config.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.5.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
- id: check-merge-conflict
10+
- id: detect-private-key
11+
- repo: https://github.com/compilerla/conventional-pre-commit
12+
rev: v3.0.0
13+
hooks:
14+
- id: conventional-pre-commit
15+
stages: [commit-msg]

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "0.4.0"
3+
}

0 commit comments

Comments
 (0)