Skip to content

Windows

Windows #806

Workflow file for this run

name: Lint and test
on:
push:
branches:
- master
- main
paths:
- '**.php'
- 'composer.json'
- '.github/workflows/main.yml'
pull_request:
types: [opened, synchronize, ready_for_review, reopened]
branches:
- master
- main
paths:
- '**.php'
- 'composer.json'
- '.github/workflows/main.yml'
workflow_dispatch:
concurrency:
# Cancel previous runs of this workflow if they are testing the same branch
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
tests:
strategy:
matrix:
php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
# os: [ubuntu-latest]
os: [ubuntu-latest, windows-latest]
fail-fast: false
name: PHP tests ${{ matrix.php }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2, phive
extensions: fileinfo, gd, zip
- name: Install Phive tools
if: ${{ github.event.pull_request.author_association == 'COLLABORATOR' || github.event.pull_request.author_association == 'OWNER' }}
# Keys taken from `phive status`
# `phive status | grep -oE '[A-F0-9]{16}' | tr '\n' ',' | sed 's/,$//'`
# sed -i "s|^\s*phive install --trust-gpg-keys .*| phive install --trust-gpg-keys $(phive status | grep -oE '[A-F0-9]{16}' | paste -sd,)|" .github/workflows/phpstan.yml
run: |
phive install --trust-gpg-keys A9DB489A9190DE9B,4AA394086372C20A
phive status
env:
# We need to be authenticated to skip GitHub rate limits
# Generate a key at: https://github.com/settings/tokens, "classic"
# Approve the 2FA notification on your phone (I presume/hope)
# "Note" what it is for, I use ~PHIVE_GH_RATE_LIMIT_BRIANHENRY_EXPIRES_DEC182026 etc.
# Choose "Expiration", "Custom"
# For "Select Date", the Expiration date can only be set ~364 days ahead
# No scopes are needed, scroll down and click "Generate Token"
# Copied the displayed key
# Visit https://github.com/your/repo/settings/secrets/actions
# Click "New repository secret" and fill it in
# Do the same at https://github.com/your/repo/settings/secrets/dependabot
#
# Fix for rate limited GitHub API requests. See https://github.com/phar-io/phive/issues/384#issuecomment-1337064012
GITHUB_AUTH_TOKEN: ${{ secrets.PHIVE_GH_RATE_LIMIT_BRIANHENRY_EXPIRES_DEC182026 }}
- name: Install Phive tools (unauthenticated)
# secrets are not available to users without write access
if: ${{ github.event.pull_request.author_association != 'COLLABORATOR' && github.event.pull_request.author_association != 'OWNER' }}
run: |
phive install --trust-gpg-keys A9DB489A9190DE9B,4AA394086372C20A
phive status
- name: Setup problem matcher for PHPUnit
run: |
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Debugging
run: |
php --version
php -m
composer --version
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Run previously workflows' failed tests first
uses: BrianHenryIE/bh-phpunit-failed-tests-action@main
with:
phpunit-command: vendor/bin/phpunit
env:
RENAMESPACER_LOG: "debug"
- name: Run tests
run: vendor/bin/phpunit --order-by=random
- name: Build phar
run:
./scripts/createphar.sh
- uses: actions/upload-artifact@v4
if: ${{ matrix.php == '7.4' && github.event_name == 'pull_request' }}
id: artifact-upload-step
with:
name: strauss.phar
path: strauss.phar
- name: Add phar to PR comment
uses: mshick/add-pr-comment@v2
if: ${{ matrix.php == '7.4' && github.event_name == 'pull_request' }}
with:
message-id: strauss-phar
message: ${{ format('[strauss.phar.zip]({0}) @ {1} {2} `composer require brianhenryie/strauss:"dev-master#{1}" --dev`', steps.artifact-upload-step.outputs.artifact-url, github.event.pull_request.head.sha, '\n') }}
continue-on-error: true
- name: Run tests with strauss.phar
run: vendor/bin/phpunit
spelling:
runs-on: ubuntu-latest
name: Spelling
steps:
- uses: actions/checkout@v4
- name: Search for misspellings
uses: crate-ci/typos@master
lint:
runs-on: ubuntu-latest
name: Lint project files
steps:
- uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: composer, cs2pr, phive
extensions: fileinfo, gd
- name: Install Phive tools
if: ${{ github.event.pull_request.author_association == 'COLLABORATOR' || github.event.pull_request.author_association == 'OWNER' }} # secrets are not available to users without write access
# Keys taken from `phive status`
# `phive status | grep -oE '[A-F0-9]{16}' | tr '\n' ',' | sed 's/,$//'`
# sed -i "s|^\s*phive install --trust-gpg-keys .*| phive install --trust-gpg-keys $(phive status | grep -oE '[A-F0-9]{16}' | paste -sd,)|" .github/workflows/phpstan.yml
run: |
phive install --trust-gpg-keys A9DB489A9190DE9B,4AA394086372C20A
phive status
env:
# We need to be authenticated to skip GitHub rate limits
# Generate a key at: https://github.com/settings/tokens, "classic"
# Approve the 2FA notification on your phone (I presume/hope)
# "Note" what it is for, I use ~PHIVE_GH_RATE_LIMIT_BRIANHENRY_EXPIRES_DEC182026 etc.
# Choose "Expiration", "Custom"
# For "Select Date", the Expiration date can only be set ~364 days ahead
# No scopes are needed, scroll down and click "Generate Token"
# Copied the displayed key
# Visit https://github.com/your/repo/settings/secrets/actions
# Click "New repository secret" and fill it in
# Do the same at https://github.com/your/repo/settings/secrets/dependabot
#
# Fix for rate limited GitHub API requests. See https://github.com/phar-io/phive/issues/384#issuecomment-1337064012
GITHUB_AUTH_TOKEN: ${{ secrets.PHIVE_GH_RATE_LIMIT_BRIANHENRY_EXPIRES_DEC182026 }}
- name: Install Phive tools (unauthenticated)
# secrets are not available to users without write access
if: ${{ github.event.pull_request.author_association != 'COLLABORATOR' && github.event.pull_request.author_association != 'OWNER' }}
run: |
phive install --trust-gpg-keys A9DB489A9190DE9B,4AA394086372C20A
phive status
- name: Debugging
run: |
php --version
php -m
composer --version
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Run validate
run: |
vendor/bin/phpcbf || true
vendor/bin/phpcs -q -n --report=checkstyle | cs2pr
- name: Commit PHPCBF changes
if: ${{ github.ref == 'refs/heads/master' && github.event_name == 'push' }} # only commit on pushes to master
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "🤖 PHPCBF"