Skip to content
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
86 changes: 16 additions & 70 deletions .github/workflows/__shared-ci.yml
Original file line number Diff line number Diff line change
@@ -1,79 +1,25 @@
name: Shared - Continuous Integration for common tasks

on:
workflow_call:

outputs:
documentation-artifact-id:
description: Generated PHP API documentation.
value: ${{ jobs.documentation.outputs.artifact-id }}
permissions: {}

jobs:
checks:
runs-on: ubuntu-latest
uses: hoverkraft-tech/ci-github-php/.github/workflows/continuous-integration.yml@b81aa7b46f6b7a18ff1d9582c918cc1cc8296b98 # 2.0.0
permissions:
contents: read
id-token: write
strategy:
matrix:
include:
- php-versions: "8.2"
- php-versions: "8.3"
- php-versions: "8.4"
- php-versions: "8.5"
stable: true
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: ⚙️ Setup PHP, with composer and extensions
uses: ./.github/workflows/actions/setup-php
with:
php-version: ${{ matrix.php-versions }}

- name: ♻️ Tools cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: tools/cache
key: ${{ runner.os }}-tools-${{ matrix.php-versions }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-tools-

- name: 👕 Lint
if: matrix.stable
run: composer php-cs-fixer -- --format=checkstyle | tools/vendor/bin/cs2pr

- name: 🔬 Rector
id: rector
if: matrix.stable
run: composer rector

- name: 🔬 Static analysis
if: matrix.stable
run: composer phpstan -- --error-format=github

- name: ♻️ Tests cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: tests/.phpunit.result.cache
key: ${{ runner.os }}-tests-${{ github.sha }}
restore-keys: |
${{ runner.os }}-tests-

- name: ♻️ Fixtures cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .cache
key: fixture-cache-${{ hashFiles('composer.lock') }}
restore-keys: fixture-cache-

- name: 🗂️ Load fixtures
run: composer test:load-fixtures

- name: 🧪 Test
run: composer test:ci

- name: 📊 Upload coverage results to Codecov
if: matrix.stable
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
files: ./build/logs/clover.xml
with:
ignore-plugins: false
test: '{"coverage":"codecov","cache":".cache"}'
package: |
{
"tests": "php-css-lint '.example { color: red; }'\nif php-css-lint '.example { unknown-property: invalid; }'; then\n echo 'Invalid CSS unexpectedly passed validation.' >&2\n exit 1\nfi"
}
documentation:
uses: hoverkraft-tech/ci-github-php/.github/workflows/documentation.yml@b81aa7b46f6b7a18ff1d9582c918cc1cc8296b98 # 2.0.0
permissions:
contents: read
35 changes: 0 additions & 35 deletions .github/workflows/actions/setup-php/action.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/greetings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ permissions: {}

jobs:
greetings:
uses: hoverkraft-tech/ci-github-common/.github/workflows/greetings.yml@2334d395217f9811699dbd4ace9d8559e4d99e0d # 0.37.3
uses: hoverkraft-tech/ci-github-common/.github/workflows/greetings.yml@d07ee49b460ae2f3815804b5153fe918092aa321 # 4.2.0
permissions:
contents: read
issues: write
Expand Down
40 changes: 8 additions & 32 deletions .github/workflows/main-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,63 +14,39 @@ permissions: {}
jobs:
ci:
name: Continuous Integration
uses: ./.github/workflows/__shared-ci.yml
uses: $/.github/workflows/__shared-ci.yml
permissions:
contents: read
id-token: write
secrets: inherit

docs-generate-phpdoc:
runs-on: ubuntu-latest
needs: ci
container: phpdoc/phpdoc:3
env:
ARTIFACT_PATH: ./_site
outputs:
artifact-id: ${{ steps.upload-artifact.outputs.artifact-id }}
artifact-path: ${{ env.ARTIFACT_PATH }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: 📃 Generate PHP documentation
run: phpdoc run -d ./src -t $ARTIFACT_PATH/phpdoc

- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
id: upload-artifact
with:
name: docs-phpdoc
path: ${{ env.ARTIFACT_PATH }}

docs-publish:
name: Publish documentation
needs: docs-generate-phpdoc
needs: ci
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
url: ${{ steps.deployment.outputs.url }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
artifact-ids: ${{ needs.docs-generate-phpdoc.outputs.artifact-id }}
path: ${{ needs.docs-generate-phpdoc.outputs.artifact-path }}
artifact-ids: ${{ needs.ci.outputs.documentation-artifact-id }}
path: _site

- uses: hoverkraft-tech/ci-github-publish/actions/deploy/jekyll@ed354ada70b9f518c2bb663e18a80041c2cf5156 # 0.27.1
- uses: hoverkraft-tech/ci-github-publish/actions/deploy/jekyll@4193622a365c0ab0bcbd6645895fd2c3126b72ba # 3.0.2
id: build
with:
site-path: ${{ needs.docs-generate-phpdoc.outputs.artifact-path }}
pages: |
./docs/*.md

- uses: hoverkraft-tech/ci-github-publish/actions/deploy/github-pages@ed354ada70b9f518c2bb663e18a80041c2cf5156 # 0.27.1
- uses: hoverkraft-tech/ci-github-publish/actions/deploy/github-pages@4193622a365c0ab0bcbd6645895fd2c3126b72ba # 3.0.2
id: deployment
with:
build-path: ${{ steps.build.outputs.build-path }}
2 changes: 1 addition & 1 deletion .github/workflows/need-fix-to-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ permissions: {}

jobs:
main:
uses: hoverkraft-tech/ci-github-common/.github/workflows/need-fix-to-issue.yml@0.37.3
uses: hoverkraft-tech/ci-github-common/.github/workflows/need-fix-to-issue.yml@d07ee49b460ae2f3815804b5153fe918092aa321 # 4.2.0
permissions:
contents: read
issues: write
Expand Down
22 changes: 8 additions & 14 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
---
name: "Prepare release"

name: Prepare release
on:
push:
branches: [main]
pull_request:
types: [opened, reopened, synchronize]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

types:
- opened
- reopened
- synchronize
- edited
permissions: {}

jobs:
release:
uses: hoverkraft-tech/ci-github-publish/.github/workflows/prepare-release.yml@ed354ada70b9f518c2bb663e18a80041c2cf5156 # 0.27.1
prepare-release:
uses: hoverkraft-tech/ci-github-publish/.github/workflows/prepare-release.yml@4193622a365c0ab0bcbd6645895fd2c3126b72ba # 3.0.2
permissions:
contents: read
pull-requests: write
2 changes: 1 addition & 1 deletion .github/workflows/pull-request-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ permissions: {}
jobs:
ci:
name: Continuous Integration
uses: ./.github/workflows/__shared-ci.yml
uses: $/.github/workflows/__shared-ci.yml
permissions:
contents: read
id-token: write
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Release
on:
workflow_dispatch:
inputs:
force:
description: Release even when no relevant changes were detected.
type: boolean
default: false
schedule:
- cron: 37 7 * * 1
permissions: {}
concurrency:
group: composer-release
cancel-in-progress: false
jobs:
prepare:
uses: hoverkraft-tech/ci-github-php/.github/workflows/prepare-package-release.yml@b81aa7b46f6b7a18ff1d9582c918cc1cc8296b98 # 2.0.0
permissions:
contents: read
pull-requests: read
with:
force: ${{ github.event_name == 'workflow_dispatch' && inputs.force || false }}
release-config: &release-config |
tag-prefix: v
tag-template: v$RESOLVED_VERSION
name-template: v$RESOLVED_VERSION
validate:
needs: prepare
if: needs.prepare.outputs.status == 'ready'
uses: $/.github/workflows/__shared-ci.yml
permissions:
contents: read
id-token: write
publish:
needs: [prepare, validate]
uses: hoverkraft-tech/ci-github-php/.github/workflows/release.yml@b81aa7b46f6b7a18ff1d9582c918cc1cc8296b98 # 2.0.0
permissions:
contents: write
pull-requests: read
with:
tag: ${{ needs.prepare.outputs.tag }}
release-config: *release-config
secrets:
changelog-summary: ${{ secrets.CHANGELOG_SUMMARY }}
5 changes: 2 additions & 3 deletions .github/workflows/semantic-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ permissions: {}

jobs:
main:
uses: hoverkraft-tech/ci-github-common/.github/workflows/semantic-pull-request.yml@2334d395217f9811699dbd4ace9d8559e4d99e0d # 0.37.3
uses: hoverkraft-tech/ci-github-common/.github/workflows/semantic-pull-request.yml@d07ee49b460ae2f3815804b5153fe918092aa321 # 4.2.0
permissions:
contents: write
pull-requests: write
contents: read
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ permissions: {}

jobs:
main:
uses: hoverkraft-tech/ci-github-common/.github/workflows/stale.yml@0.37.3
uses: hoverkraft-tech/ci-github-common/.github/workflows/stale.yml@d07ee49b460ae2f3815804b5153fe918092aa321 # 4.2.0
permissions:
issues: write
pull-requests: write
6 changes: 3 additions & 3 deletions .github/workflows/update-css-referential.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ jobs:
persist-credentials: false

- name: ⚙️ Setup PHP, with composer and extensions
uses: ./.github/workflows/actions/setup-php
uses: hoverkraft-tech/ci-github-php/actions/setup-php@b81aa7b46f6b7a18ff1d9582c918cc1cc8296b98 # 2.0.0
with:
php-version: 8.5
ignore-plugins: "false"

- name: Generate CSS Referential
run: composer run-script generate-css-referentials

- name: Push changes and create pull request
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
uses: peter-evans/create-pull-request@3ffccacd46053766916f087ce41d627c0b8cf2d1 # v8.1.3
with:
branch: update-css-referential
add-paths: |
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ composer.lock
.cache
tests/.phpunit.result.cache
build/
/junit.xml
/clover.xml
20 changes: 15 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
PHP_VERSION=8.5
PHP_VERSION ?=
PHP_IMAGE_TAG = $(if $(PHP_VERSION),$(PHP_VERSION),dev)
PROJECT_NAME=$(shell basename $(CURDIR))
UID=$(shell id -u)
GID=$(shell id -g)
IMAGE="${PROJECT_NAME}:${PHP_VERSION}"
IMAGE="${PROJECT_NAME}:$(PHP_IMAGE_TAG)"

.PHONY: help

Expand All @@ -11,9 +12,18 @@ help:

setup: build-php install test-load-fixtures ## Initialize project

build-php: ## Build PHP image
@echo "Build php ${PHP_VERSION}"
@DOCKER_BUILDKIT=1 docker build -t "${IMAGE}" --build-arg "VERSION=${PHP_VERSION}" --build-arg "UID=${UID}" --build-arg "GID=${GID}" .
build-php: ## Build PHP image from the Composer constraint, or PHP_VERSION override
@set -eu; version="$(PHP_VERSION)"; \
if [ -z "$$version" ]; then \
workflow_ref=$$(grep -hE '^[[:space:]]*(-[[:space:]]*)?uses:' .github/workflows/*.y*ml | grep -oE 'hoverkraft-tech/ci-github-php/[^@[:space:]]+@[a-f0-9]{40}' | cut -d@ -f2 | sort -u); \
if [ "$${#workflow_ref}" -ne 40 ]; then \
echo 'Expected one consistent ci-github-php commit pin in .github/workflows.' >&2; exit 1; \
fi; \
resolver=$$(docker build --quiet "https://github.com/hoverkraft-tech/ci-github-php.git#$$workflow_ref:actions/get-php-versions"); \
version=$$(docker run --rm --volume "$(CURDIR):/project:ro" "$$resolver"); \
fi; \
echo "Build PHP $$version"; \
DOCKER_BUILDKIT=1 docker build -t "${IMAGE}" --build-arg "VERSION=$$version" --build-arg "UID=${UID}" --build-arg "GID=${GID}" .

install: ## Install PHP dependencies for given PHP version
rm -f composer.lock
Expand Down
Loading
Loading