Skip to content

#7 - Activity history #44

#7 - Activity history

#7 - Activity history #44

name: Test & lint PHP codebase
on:
pull_request:
branches: [ "main" ]
types: [opened, synchronize, reopened, ready_for_review]
paths:
- '**.php'
- 'composer.json'
- 'composer.lock'
- 'phpunit.xml.ci'
- '.env.ci'
jobs:
test-and-lint-php:
name: Test & lint PHP codebase
timeout-minutes: 10
if: github.event.pull_request.draft == false
runs-on: ubuntu-24.04
env:
# renovate: datasource=github-releases depName=php packageName=containerbase/php-prebuild
PHP_VERSION: 8.4.10
services:
pgsql:
image: postgres:16.3-alpine3.18@sha256:64e18e8fb3e9c9aac89ac590c5dd8306b862478404f76cd9b5f7720d012b4c47 # https://hub.docker.com/_/postgres
env:
POSTGRES_DB: MiniStravaAPI
POSTGRES_USER: MiniStravaAPI
POSTGRES_PASSWORD: password
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 3s
--health-timeout 3s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 # https://github.com/actions/checkout
- name: Validate composer.json and composer.lock
run: composer validate
- name: Cache dependencies
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 # https://github.com/actions/cache
with:
path: vendor
key: ${{ runner.os }}-composer-dependencies-${{ hashFiles('composer.lock') }}
restore-keys: ${{ runner.os }}-composer-dependencies
- name: Setup PHP
uses: shivammathur/setup-php@0f7f1d08e3e32076e51cae65eb0b0c871405b16e # 2.34.1 # https://github.com/shivammathur/setup-php
with:
php-version: ${{ env.PHP_VERSION }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_pgsql, intl
coverage: none
- name: Install Composer dependencies
run: composer install --prefer-dist --no-interaction
- name: Run PHP linter
run: composer cs
- name: Execute tests
run: |
cp .env.ci .env
vendor/bin/phpunit -c phpunit.xml.ci --colors=always