2024-01-24 18:43:17 +00:00
|
|
|
name: "Tests"
|
|
|
|
on:
|
2024-01-25 17:42:40 +00:00
|
|
|
workflow_dispatch: {}
|
2024-01-24 18:43:17 +00:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
2024-01-25 17:42:40 +00:00
|
|
|
|
2024-01-24 18:43:17 +00:00
|
|
|
pull_request: {}
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
tests:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
name: PHP v8.1 with MongoDB 6.0
|
|
|
|
concurrency: "ci-${{ github.ref }}"
|
|
|
|
env:
|
2024-01-25 17:42:40 +00:00
|
|
|
extensions: curl,intl,mbstring,mongodb-stable,redis,opcache,sockets,pcntl,xdebug
|
2024-01-24 18:43:17 +00:00
|
|
|
key: jikan-rest-ci-cache-v1
|
|
|
|
phpversion: 8.1
|
|
|
|
services:
|
|
|
|
mongodb:
|
|
|
|
image: mongo:6
|
|
|
|
ports:
|
|
|
|
- 27017:27017
|
|
|
|
env:
|
|
|
|
MONGO_INITDB_DATABASE: jikan_test
|
|
|
|
typesense:
|
|
|
|
image: typesense/typesense:0.24.1
|
|
|
|
ports:
|
|
|
|
- 8108:8108
|
2024-01-25 23:39:12 +00:00
|
|
|
volumes:
|
|
|
|
- typesense-data:/data
|
2024-01-24 18:43:17 +00:00
|
|
|
env:
|
|
|
|
TYPESENSE_API_KEY: jikan_testing
|
2024-01-25 23:39:12 +00:00
|
|
|
TYPESENSE_DATA_DIR: /data
|
2024-01-24 18:43:17 +00:00
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v4
|
2024-01-25 17:42:40 +00:00
|
|
|
|
2024-01-24 18:43:17 +00:00
|
|
|
- name: Show MongoDB server status
|
|
|
|
run: |
|
2024-01-26 00:09:02 +00:00
|
|
|
docker run --rm --network host mongo:6 mongosh localhost:27017 --eval "db.runCommand({ serverStatus: 1 })"
|
2024-01-25 17:42:40 +00:00
|
|
|
|
2024-01-26 00:15:59 +00:00
|
|
|
- name: Show Typesense server status
|
2024-01-26 00:19:19 +00:00
|
|
|
run: curl --connect-timeout 5 --max-time 10 --retry 5 --retry-delay 1 --retry-max-time 5 -s -f http://localhost:8108/health
|
2024-01-26 00:15:59 +00:00
|
|
|
|
2024-01-24 18:43:17 +00:00
|
|
|
- name: Setup extension cache
|
|
|
|
id: extcache
|
|
|
|
uses: shivammathur/cache-extensions@v1
|
|
|
|
with:
|
|
|
|
php-version: ${{ env.phpversion }}
|
|
|
|
extensions: ${{ env.extensions }}
|
|
|
|
key: ${{ env.key }}
|
|
|
|
|
|
|
|
- name: Cache extensions
|
|
|
|
uses: actions/cache@v4
|
|
|
|
with:
|
|
|
|
path: ${{ steps.extcache.outputs.dir }}
|
|
|
|
key: ${{ steps.extcache.outputs.key }}
|
|
|
|
restore-keys: ${{ steps.extcache.outputs.key }}
|
2024-01-25 17:42:40 +00:00
|
|
|
|
2024-01-24 18:43:17 +00:00
|
|
|
- name: Setup PHP
|
|
|
|
uses: shivammathur/setup-php@v2
|
|
|
|
with:
|
|
|
|
php-version: ${{ env.phpversion }}
|
|
|
|
extensions: ${{ env.extensions }}
|
2024-01-25 17:42:40 +00:00
|
|
|
coverage: xdebug
|
|
|
|
tools: composer
|
|
|
|
|
2024-01-24 18:43:17 +00:00
|
|
|
- name: Setup dependency cache
|
|
|
|
id: composercache
|
|
|
|
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
|
|
|
|
|
|
|
- name: Cache composer dependencies
|
|
|
|
uses: actions/cache@v4
|
|
|
|
with:
|
|
|
|
path: ${{ steps.composercache.outputs.dir }}
|
|
|
|
key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}"
|
|
|
|
restore-keys: "${{ runner.os }}-composer-"
|
2024-01-25 17:42:40 +00:00
|
|
|
|
2024-01-24 18:43:17 +00:00
|
|
|
- name: Install dependencies
|
|
|
|
run: composer install --no-interaction --no-progress --no-suggest --no-scripts
|
|
|
|
|
|
|
|
- name: Run tests
|
|
|
|
env:
|
|
|
|
CI_ENV: true
|
|
|
|
APP_ENV: testing
|
|
|
|
APP_DEBUG: "true"
|
|
|
|
APP_KEY: "base64:em9ycm8="
|
|
|
|
APP_TIMEZONE: UTC
|
|
|
|
APP_URL: http://localhost:8080
|
|
|
|
LOG_CHANNEL: stack
|
|
|
|
LOG_LEVEL: debug
|
|
|
|
DB_HOST: localhost
|
|
|
|
DB_PORT: 27017
|
|
|
|
MAX_RESULTS_PER_PAGE: 25
|
|
|
|
TYPESENSE_API_KEY: jikan_testing
|
|
|
|
TYPESENSE_HOST: localhost
|
|
|
|
TYPESENSE_PORT: 8108
|
|
|
|
SCOUT_DRIVER: typesense
|
|
|
|
SCOUT_QUEUE: "false"
|
|
|
|
MICROCACHING: "false"
|
|
|
|
CACHING: "false"
|
|
|
|
CACHE_DRIVER: array
|
|
|
|
CACHE_DEFAULT_EXPIRE: 86400
|
|
|
|
CACHE_META_EXPIRE: 300
|
|
|
|
CACHE_USER_EXPIRE: 300
|
|
|
|
CACHE_USERLIST_EXPIRE: 3600
|
|
|
|
CACHE_404_EXPIRE: 604800
|
|
|
|
CACHE_SEARCH_EXPIRE: 432000
|
|
|
|
CACHE_PRODUCERS_EXPIRE: 432000
|
|
|
|
CACHE_MAGAZINES_EXPIRE: 432000
|
|
|
|
CACHE_MICROCACHE_EXPIRE: 60
|
|
|
|
GITHUB_REPORTING: "false"
|
|
|
|
REPORTING: "false"
|
|
|
|
|
|
|
|
run: ./vendor/bin/phpunit --coverage-clover coverage.xml
|
2024-01-25 23:27:32 +00:00
|
|
|
|
2024-01-31 19:19:20 +00:00
|
|
|
- name: Show logs after test failure
|
|
|
|
if: failure()
|
|
|
|
run: find ./storage/logs/daily/*.log | head -n 1 | xargs cat
|
|
|
|
|
2024-01-25 23:27:32 +00:00
|
|
|
- name: Upload coverage reports
|
2024-02-01 13:56:57 +00:00
|
|
|
uses: codecov/codecov-action@v4
|
2024-01-25 23:27:32 +00:00
|
|
|
with:
|
|
|
|
files: coverage.xml
|
|
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|