Skip to content
Open
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
20 changes: 16 additions & 4 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
# Path-based git attributes
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html

# Ignore all test and documentation with "export-ignore".
# Keep development files out of the Composer package. docs, llms.txt, dist and
# resources/boost ship with it, for apps without Vite, AI assistants and Laravel Boost.
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/.github export-ignore
/.editorconfig export-ignore
/.prettierrc.json export-ignore
/.prettierignore export-ignore
/eslint.config.js export-ignore
/phpunit.xml.dist export-ignore
/.scrutinizer.yml export-ignore
/pint.json export-ignore
/tests export-ignore
/.editorconfig export-ignore
/AGENTS.md export-ignore
/CLAUDE.md export-ignore
/node_modules export-ignore
/package.json export-ignore
/pnpm-lock.yaml export-ignore
/tsconfig.json export-ignore
/vite.config.ts export-ignore
/vitest.config.ts export-ignore
20 changes: 0 additions & 20 deletions .github/coverage.svg

This file was deleted.

73 changes: 0 additions & 73 deletions .github/workflows/run-tests.yml

This file was deleted.

233 changes: 233 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
name: tests

on:
pull_request:
push:
branches:
- main
- next-gen
workflow_dispatch:

# The unreleased javaabu/* dependencies come from VCS repositories; the job's own
# token keeps Composer within GitHub's API limits
env:
COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ github.token }}"}}'

jobs:
pint:
runs-on: ubuntu-latest

name: Pint and dependencies

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

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

- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"

- name: Cache Composer downloads
uses: actions/cache@v6
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-${{ github.job }}-${{ strategy.job-index }}-${{ hashFiles('composer.json', 'composer.lock') }}
restore-keys: |
composer-${{ runner.os }}-${{ github.job }}-${{ strategy.job-index }}-
composer-${{ runner.os }}-${{ github.job }}-

- name: Install dependencies
run: composer update --prefer-dist --no-interaction --no-progress

- name: Check code style
run: vendor/bin/pint --test

# javaabu/helpers pins javaabu/settings ^1, which breaks installs next to settings v2
- name: No javaabu/helpers or javaabu/settings ^1 in production dependencies
run: |
tree="$(composer show --tree --no-dev)"
if echo "$tree" | grep -E 'javaabu/helpers'; then
echo "javaabu/mediapicker must not depend on javaabu/helpers"
exit 1
fi
if echo "$tree" | grep -E 'javaabu/settings (\^|~)?1'; then
echo "javaabu/mediapicker must not depend on javaabu/settings ^1"
exit 1
fi

js:
runs-on: ubuntu-latest

name: TypeScript (lint, typecheck, tests, dist)

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

# @javaabu/block-editor and @javaabu/stencil come from their Composer packages in vendor/
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.4
coverage: none

- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"

- name: Cache Composer downloads
uses: actions/cache@v6
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-${{ github.job }}-${{ strategy.job-index }}-${{ hashFiles('composer.json', 'composer.lock') }}
restore-keys: |
composer-${{ runner.os }}-${{ github.job }}-${{ strategy.job-index }}-
composer-${{ runner.os }}-${{ github.job }}-

- name: Install Composer dependencies
run: composer update --prefer-dist --no-interaction --no-progress

- name: Setup pnpm
uses: pnpm/action-setup@v4

# Keep the store out of node_modules, where @javaabu/forms' prepare build can't
# emit portable types (Javaabu/react-forms#20)
- name: Use a pnpm store outside node_modules
run: pnpm config set store-dir ~/.pnpm-store

- name: Setup Node
uses: actions/setup-node@v5
with:
node-version: 22
cache: pnpm

- name: Install npm dependencies
run: pnpm install --frozen-lockfile

- run: pnpm lint
- run: pnpm format:check
- run: pnpm typecheck

- name: Tests with coverage
run: pnpm test:coverage

- name: Upload coverage
uses: codecov/codecov-action@v5
with:
files: coverage/lcov.info
flags: js
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false

- name: Check that the committed dist is up to date
run: |
pnpm build
git diff --exit-code -- dist || (echo "dist is out of date: run pnpm build and commit it." && exit 1)

without-translatable:
runs-on: ubuntu-latest

name: Tests without javaabu/translatable

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.4
extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv, gd, exif, fileinfo
coverage: none

- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"

- name: Cache Composer downloads
uses: actions/cache@v6
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-${{ github.job }}-${{ strategy.job-index }}-${{ hashFiles('composer.json', 'composer.lock') }}
restore-keys: |
composer-${{ runner.os }}-${{ github.job }}-${{ strategy.job-index }}-
composer-${{ runner.os }}-${{ github.job }}-

- name: Install dependencies without javaabu/translatable
run: |
composer remove --dev javaabu/translatable --no-update
composer update --prefer-dist --no-interaction --no-progress

- name: Execute tests
run: vendor/bin/phpunit --testsuite "Test Suite"

tests:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php: [8.4, 8.5]
laravel: [12.*, 13.*]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 12.*
testbench: 10.*
- laravel: 13.*
testbench: 11.*

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }}

env:
COVERAGE: ${{ matrix.php == '8.4' && matrix.laravel == '13.*' && matrix.stability == 'prefer-stable' }}

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv, gd, exif, fileinfo
coverage: ${{ env.COVERAGE == 'true' && 'pcov' || 'none' }}

- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"

- name: Cache Composer downloads
uses: actions/cache@v6
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-${{ github.job }}-${{ strategy.job-index }}-${{ hashFiles('composer.json', 'composer.lock') }}
restore-keys: |
composer-${{ runner.os }}-${{ github.job }}-${{ strategy.job-index }}-
composer-${{ runner.os }}-${{ github.job }}-

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress

- name: Execute tests
if: env.COVERAGE != 'true'
run: vendor/bin/phpunit

- name: Execute tests with coverage
if: env.COVERAGE == 'true'
run: vendor/bin/phpunit --coverage-clover build/coverage.xml

- name: Upload coverage to Codecov
if: env.COVERAGE == 'true'
uses: codecov/codecov-action@v5
with:
files: build/coverage.xml
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ composer.lock
vendor
coverage
.phpunit.result.cache
.phpunit.cache
.php-cs-fixer.cache
.idea
node_modules
clover.xml
tests/TestSupport/temp
tests/temp
Loading
Loading