Skip to content
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
21 changes: 21 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.git
.github
.claude
.scribe
.idea
.vscode
.env
.env.*
!.env.example
node_modules
vendor
tests
storage/logs/*
storage/framework/cache/data/*
storage/framework/sessions/*
storage/framework/views/*
bootstrap/cache/*.php
database/*.sqlite
frankenphp
Dockerfile
.dockerignore
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
SANCTUM_EXPIRATION=120
API_KEY_DEFAULT_DAYS=90
API_KEY_MAX_DAYS=365
IDEMPOTENCY_TTL=86400
SECURITY_FORCE_HTTPS=false
SECURITY_HSTS_ENABLED=true
Expand Down Expand Up @@ -48,6 +50,8 @@ BROADCAST_CONNECTION=log
FILESYSTEM_DISK=local
QUEUE_CONNECTION=database

OCTANE_SERVER=frankenphp

CACHE_STORE=database
# CACHE_PREFIX=

Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,55 @@ jobs:

- name: Run test suite
run: php artisan test

# The test suite regenerates public/docs/openapi.yaml, so this grades the spec the code
# produces now, against .legible.yaml.
- name: Check the OpenAPI spec is agent-ready
env:
LEGIBLE_VERSION: 0.1.2
run: |
archive="legible_${LEGIBLE_VERSION}_linux_amd64.tar.gz"
base="https://github.com/JustSteveKing/legible/releases/download/v${LEGIBLE_VERSION}"
curl -fsSLO "${base}/${archive}"
curl -fsSL "${base}/checksums.txt" | grep " ${archive}\$" | sha256sum -c -
tar xzf "${archive}" legible
./legible check public/docs/openapi.yaml

image:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Build the production image
run: docker build --tag kit:ci .

# Boots with production settings, so ProductionSecurityChecks runs, then asks Octane for a
# health check and an API problem through a TLS-terminating proxy's headers.
- name: Boot it and make requests
run: |
docker run --detach --name kit --publish 8000:8000 \
--env APP_KEY="base64:$(openssl rand -base64 32)" \
--env APP_URL=https://api.example.test \
--env SECURITY_FORCE_HTTPS=true \
--env TRUSTED_HOSTS=api.example.test \
--env CORS_ALLOWED_ORIGINS=https://app.example.test \
--env DB_CONNECTION=sqlite \
--env DB_DATABASE=/tmp/kit.sqlite \
kit:ci
for attempt in $(seq 1 30); do
curl --silent --fail --header 'Host: api.example.test' --header 'X-Forwarded-Proto: https' \
http://127.0.0.1:8000/up > /dev/null && break
sleep 1
done
curl --silent --fail --header 'Host: api.example.test' --header 'X-Forwarded-Proto: https' \
http://127.0.0.1:8000/up > /dev/null
curl --silent --include --header 'Host: api.example.test' --header 'X-Forwarded-Proto: https' \
http://127.0.0.1:8000/v1/auth/me | tee response.txt
grep --quiet '^HTTP/1.1 401' response.txt
grep --quiet --ignore-case '^content-type: application/problem+json' response.txt

- name: Show the container log
if: failure()
run: docker logs kit
25 changes: 23 additions & 2 deletions .github/workflows/dependency-updates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ jobs:
coverage: none

- name: Install current dependencies
run: composer install --no-interaction --no-progress --prefer-dist --no-scripts
run: |
composer install --no-interaction --no-progress --prefer-dist --no-scripts
cp composer.lock "${RUNNER_TEMP}/composer.lock.before"

# Vet's plugin keeps every release younger than vet.json's minimum-release-age out of the
# update. It then refuses to install what nobody has trusted yet and exits 1, after the lock
Expand All @@ -40,19 +42,37 @@ jobs:
- name: Install the updated lock without Vet
run: composer install --no-plugins --no-interaction --no-progress --prefer-dist --no-scripts

# Laravel's own packages are trusted by policy (AGENTS.md, Dependencies). When they are the
# only packages the update changed, their trust is recorded here and the PR needs no review.
- name: Trust Laravel's own packages
run: |
decision=$(jq -rn --slurpfile old "${RUNNER_TEMP}/composer.lock.before" --slurpfile new composer.lock '
def index(lock): [lock.packages[], lock["packages-dev"][]] | map({key: .name, value: (.version + "@" + (.dist.reference // .source.reference // ""))}) | from_entries;
(index($old[0])) as $before
| [index($new[0]) | to_entries[] | select($before[.key] != .value) | .key]
| if length > 0 and all(startswith("laravel/")) then "trust" else "review" end')
if [ "${decision}" = 'trust' ]; then
./vendor/bin/vet --fresh --no-interaction --no-ansi
echo 'LARAVEL_ONLY=true' >> "${GITHUB_ENV}"
fi

- name: Audit with Vet
run: |
./vendor/bin/vet --no-interaction --no-ansi > vet-report.txt 2>&1 || true
{
echo 'Automated weekly dependency refresh: `composer update`, holding back every release younger than `minimum-release-age` in `vet.json`.'
echo
if [ "${LARAVEL_ONLY:-}" = 'true' ]; then
echo 'Every changed package is `laravel/*`, trusted by policy, so `vet.json` is updated in this PR and it needs no review.'
echo
fi
echo '## Vet'
echo
echo '```'
cat vet-report.txt
echo '```'
echo
echo 'Untrusted packages fail `composer install` in CI. To review, check out this branch, run `composer install --no-plugins`, then `./vendor/bin/vet` in a terminal: read each change, or hand them to your coding agent, and pick the packages you trust. Commit `vet.json` to this branch; that push runs CI.'
echo 'Otherwise, untrusted packages fail `composer install` in CI. To review, check out this branch, run `composer install --no-plugins`, then `./vendor/bin/vet` in a terminal: read each change, or hand them to your coding agent, and pick the packages you trust. Commit `vet.json` to this branch; that push runs CI.'
} > pr-body.md
rm update.log vet-report.txt

Expand All @@ -65,5 +85,6 @@ jobs:
add-paths: |
composer.json
composer.lock
vet.json
branch: bot/dependency-updates
delete-branch: true
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@
Homestead.json
Homestead.yaml
Thumbs.db

# Octane: a locally downloaded FrankenPHP binary and its Caddy state
/frankenphp
/public/frankenphp-worker.php
**/caddy
/.legible
18 changes: 18 additions & 0 deletions .legible.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# legible scores public/docs/openapi.yaml for agent readiness: what will trip up an LLM calling
# the API as tools. CI fails on any warning or a score under 95. `legible explain <rule>` says why a
# rule matters. https://github.com/JustSteveKing/legible
fail-on: warning
fail-under: 95

ignore:
- rule: error-shape
operations:
- POST /v1/auth/register
- POST /v1/auth/login
- POST /v1/auth/password/forgot
- POST /v1/auth/password/reset
- GET /v1/auth/password/reset/*
- POST /v1/auth/tokens
reason: >
Validation problems add an errors member keyed by field, which apiguide.dev's
validation-failed type defines. Every problem shares type, title, status and detail.
Loading
Loading