Skip to content

feat: Template sync #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
trim_trailing_whitespace = false
8 changes: 8 additions & 0 deletions .github/template-sync.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"repositories": [
{
"url": "https://github.com/tenantcloud/php-package-skeleton",
"branch": "sync"
}
]
}
28 changes: 14 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Release

on:
workflow_run:
workflows: ["Tests"]
workflows: ['Tests']
types:
- completed
branches:
Expand All @@ -18,17 +18,17 @@ jobs:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Create a release
uses: cycjimmy/semantic-release-action@v3
with:
extra_plugins: |
@semantic-release/changelog
@semantic-release/git
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create a release
uses: cycjimmy/semantic-release-action@v3
with:
extra_plugins: |
@semantic-release/changelog
@semantic-release/git
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
62 changes: 62 additions & 0 deletions .github/workflows/template-sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Template sync

on:
workflow_dispatch:
schedule:
- cron: '*/5 * * * *'

jobs:
sync:
name: Sync
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Sync from template
id: sync_from_template
uses: tenantcloud/template-sync@v1.0.0-alpha.9
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Reformat
uses: actionsx/prettier@v2
with:
args: --write .

- name: Generate token to read from source repo
id: generate_token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.PACKAGE_SYNC_APP_ID }}
private_key: ${{ secrets.PACKAGE_SYNC_PRIVATE_KEY }}

- name: Create PR
uses: peter-evans/create-pull-request@v6
with:
token: ${{ steps.generate_token.outputs.token }}
committer: 'package-sync[bot] <165811605+package-sync[bot]@users.noreply.github.com>'
branch: 'template-sync'
delete-branch: true
title: 'chore: Sync changes from the template'
commit-message: 'chore: Sync changes from the template'
body: ${{ steps.sync_from_template.outputs.report }}
assignees: oprypkhantc
reviewers: oprypkhantc

# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
# GitHub automatically disables `schedule` workflows in public repositories
# after 60 days without commits, so this job is there to prevent it.
workflow-keepalive:
name: Workflow keepalive
runs-on: ubuntu-latest
if: github.event_name == 'schedule'

permissions:
actions: write

steps:
- uses: liskin/gh-workflow-keepalive@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
175 changes: 94 additions & 81 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,99 +9,112 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [ 8.1, 8.2 ]
php: [8.2]

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none

- name: Validate composer.json and composer.lock
run: composer validate

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Execute phpunit
run: composer test -- --colors=always
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none

- name: Validate composer.json and composer.lock
run: composer validate

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Execute phpunit
run: composer test -- --colors=always

php-cs-fixer:
name: php-cs-fixer
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
extensions: dom, curl, libxml, mbstring, zip
tools: composer:v2
coverage: none

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Execute php-cs-fixer
run: composer cs-fix -- --dry-run --diff --using-cache=no
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
extensions: dom, curl, libxml, mbstring, zip
tools: composer:v2
coverage: none

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Execute php-cs-fixer
run: composer cs-fix -- --dry-run --diff --using-cache=no

prettier:
name: Prettier
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Run prettier
uses: actionsx/prettier@v2
with:
args: --check .

phpstan:
name: PHPStan on PHP v${{ matrix.php }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: [ 8.1, 8.2 ]
php: [8.2]
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none

- name: Validate composer.json and composer.lock
run: composer validate

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Execute phpstan
run: composer phpstan
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none

- name: Validate composer.json and composer.lock
run: composer validate

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Execute phpstan
run: composer phpstan
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
!.idea/fileTemplates

# Dependencies
/vendor/
/vendor
/composer.lock

# Build/coverage
Expand All @@ -16,7 +16,7 @@
**/.phpunit.result.cache

# Temporary
tmp/
/tmp

# Misc
.DS_Store
Expand Down
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CHANGELOG.md

/.idea
/build
/coverage
/tmp
/vendor
1 change: 1 addition & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
singleQuote: true
10 changes: 6 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Commands

Here are some of the commands that you'll need:
- install dependencies: `docker run -it --rm -v $PWD:/app -w /app chialab/php-dev:8.2 composer install`
- run tests with phpunit: `docker run -it --rm -v $PWD:/app -w /app chialab/php-dev:8.2 composer test`
- reformat using php-cs-fixer: `docker run -it --rm -v $PWD:/app -w /app chialab/php-dev:8.2 composer cs-fix`
- analyse with phpstan: `docker run -it --rm -v $PWD:/app -w /app chialab/php-dev:8.2 composer phpstan`

- install dependencies: `docker run -it --rm -v $PWD:/app -w /app chialab/php-dev:8.2 composer install`
- run tests with phpunit: `docker run -it --rm -v $PWD:/app -w /app chialab/php-dev:8.2 composer test`
- reformat using php-cs-fixer: `docker run -it --rm -v $PWD:/app -w /app chialab/php-dev:8.2 composer cs-fix`
- reformat the rest with prettier: `docker run -it --rm -v $PWD:/app -w /app tmknom/prettier --write .`
- analyse with phpstan: `docker run -it --rm -v $PWD:/app -w /app chialab/php-dev:8.2 composer phpstan`
Loading