Skip to content

CI

CI #1068

Workflow file for this run

name: CI
on:
push:
branches:
- main
- '[0-9]+.[0-9]+'
pull_request: ~
workflow_dispatch:
inputs:
send-success-notification:
description: "Send a Slack notification when the build passes"
default: true
required: false
type: boolean
jobs:
cs-fix:
name: Run code style check
runs-on: "ubuntu-24.04"
strategy:
matrix:
php:
- '8.3'
steps:
- uses: actions/checkout@v6
- uses: ibexa/gh-workflows/actions/setup-composer-root-version@main
- uses: ibexa/gh-workflows/actions/composer-install@main
with:
gh-client-id: ${{ secrets.AUTOMATION_CLIENT_ID }}
gh-client-secret: ${{ secrets.AUTOMATION_CLIENT_SECRET }}
satis-network-key: ${{ secrets.SATIS_NETWORK_KEY }}
satis-network-token: ${{ secrets.SATIS_NETWORK_TOKEN }}
- name: Run code style check
run: composer run-script check-cs -- --format=checkstyle | cs2pr
rector:
name: Run rector
runs-on: "ubuntu-22.04"
strategy:
matrix:
php:
- '8.3'
steps:
- uses: actions/checkout@v4
- name: Setup PHP Action
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
extensions: 'pdo_sqlite, gd'
tools: cs2pr
- uses: actions/checkout@v6
- uses: ibexa/gh-workflows/actions/composer-install@main
with:
gh-client-id: ${{ secrets.AUTOMATION_CLIENT_ID }}
gh-client-secret: ${{ secrets.AUTOMATION_CLIENT_SECRET }}
satis-network-key: ${{ secrets.SATIS_NETWORK_KEY }}
satis-network-token: ${{ secrets.SATIS_NETWORK_TOKEN }}
- name: Run rector
run: vendor/bin/rector process --dry-run --ansi
tests:
name: Tests
runs-on: "ubuntu-24.04"
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
php:
- '8.3'
- '8.4'
steps:
- uses: actions/checkout@v6
- uses: ibexa/gh-workflows/actions/setup-composer-root-version@main
- uses: ibexa/gh-workflows/actions/composer-install@main
with:
gh-client-id: ${{ secrets.AUTOMATION_CLIENT_ID }}
gh-client-secret: ${{ secrets.AUTOMATION_CLIENT_SECRET }}
satis-network-key: ${{ secrets.SATIS_NETWORK_KEY }}
satis-network-token: ${{ secrets.SATIS_NETWORK_TOKEN }}
- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Run test suite
run: composer run-script --timeout=600 test-unit
- name: Run PHPStan analysis
run: composer run-script phpstan
integration-tests-postgres:
name: PostgreSQL integration tests
needs: tests
services:
postgres:
image: postgres:10
ports:
- 5432
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: testdb
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--tmpfs /var/lib/postgresql/data
runs-on: "ubuntu-24.04"
timeout-minutes: 20
strategy:
matrix:
php:
- '8.3'
- '8.4'
steps:
- uses: actions/checkout@v6
- uses: ibexa/gh-workflows/actions/setup-composer-root-version@main
- uses: ibexa/gh-workflows/actions/composer-install@main
with:
gh-client-id: ${{ secrets.AUTOMATION_CLIENT_ID }}
gh-client-secret: ${{ secrets.AUTOMATION_CLIENT_SECRET }}
satis-network-key: ${{ secrets.SATIS_NETWORK_KEY }}
satis-network-token: ${{ secrets.SATIS_NETWORK_TOKEN }}
- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Run integration test suite on Postgres
run: composer run-script --timeout=600 test-integration
env:
SEARCH_ENGINE: legacy
DATABASE_URL: "pgsql://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/testdb?server_version=10"
integration-tests-mysql:
name: MySQL integration tests
needs: tests
services:
mysql:
image: ghcr.io/ibexa/core/mysql
ports:
- 3306/tcp
env:
MYSQL_RANDOM_ROOT_PASSWORD: true
MYSQL_USER: mysql
MYSQL_PASSWORD: mysql
MYSQL_DATABASE: testdb
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=5
--tmpfs=/var/lib/mysql
runs-on: "ubuntu-24.04"
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
php:
- '8.3'
- '8.4'
steps:
- uses: actions/checkout@v6
- uses: ibexa/gh-workflows/actions/setup-composer-root-version@main
- uses: ibexa/gh-workflows/actions/composer-install@main
with:
gh-client-id: ${{ secrets.AUTOMATION_CLIENT_ID }}
gh-client-secret: ${{ secrets.AUTOMATION_CLIENT_SECRET }}
satis-network-key: ${{ secrets.SATIS_NETWORK_KEY }}
satis-network-token: ${{ secrets.SATIS_NETWORK_TOKEN }}
- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Run integration test suite vs MySQL
run: composer run-script --timeout=600 test-integration
env:
SEARCH_ENGINE: legacy
DATABASE_URL: "mysql://mysql:mysql@127.0.0.1:${{ job.services.mysql.ports[3306] }}/testdb"
notify-slack:
name: Notify Slack
needs: [cs-fix, tests, integration-tests-postgres, integration-tests-mysql]
if: always() && github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Determine overall result
id: result
run: |
if ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}; then
echo "state=failure" >> "$GITHUB_OUTPUT"
echo "emoji=❌" >> "$GITHUB_OUTPUT"
else
echo "state=success" >> "$GITHUB_OUTPUT"
echo "emoji=✅" >> "$GITHUB_OUTPUT"
fi
- name: Build Slack payload
if: steps.result.outputs.state == 'failure' || inputs.send-success-notification
run: >
echo "SLACK_PAYLOAD=
{\"blocks\": [{\"type\": \"section\",\"text\": {\"type\": \"mrkdwn\",\"text\": \"
${{ steps.result.outputs.emoji }} Backend CI *$GITHUB_REPOSITORY*:*$GITHUB_REF_NAME* ($GITHUB_ACTOR) |
<$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID|Details>
\"}}]}" >> $GITHUB_ENV
- name: Send Slack notification
if: steps.result.outputs.state == 'failure' || inputs.send-success-notification
uses: slackapi/slack-github-action@45a88b9581bfab2566dc881e2cd66d334e621e2c # v3.0.3
with:
webhook: ${{ secrets.SLACK_PHP_BACKEND_CI_WEBHOOK_URL }}
webhook-type: incoming-webhook
payload: ${{ env.SLACK_PAYLOAD }}