Skip to content

Commit b16a39e

Browse files
feat: Template sync (#14)
* refactor: Add template sync * chore: Sync changes from the template (#13) Co-authored-by: oprypkhantc <54406427+oprypkhantc@users.noreply.github.com> --------- Co-authored-by: package-sync[bot] <165811605+package-sync[bot]@users.noreply.github.com>
1 parent 79b338c commit b16a39e

File tree

11 files changed

+255
-159
lines changed

11 files changed

+255
-159
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ insert_final_newline = true
1212
trim_trailing_whitespace = true
1313

1414
[*.md]
15-
trim_trailing_whitespace = false
15+
trim_trailing_whitespace = false

.github/template-sync.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"repositories": [
3+
{
4+
"url": "https://github.com/tenantcloud/php-package-skeleton",
5+
"branch": "sync"
6+
}
7+
]
8+
}

.github/workflows/release.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Release
22

33
on:
44
workflow_run:
5-
workflows: ["Tests"]
5+
workflows: ['Tests']
66
types:
77
- completed
88
branches:
@@ -18,17 +18,17 @@ jobs:
1818
runs-on: ubuntu-latest
1919
if: ${{ github.event.workflow_run.conclusion == 'success' }}
2020
steps:
21-
- name: Checkout
22-
uses: actions/checkout@v3
23-
with:
24-
fetch-depth: 0
21+
- name: Checkout
22+
uses: actions/checkout@v3
23+
with:
24+
fetch-depth: 0
2525

26-
- name: Create a release
27-
uses: cycjimmy/semantic-release-action@v3
28-
with:
29-
extra_plugins: |
30-
@semantic-release/changelog
31-
@semantic-release/git
32-
env:
33-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
26+
- name: Create a release
27+
uses: cycjimmy/semantic-release-action@v3
28+
with:
29+
extra_plugins: |
30+
@semantic-release/changelog
31+
@semantic-release/git
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/template-sync.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Template sync
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '*/5 * * * *'
7+
8+
jobs:
9+
sync:
10+
name: Sync
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Sync from template
18+
id: sync_from_template
19+
uses: tenantcloud/template-sync@v1.0.0-alpha.9
20+
with:
21+
token: ${{ secrets.GITHUB_TOKEN }}
22+
23+
- name: Reformat
24+
uses: actionsx/prettier@v2
25+
with:
26+
args: --write .
27+
28+
- name: Generate token to read from source repo
29+
id: generate_token
30+
uses: tibdex/github-app-token@v1
31+
with:
32+
app_id: ${{ secrets.PACKAGE_SYNC_APP_ID }}
33+
private_key: ${{ secrets.PACKAGE_SYNC_PRIVATE_KEY }}
34+
35+
- name: Create PR
36+
uses: peter-evans/create-pull-request@v6
37+
with:
38+
token: ${{ steps.generate_token.outputs.token }}
39+
committer: 'package-sync[bot] <165811605+package-sync[bot]@users.noreply.github.com>'
40+
branch: 'template-sync'
41+
delete-branch: true
42+
title: 'chore: Sync changes from the template'
43+
commit-message: 'chore: Sync changes from the template'
44+
body: ${{ steps.sync_from_template.outputs.report }}
45+
assignees: oprypkhantc
46+
reviewers: oprypkhantc
47+
48+
# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
49+
# GitHub automatically disables `schedule` workflows in public repositories
50+
# after 60 days without commits, so this job is there to prevent it.
51+
workflow-keepalive:
52+
name: Workflow keepalive
53+
runs-on: ubuntu-latest
54+
if: github.event_name == 'schedule'
55+
56+
permissions:
57+
actions: write
58+
59+
steps:
60+
- uses: liskin/gh-workflow-keepalive@v1
61+
with:
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/tests.yml

Lines changed: 94 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -9,99 +9,112 @@ jobs:
99
strategy:
1010
fail-fast: true
1111
matrix:
12-
php: [ 8.1, 8.2 ]
12+
php: [8.2]
1313

1414
steps:
15-
- name: Checkout code
16-
uses: actions/checkout@v3
17-
18-
- name: Setup PHP
19-
uses: shivammathur/setup-php@v2
20-
with:
21-
php-version: ${{ matrix.php }}
22-
tools: composer:v2
23-
coverage: none
24-
25-
- name: Validate composer.json and composer.lock
26-
run: composer validate
27-
28-
- name: Cache Composer packages
29-
id: composer-cache
30-
uses: actions/cache@v3
31-
with:
32-
path: vendor
33-
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
34-
restore-keys: |
35-
${{ runner.os }}-php-
36-
37-
- name: Install dependencies
38-
run: composer install --prefer-dist --no-progress
39-
40-
- name: Execute phpunit
41-
run: composer test -- --colors=always
15+
- name: Checkout code
16+
uses: actions/checkout@v3
17+
18+
- name: Setup PHP
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: ${{ matrix.php }}
22+
tools: composer:v2
23+
coverage: none
24+
25+
- name: Validate composer.json and composer.lock
26+
run: composer validate
27+
28+
- name: Cache Composer packages
29+
id: composer-cache
30+
uses: actions/cache@v3
31+
with:
32+
path: vendor
33+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
34+
restore-keys: |
35+
${{ runner.os }}-php-
36+
37+
- name: Install dependencies
38+
run: composer install --prefer-dist --no-progress
39+
40+
- name: Execute phpunit
41+
run: composer test -- --colors=always
4242

4343
php-cs-fixer:
4444
name: php-cs-fixer
4545
runs-on: ubuntu-latest
4646
steps:
47-
- name: Checkout code
48-
uses: actions/checkout@v3
49-
50-
- name: Setup PHP
51-
uses: shivammathur/setup-php@v2
52-
with:
53-
php-version: 8.1
54-
extensions: dom, curl, libxml, mbstring, zip
55-
tools: composer:v2
56-
coverage: none
57-
58-
- name: Cache Composer packages
59-
id: composer-cache
60-
uses: actions/cache@v3
61-
with:
62-
path: vendor
63-
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
64-
restore-keys: |
65-
${{ runner.os }}-php-
66-
67-
- name: Install dependencies
68-
run: composer install --prefer-dist --no-progress
69-
70-
- name: Execute php-cs-fixer
71-
run: composer cs-fix -- --dry-run --diff --using-cache=no
47+
- name: Checkout code
48+
uses: actions/checkout@v3
49+
50+
- name: Setup PHP
51+
uses: shivammathur/setup-php@v2
52+
with:
53+
php-version: 8.2
54+
extensions: dom, curl, libxml, mbstring, zip
55+
tools: composer:v2
56+
coverage: none
57+
58+
- name: Cache Composer packages
59+
id: composer-cache
60+
uses: actions/cache@v3
61+
with:
62+
path: vendor
63+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
64+
restore-keys: |
65+
${{ runner.os }}-php-
66+
67+
- name: Install dependencies
68+
run: composer install --prefer-dist --no-progress
69+
70+
- name: Execute php-cs-fixer
71+
run: composer cs-fix -- --dry-run --diff --using-cache=no
72+
73+
prettier:
74+
name: Prettier
75+
runs-on: ubuntu-latest
76+
77+
steps:
78+
- name: Checkout code
79+
uses: actions/checkout@v3
80+
81+
- name: Run prettier
82+
uses: actionsx/prettier@v2
83+
with:
84+
args: --check .
7285

7386
phpstan:
7487
name: PHPStan on PHP v${{ matrix.php }}
7588
runs-on: ubuntu-latest
7689
strategy:
7790
fail-fast: true
7891
matrix:
79-
php: [ 8.1, 8.2 ]
92+
php: [8.2]
8093
steps:
81-
- name: Checkout code
82-
uses: actions/checkout@v3
83-
84-
- name: Setup PHP
85-
uses: shivammathur/setup-php@v2
86-
with:
87-
php-version: ${{ matrix.php }}
88-
tools: composer:v2
89-
coverage: none
90-
91-
- name: Validate composer.json and composer.lock
92-
run: composer validate
93-
94-
- name: Cache Composer packages
95-
id: composer-cache
96-
uses: actions/cache@v3
97-
with:
98-
path: vendor
99-
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
100-
restore-keys: |
101-
${{ runner.os }}-php-
102-
103-
- name: Install dependencies
104-
run: composer install --prefer-dist --no-progress
105-
106-
- name: Execute phpstan
107-
run: composer phpstan
94+
- name: Checkout code
95+
uses: actions/checkout@v3
96+
97+
- name: Setup PHP
98+
uses: shivammathur/setup-php@v2
99+
with:
100+
php-version: ${{ matrix.php }}
101+
tools: composer:v2
102+
coverage: none
103+
104+
- name: Validate composer.json and composer.lock
105+
run: composer validate
106+
107+
- name: Cache Composer packages
108+
id: composer-cache
109+
uses: actions/cache@v3
110+
with:
111+
path: vendor
112+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
113+
restore-keys: |
114+
${{ runner.os }}-php-
115+
116+
- name: Install dependencies
117+
run: composer install --prefer-dist --no-progress
118+
119+
- name: Execute phpstan
120+
run: composer phpstan

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
!.idea/fileTemplates
44

55
# Dependencies
6-
/vendor/
6+
/vendor
77
/composer.lock
88

99
# Build/coverage
@@ -16,7 +16,7 @@
1616
**/.phpunit.result.cache
1717

1818
# Temporary
19-
tmp/
19+
/tmp
2020

2121
# Misc
2222
.DS_Store

.prettierignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CHANGELOG.md
2+
3+
/.idea
4+
/build
5+
/coverage
6+
/tmp
7+
/vendor

.prettierrc.yml

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

CONTRIBUTING.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Commands
22

33
Here are some of the commands that you'll need:
4-
- install dependencies: `docker run -it --rm -v $PWD:/app -w /app chialab/php-dev:8.2 composer install`
5-
- run tests with phpunit: `docker run -it --rm -v $PWD:/app -w /app chialab/php-dev:8.2 composer test`
6-
- reformat using php-cs-fixer: `docker run -it --rm -v $PWD:/app -w /app chialab/php-dev:8.2 composer cs-fix`
7-
- analyse with phpstan: `docker run -it --rm -v $PWD:/app -w /app chialab/php-dev:8.2 composer phpstan`
4+
5+
- install dependencies: `docker run -it --rm -v $PWD:/app -w /app chialab/php-dev:8.2 composer install`
6+
- run tests with phpunit: `docker run -it --rm -v $PWD:/app -w /app chialab/php-dev:8.2 composer test`
7+
- reformat using php-cs-fixer: `docker run -it --rm -v $PWD:/app -w /app chialab/php-dev:8.2 composer cs-fix`
8+
- reformat the rest with prettier: `docker run -it --rm -v $PWD:/app -w /app tmknom/prettier --write .`
9+
- analyse with phpstan: `docker run -it --rm -v $PWD:/app -w /app chialab/php-dev:8.2 composer phpstan`

0 commit comments

Comments
 (0)