Skip to content
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

Create framework #3

Merged
merged 16 commits into from
Sep 6, 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
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ phpunit.xml* export-ignore
pest.xml* export-ignore
psalm.* export-ignore
psalm-baseline.xml export-ignore
dload.xml export-ignore
box.json* export-ignore
ai.xml export-ignore
infection.* export-ignore
codecov.* export-ignore
56 changes: 56 additions & 0 deletions .github/.yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---

extends: default

ignore: |
.build/
vendor/
bin/

rules:
braces:
# Defaults
# min-spaces-inside: 0
# max-spaces-inside: 0

# Keep 0 min-spaces to not error on empty {} collection definitions
min-spaces-inside: 0

# Allow one space inside braces to improve code readability
max-spaces-inside: 1

brackets:
# Defaults
# min-spaces-inside: 0
# max-spaces-inside: 0

# Keep 0 min-spaces to not error on empty [] collection definitions
min-spaces-inside: 0

# Allow one space inside braces to improve code readability
max-spaces-inside: 1

colons:
# Defaults
# min-spaces-before: 0
# max-spaces-after: 1

# Allow multiple spaces after a colon to allow indentation of YAML
# dictionary values
max-spaces-after: -1

commas:
# Defaults
# max-spaces-after: 1

# Allow multiple spaces after a comma to allow indentation of YAML
# dictionary values
max-spaces-after: -1

comments:
require-starting-space: true
min-spaces-from-content: 1

line-length: disable

...
Binary file added .github/phar/keys.asc.gpg
Binary file not shown.
100 changes: 100 additions & 0 deletions .github/workflows/build-phar-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
---

on: # yamllint disable-line rule:truthy
release:
types:
- published

name: 📦 Build PHAR release

jobs:
build-release:
runs-on: ubuntu-latest
timeout-minutes: 4
strategy:
matrix:
php-version:
- '8.2'
dependencies:
- locked
env:
PHAR_PATH: ".build/phar/ai.phar"
PHAR_SIGNATURE: ".build/phar/ai.phar.asc"
GPG_KEYS: ".build/phar/keys.asc"
GPG_KEYS_ENCRYPTED: ".github/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 --ansi

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

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

- name: 🤔 Run ai.phar help command
run: ${{ env.PHAR_PATH }} --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 ai.phar with gpg
run: gpg --armor --local-user "${{ secrets.GPG_LOCAL_USER }}" --output ${{ env.PHAR_SIGNATURE }} --passphrase "${{ secrets.GPG_KEY_PASSPHRASE }}" --pinentry-mode loopback --yes --detach-sig ${{ env.PHAR_PATH }}

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

- name: 📤 Upload release assets
uses: softprops/action-gh-release@v2.0.5
if: startsWith(github.ref, 'refs/tags/')
with:
token: "${{ secrets.RELEASE_TOKEN }}"
files: |
${{ env.PHAR_PATH }}
${{ env.PHAR_SIGNATURE }}
118 changes: 118 additions & 0 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
---

on: # yamllint disable-line rule:truthy
pull_request:
branches:
- master
push:
branches:
- master

name: 🧹 Fix PHP coding standards

jobs:
yaml-linting:
timeout-minutes: 4
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
steps:
- name: 📦 Check out the codebase
uses: actions/checkout@v4.1.6

- name: 🧐 Lint YAML files
uses: ibiqlik/action-yamllint@v3.1.1
with:
config_file: .github/.yamllint.yaml
file_or_dir: '.'
strict: true

markdown-linting:
timeout-minutes: 4
runs-on: ubuntu-latest
concurrency:
cancel-in-progress: true
group: markdown-linting-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
steps:
- name: 📦 Check out the codebase
uses: actions/checkout@v4.1.6

- name: 🧐 Lint Markdown files
uses: DavidAnson/markdownlint-cli2-action@v16.0.0
with:
globs: |
**/*.md
!CHANGELOG.md

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.6

- 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 }}
59 changes: 59 additions & 0 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---

name: 🔐 Security analysis

on: # yamllint disable-line rule:truthy
pull_request:
push:

jobs:
security-analysis:
timeout-minutes: 4
runs-on: ${{ matrix.os }}
concurrency:
cancel-in-progress: true
group: security-analysis-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
strategy:
fail-fast: true
matrix:
os:
- ubuntu-latest
php-version:
- '8.2'
dependencies:
- locked
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

- 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
uses: wayofdev/gh-actions/actions/composer/install@v3.1.0
with:
dependencies: ${{ matrix.dependencies }}

- name: 🐛 Check installed packages for security vulnerability advisories
run: composer audit --ansi
Loading
Loading