Skip to content
Open
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
60 changes: 60 additions & 0 deletions .github/workflows/composer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Composer

on:
push:
branches:
- main
pull_request:
# New advisories are published without anything changing here, so check every Monday as well.
schedule:
- cron: '20 5 * * 1'
workflow_dispatch:

permissions:
contents: read

# A new push to a pull request cancels the run still going for the old one. Each commit on main gets a
# group of its own, so every one of them is checked.
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.sha }}
cancel-in-progress: true

# Both jobs read composer.json and composer.lock only. They install nothing and need no plugin licence
# credentials, so they work the same for pull requests from forks. They're separate jobs so that the
# branch ruleset can require composer-validate without also requiring composer-audit.
jobs:
composer-validate:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v7

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
coverage: none

# Fails when composer.json is invalid, or when composer.lock doesn't match it, which happens when
# composer.json is edited by hand without running composer update. Run that command locally to fix it.
- name: Validate composer.json and composer.lock
run: composer validate --strict

composer-audit:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v7

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
coverage: none

# Fails when a locked package has a known security advisory. Abandoned packages are listed in the
# output but don't fail the check, because replacing one is rarely urgent.
- name: Check dependencies for security advisories
run: composer audit --locked --abandoned=report