diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..93cc554 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,75 @@ +name: CI + +on: + push: + branches: [main, develop] + pull_request: + branches: [main, develop] + +jobs: + pint: + name: Code Style + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 + with: + php-version: "8.5" + extensions: mbstring, xml, ctype, json, bcmath, pdo, pgsql + tools: composer:v2 + coverage: none + - uses: actions/cache@v4 + with: + path: vendor + key: composer-${{ runner.os }}-${{ hashFiles('**/composer.lock') }} + - run: composer install --no-progress --prefer-dist + - run: vendor/bin/pint --test + + test: + name: Tests (${{ matrix.db }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - db: SQLite + connection: sqlite + config: phpunit.xml + - db: PostgreSQL + connection: pgsql + config: phpunit.pgsql.xml + + services: + postgres: + image: postgres:16-alpine + env: + POSTGRES_DB: testing + POSTGRES_USER: root + POSTGRES_PASSWORD: password + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + env: + DB_CONNECTION: ${{ matrix.connection }} + + steps: + - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 + with: + php-version: "8.5" + extensions: mbstring, xml, ctype, json, bcmath, pdo, pgsql, sqlite3 + tools: composer:v2 + coverage: none + - uses: actions/cache@v4 + with: + path: vendor + key: composer-${{ runner.os }}-${{ hashFiles('**/composer.lock') }} + - run: composer install --no-progress --prefer-dist + - run: cp .env.example .env + - run: php artisan key:generate + - run: vendor/bin/pest --configuration=${{ matrix.config }} diff --git a/README.md b/README.md index f86b30c..285355e 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ Sanctum API v1 MIT + CI

diff --git a/phpunit.pgsql.xml b/phpunit.pgsql.xml new file mode 100644 index 0000000..1257788 --- /dev/null +++ b/phpunit.pgsql.xml @@ -0,0 +1,40 @@ + + + + + tests/Unit + + + tests/Feature + + + + + app + + + + + + + + + + + + + + + + + + + + + + +