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
13 changes: 13 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/tests export-ignore
/vendor export-ignore

/README.md export-ignore
/LICENSE export-ignore
/Makefile export-ignore
/phpunit.xml export-ignore
/phpstan.neon.dist export-ignore
/infection.json.dist export-ignore

/.github export-ignore
/.gitignore export-ignore
/.gitattributes export-ignore
31 changes: 31 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: 2

updates:
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 0
labels:
- "php"
- "security"
- "dependencies"
groups:
php-security:
applies-to: security-updates
patterns:
- "*"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "build"
labels:
- "dependencies"
- "github-actions"
groups:
github-actions:
patterns:
- "*"
25 changes: 25 additions & 0 deletions .github/workflows/auto-assign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Auto assign issues and pull requests

on:
issues:
types:
- opened
pull_request:
types:
- opened

jobs:
run:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: Assign issues and pull requests
uses: gustavofreze/auto-assign@2.1.0
with:
assignees: '${{ vars.ASSIGNEES }}'
github_token: '${{ secrets.GITHUB_TOKEN }}'
allow_self_assign: 'true'
allow_no_assignees: 'true'
assignment_options: 'ISSUE,PULL_REQUEST'
87 changes: 87 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: CI

on:
pull_request:

permissions:
contents: read

env:
PHP_VERSION: '8.5'

jobs:
build:
name: Build
runs-on: ubuntu-latest

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

- name: Configure PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
tools: composer:2

- name: Validate composer.json
run: composer validate --no-interaction

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

- name: Upload vendor and composer.lock as artifact
uses: actions/upload-artifact@v6
with:
name: vendor-artifact
path: |
vendor
composer.lock

auto-review:
name: Auto review
runs-on: ubuntu-latest
needs: build

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

- name: Configure PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
tools: composer:2

- name: Download vendor artifact from build
uses: actions/download-artifact@v7
with:
name: vendor-artifact
path: .

- name: Run review
run: composer review

tests:
name: Tests
runs-on: ubuntu-latest
needs: auto-review

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

- name: Configure PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
tools: composer:2

- name: Download vendor artifact from build
uses: actions/download-artifact@v7
with:
name: vendor-artifact
path: .

- name: Run tests
run: composer tests
35 changes: 35 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Security checks

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: "0 0 * * *"

permissions:
actions: read
contents: read
security-events: write

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: [ "actions" ]

steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}

- name: Perform CodeQL analysis
uses: github/codeql-action/analyze@v4
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.idea

vendor
report
.phpunit.*

*.lock
68 changes: 68 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
PWD := $(CURDIR)
ARCH := $(shell uname -m)
PLATFORM :=

ifeq ($(ARCH),arm64)
PLATFORM := --platform=linux/amd64
endif

DOCKER_RUN = docker run ${PLATFORM} --rm -it --net=host -v ${PWD}:/app -w /app gustavofreze/php:8.5-alpine

RESET := \033[0m
GREEN := \033[0;32m
YELLOW := \033[0;33m

.DEFAULT_GOAL := help

.PHONY: configure
configure: ## Configure development environment
@${DOCKER_RUN} composer update --optimize-autoloader

.PHONY: test
test: ## Run all tests with coverage
@${DOCKER_RUN} composer tests

.PHONY: test-file
test-file: ## Run tests for a specific file (usage: make test-file FILE=path/to/file)
@${DOCKER_RUN} composer test-file ${FILE}

.PHONY: test-no-coverage
test-no-coverage: ## Run all tests without coverage
@${DOCKER_RUN} composer tests-no-coverage

.PHONY: review
review: ## Run static code analysis
@${DOCKER_RUN} composer review

.PHONY: show-reports
show-reports: ## Open static analysis reports (e.g., coverage, lints) in the browser
@sensible-browser report/coverage/coverage-html/index.html report/coverage/mutation-report.html

.PHONY: clean
clean: ## Remove dependencies and generated artifacts
@sudo chown -R ${USER}:${USER} ${PWD}
@rm -rf report vendor .phpunit.cache *.lock

.PHONY: help
help: ## Display this help message
@echo "Usage: make [target]"
@echo ""
@echo "$$(printf '$(GREEN)')Setup$$(printf '$(RESET)')"
@grep -E '^(configure):.*?## .*$$' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*? ## "}; {printf "$(YELLOW)%-25s$(RESET) %s\n", $$1, $$2}'
@echo ""
@echo "$$(printf '$(GREEN)')Testing$$(printf '$(RESET)')"
@grep -E '^(test|test-file|test-no-coverage):.*?## .*$$' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; {printf "$(YELLOW)%-25s$(RESET) %s\n", $$1, $$2}'
@echo ""
@echo "$$(printf '$(GREEN)')Quality$$(printf '$(RESET)')"
@grep -E '^(review):.*?## .*$$' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; {printf "$(YELLOW)%-25s$(RESET) %s\n", $$1, $$2}'
@echo ""
@echo "$$(printf '$(GREEN)')Reports$$(printf '$(RESET)')"
@grep -E '^(show-reports):.*?## .*$$' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; {printf "$(YELLOW)%-25s$(RESET) %s\n", $$1, $$2}'
@echo ""
@echo "$$(printf '$(GREEN)')Cleanup$$(printf '$(RESET)')"
@grep -E '^(clean):.*?## .*$$' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; {printf "$(YELLOW)%-25s$(RESET) %s\n", $$1, $$2}'
Loading