Skip to content

chore: phpunit with real typesense server #322

chore: phpunit with real typesense server

chore: phpunit with real typesense server #322

name: "coding-standards"
permissions:
checks: write
pull-requests: write
contents: write
on:
pull_request:
branches:
- "*"
push:
branches:
- "main"
jobs:
conventional-commits:
name: "conventional-commits"
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: webiny/[email protected]
coding-standards:
name: "coding-standards"
runs-on: ubuntu-24.04
strategy:
fail-fast: true
matrix:
php-version:
- "8.2"
- "8.3"
- "8.4"
composer-versions:
- highest
include:
- composer-versions: "lowest"
php-version: "8.2"
- composer-versions: "lowest"
php-version: "8.4"
services:
typesense:
image: typesense/typesense:28.0
ports:
- 8108:8108/tcp
volumes:
- /tmp/typesense-server-data:/data
env:
TYPESENSE_DATA_DIR: /data
TYPESENSE_API_KEY: xyz
TYPESENSE_ENABLE_CORS: true
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "xdebug"
php-version: "${{ matrix.php-version }}"
- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v3"
with:
dependency-versions: "${{ matrix.composer-versions }}"
- name: "Run init-db"
run: |
composer run init-db
- name: "Run PHPCS"
run: |
composer run test-phpcs
- name: "Run rector"
run: |
composer run test-rector
- name: "Run phpstan"
run: |
composer run phpstan
- name: "Run phpunit"
run: |
EXIT_STATUS=0
composer run phpunit || EXIT_STATUS=$?
if [ $EXIT_STATUS -eq 1 ] && [ "${{ matrix.composer-versions }}" = "lowest" ]; then
exit 0 # Allow warnings on lowest level
fi
exit $EXIT_STATUS
- name: Get previous coverage from main
if: matrix.composer-versions == 'highest' && matrix.php-version == '8.4' && github.event_name == 'pull_request'
uses: dawidd6/action-download-artifact@v8
continue-on-error: true
with:
workflow: coding-standards.yaml # this file
branch: main
name: coverage-report
path: tests/base
- name: Upload coverage
if: matrix.composer-versions == 'highest' && matrix.php-version == '8.4'
uses: actions/upload-artifact@v4
with:
overwrite: true
name: coverage-report
path: tests/coverage/clover.xml
- name: Upload html-coverage
if: matrix.composer-versions == 'highest' && matrix.php-version == '8.4'
uses: actions/upload-artifact@v4
with:
overwrite: true
name: coverage-report-web
path: tests/coverage/html-coverage/
- name: Coverage Report as Comment (Clover)
uses: lucassabreu/comment-coverage-clover@main
if: github.event_name == 'pull_request' && matrix.composer-versions == 'highest' && matrix.php-version == '8.4'
with:
file: tests/coverage/clover.xml
base-file: tests/base/clover.xml
- name: Coverage as artifact
if: matrix.composer-versions == 'highest' && matrix.php-version == '8.2'
uses: actions/upload-artifact@v4
with:
overwrite: true
name: coverage-report
path: tests/coverage/
documentation:
needs: "coding-standards"
runs-on: "ubuntu-24.04"
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: Download Coverage Artifact
uses: actions/download-artifact@v4
with:
name: coverage-report
path: tests/coverage/
- id: get-user
run: |
echo uid=$(id -u) >> $GITHUB_OUTPUT
echo gid=$(id -g) >> $GITHUB_OUTPUT
- name: Generate doc
uses: addnab/docker-run-action@v3
with:
image: daux/daux.io
options: -w /build -v ${{ github.workspace }}:/build -e EXTERNAL_PERMISSION=${{ steps.get-user.outputs.uid }}:${{ steps.get-user.outputs.gid }}
run: |
cp README.md docs/index.md
daux generate --source=docs --destination=static
chown -R ${EXTERNAL_PERMISSION} static
rm -Rf docs/public && mkdir -p docs/public
mv static/* docs/public/
rm -Rf static
chown -R ${EXTERNAL_PERMISSION} docs/public
- name: Make code coverage badge (done as root)
uses: timkrase/[email protected]
with:
report: tests/coverage/clover.xml
coverage_badge_path: docs/public/badge/coverage.svg
push_badge: false
- name: Docs as artifact
uses: actions/upload-artifact@v4
with:
overwrite: true
name: docs-public
path: docs/public/
- name: Publish doc & badge
uses: peaceiris/actions-gh-pages@v4
if: "${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}"
with:
publish_dir: ./docs/public
publish_branch: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
force_orphan: true
commit_message: "ci(doc): Generated documentation"