Skip to content

Commit

Permalink
Merge pull request #77 from buggregator/feat/dx-updates
Browse files Browse the repository at this point in the history
feat: support of Makefile and PHAR builds on local machines
  • Loading branch information
lotyp authored May 13, 2024
2 parents 54c1e51 + d404118 commit 25eb86e
Show file tree
Hide file tree
Showing 23 changed files with 5,738 additions and 551 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ end_of_line = crlf

[*.md]
trim_trailing_whitespace = false

[Makefile]
indent_style = tab
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# https://docs.docker.com/compose/reference/envvars/#compose_project_name
# With custom namespace provided, it will be used to prefix all services
# in Docker network for current project
COMPOSE_PROJECT_NAME=trap

XDEBUG_MODE=coverage
23 changes: 15 additions & 8 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
* text=auto

/.github export-ignore
/tests export-ignore
/.* export-ignore
/phpunit.xml* export-ignore
/phpstan.* export-ignore
/psalm.* export-ignore
/infection.* export-ignore
/codecov.* export-ignore
.github export-ignore
.phive export-ignore
phar export-ignore
tests export-ignore
.* export-ignore
box.json.dist export-ignore
composer.lock export-ignore
docker-compose.yaml export-ignore
Makefile export-ignore
phpunit.xml* export-ignore
phpstan.* export-ignore
psalm.* export-ignore
psalm-baseline.xml export-ignore
infection.* export-ignore
codecov.* export-ignore

*.http binary
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---

# These are supported funding model platforms

patreon: roxblnfk
124 changes: 124 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
---

on: # yamllint disable-line rule:truthy
push:
tags:
- '*.*.*'

name: 📦 Build PHAR release

jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 4
strategy:
matrix:
php-version:
- '8.2'
dependencies:
- locked
env:
TRAP_PHAR: ".build/phar/trap.phar"
TRAP_PHAR_SIGNATURE: ".build/phar/trap.phar.asc"
GPG_KEYS: ".build/phar/keys.asc"
GPG_KEYS_ENCRYPTED: "phar/keys.asc.gpg"
steps:
- name: 📦 Check out the codebase
uses: actions/checkout@v4.1.5

- name: 🛠️ Setup PHP
uses: shivammathur/setup-php@2.30.4
with:
php-version: ${{ matrix.php-version }}
extensions: none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter, sockets
ini-values: error_reporting=E_ALL
coverage: none
tools: phive

- name: 🛠️ Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: 🤖 Validate composer.json and composer.lock
run: composer validate --ansi --strict

- name: 🔍 Get composer cache directory
uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.0

- name: ♻️ Restore cached dependencies installed with composer
uses: actions/cache@v4.0.2
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}
restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-

- name: 📥 Install "${{ matrix.dependencies }}" dependencies with composer
uses: wayofdev/gh-actions/actions/composer/install@v3.1.0
with:
dependencies: ${{ matrix.dependencies }}

- name: 📥 Install dependencies with phive
uses: wayofdev/gh-actions/actions/phive/install@v3.1.0
with:
phive-home: '.phive'
trust-gpg-keys: '0xC00543248C87FB13,0x033E5F8D801A2F8D,0x2DF45277AEF09A2F'

- name: 🔍 Validate configuration for box-project/box
run: .phive/box validate box.json.dist --ansi

- name: 🤖 Compile trap.phar with box-project/box
run: .phive/box compile --ansi

- name: 💥 Show info about trap.phar with box-project/box
run: .phive/box info ${{ env.TRAP_PHAR }} --ansi

- name: 🤔 Run trap.phar help command
run: ${{ env.TRAP_PHAR }} --help

- name: 🔍 Show gpg version
run: gpg --version

- name: 🔑 Decrypt keys.asc.gpg with gpg
run: gpg --batch --output ${{ env.GPG_KEYS }} --passphrase \"${{ secrets.GPG_DECRYPT_PASSPHRASE }}\" --yes --decrypt ${{ env.GPG_KEYS_ENCRYPTED }}

- name: 📥 Import keys from keys.asc with gpg
run: gpg --batch --import ${{ env.GPG_KEYS }}

- name: 🔐 Sign trap.phar with gpg
run: gpg --armor --local-user \"${{ secrets.GPG_LOCAL_USER }}\" --output ${{ env.TRAP_PHAR_SIGNATURE }} --passphrase \"${{ secrets.GPG_KEY_PASSPHRASE }}\" --pinentry-mode loopback --yes --detach-sig ${{ env.TRAP_PHAR }}

- name: ❎ Remove decrypted keys.asc
run: rm ${{ env.GPG_KEYS }}

- name: 📤 Upload release assets
uses: actions/github-script@v7.0.1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
script: |
const fs = require("fs");
const files = [
{
name: "trap.phar",
path: process.env.TRAP_PHAR,
},
{
name: "trap.phar.asc",
path: process.env.TRAP_PHAR_SIGNATURE,
},
];
for (const file of files) {
try {
await github.rest.repos.uploadReleaseAsset({
data: fs.readFileSync(file.path),
name: file.name,
origin: process.env.RELEASE_UPLOAD_URL,
owner: context.repo.owner,
release_id: process.env.RELEASE_ID,
repo: context.repo.repo,
});
} catch (error) {
core.setFailed(error.message);
}
}
81 changes: 0 additions & 81 deletions .github/workflows/cs-fixser.yml

This file was deleted.

90 changes: 90 additions & 0 deletions .github/workflows/lint-php-files.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
---

on: # yamllint disable-line rule:truthy
pull_request:
paths:
- 'src/**'
- 'tests/**'
- 'bin/trap'
- '.php-cs-fixer.dist.php'
push:
paths:
- 'src/**'
- 'tests/**'
- 'bin/trap'
- '.php-cs-fixer.dist.php'

name: 🧹 Fix PHP coding standards

jobs:
coding-standards:
timeout-minutes: 4
runs-on: ${{ matrix.os }}
concurrency:
cancel-in-progress: true
group: coding-standards-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
strategy:
matrix:
os:
- ubuntu-latest
php-version:
- '8.2'
dependencies:
- locked
permissions:
contents: write
steps:
- name: ⚙️ Set git to use LF line endings
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: 🛠️ Setup PHP
uses: shivammathur/setup-php@2.30.4
with:
php-version: ${{ matrix.php-version }}
extensions: none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter, sockets
ini-values: error_reporting=E_ALL
coverage: none

- name: 📦 Check out the codebase
uses: actions/checkout@v4.1.5

- name: 🛠️ Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: 🤖 Validate composer.json and composer.lock
run: composer validate --ansi --strict

- name: 🔍 Get composer cache directory
uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.0

- name: ♻️ Restore cached dependencies installed with composer
uses: actions/cache@v4.0.2
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}
restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-

- name: 📥 Install "${{ matrix.dependencies }}" dependencies with composer
uses: wayofdev/gh-actions/actions/composer/install@v3.1.0
with:
dependencies: ${{ matrix.dependencies }}

- name: 🛠️ Prepare environment
run: make prepare

- name: 🚨 Run coding standards task
run: composer cs:fix
env:
PHP_CS_FIXER_IGNORE_ENV: true

- name: 📤 Commit and push changed files back to GitHub
uses: stefanzweifel/git-auto-commit-action@v5.0.1
with:
commit_message: 'style(php-cs-fixer): lint php files and fix coding standards'
branch: ${{ github.head_ref }}
commit_author: 'github-actions <github-actions@users.noreply.github.com>'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading

0 comments on commit 25eb86e

Please sign in to comment.