Add command to build standalone binary #995
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Continuous Integration | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
permissions: | |
contents: read | |
jobs: | |
check-cs: | |
name: Coding Standards | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: PHP-CS-Fixer | |
uses: docker://ghcr.io/php-cs-fixer/php-cs-fixer:3-php8.3 | |
with: | |
args: --config=.php-cs-fixer.php check --diff | |
phpstan: | |
name: Static Analysis | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: PHPStan | |
uses: docker://oskarstark/phpstan-ga | |
env: | |
REQUIRE_DEV: true | |
phpunit: | |
name: "PHPUnit on ${{ matrix.php }} | Castor from ${{ matrix.castor.method }}" | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- php: "8.1" | |
castor: | |
bin: 'bin/castor' | |
method: 'bin/castor' | |
- php: "8.1" | |
castor: | |
bin: 'tools/phar/build/castor.linux-amd64.phar' | |
method: 'phar' | |
- php: "8.1" | |
castor: | |
bin: 'castor' | |
method: 'binary' | |
- php: "8.2" | |
castor: | |
bin: 'bin/castor' | |
method: 'bin/castor' | |
- php: "8.3" | |
castor: | |
bin: 'bin/castor' | |
method: 'bin/castor' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: "${{ matrix.php }}" | |
- name: Install dependencies (project) | |
run: composer install --prefer-dist --no-progress --optimize-autoloader --classmap-authoritative | |
# Needed because we repack an application in some tests | |
- name: Install dependencies (phar builder) | |
run: composer install --prefer-dist --no-progress --optimize-autoloader --classmap-authoritative | |
working-directory: tools/phar | |
- name: Build Castor phar for Linux | |
run: bin/castor castor:phar:linux | |
shell: bash | |
if: matrix.castor.method == 'phar' || matrix.castor.method == 'binary' | |
- name: Restore PHP static building artifacts cache | |
uses: actions/cache/restore@v4 | |
with: | |
path: | | |
/home/runner/.cache/castor/castor-php-static-compiler | |
# https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache | |
key: dynamic-key-${{ github.run_id }} | |
restore-keys: | | |
php-static-building-artifacts-cache- | |
- name: Compile Custom Built PHP along Castor phar for Linux | |
run: bin/castor compile tools/phar/build/castor.linux-amd64.phar --php-extensions=mbstring,phar,posix,tokenizer,pcntl | |
shell: bash | |
if: matrix.castor.method == 'binary' | |
- name: Link box | |
run: sudo ln -s $GITHUB_WORKSPACE/tools/phar/vendor/bin/box /usr/local/bin/box | |
- name: Install PHPUnit | |
run: vendor/bin/simple-phpunit install | |
- name: Run tests | |
run: vendor/bin/simple-phpunit | |
env: | |
CASTOR_BIN: ${{ github.workspace }}/${{ matrix.castor.bin }} | |
# Workaround because hashFiles() can only include files inside the GITHUB_WORKSPACE | |
- name: Generate PHP static building artifacts cache key | |
run: echo "php_build_artifact_cache_key=$(find /home/runner/.cache/castor/castor-php-static-compiler -type f -exec md5sum {} + | sort -k 2 | md5sum | awk '{print $1}')" >> $GITHUB_ENV | |
- name: Save PHP static building artifacts cache | |
uses: actions/cache/save@v4 | |
with: | |
path: | | |
/home/runner/.cache/castor/castor-php-static-compiler | |
key: php-static-building-artifacts-cache-${{ env.php_build_artifact_cache_key }} | |
# Cache outputs from the "binary" job specifically, as it generates an additional PHP build not produced by other jobs | |
if: matrix.castor.method == 'binary' | |
phar: | |
name: Ensure phar is OK | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build all the phars | |
uses: ./.github/actions/phar |