Improve dev/prod separation #813
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
name: Tests | |
on: [push,pull_request] | |
permissions: | |
contents: read | |
issues: write | |
pull-requests: write | |
jobs: | |
biblioteca-tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Prepare env | |
run: | | |
php -r "file_exists('.env.test.local') || copy('.env.test', '.env.test.local');" | |
touch .env.local && echo "APP_ENV=test" >> .env.local | |
docker network create pontsun | |
mkdir -p vendor var node_modules public/build public/books public/covers public/media | |
chmod -R 777 . | |
- name: Install Docker Compose | |
uses: ndeloof/[email protected] | |
- name: Run docker-compose up | |
run: docker compose -f docker-compose.yml -f docker-compose.test.yml up -d --build | |
- name: Install Composer Dependencies | |
run: docker compose exec biblioteca composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist | |
- name: Install NPM Dependencies | |
run: docker compose exec biblioteca npm i | |
- name: Build npm | |
run: docker compose exec biblioteca npm run build | |
- name: Prepare Database | |
run: | | |
docker compose exec biblioteca bin/console doctrine:database:create --env=test -n | |
docker compose exec biblioteca bin/console doctrine:migrations:migrate --env=test -n | |
docker compose exec biblioteca bin/console doctrine:fixtures:load --env=test --append -n | |
docker compose exec biblioteca bin/console biblioverse:typesense:populate --env=test | |
- name: Valide schema | |
run: docker compose exec biblioteca bin/console doctrine:schema:validate --env=test | |
- name: Execute tests | |
run: docker compose exec biblioteca composer test | |
- if: ${{ github.event_name == 'pull_request' }} | |
name: Download previous coverage | |
uses: dawidd6/action-download-artifact@v8 | |
continue-on-error: true | |
with: | |
workflow: tests.yml # this file | |
branch: main | |
name: coverage-report | |
path: tests/base | |
- if: ${{ github.event_name != 'pull_request' }} | |
name: Upload coverage | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-report | |
path: coverage.xml | |
- name: Coverage Report as Comment | |
uses: lucassabreu/comment-coverage-clover@main | |
if: ${{ github.event_name == 'pull_request' }} | |
with: | |
file: coverage.xml | |
base-file: tests/base/coverage.xml | |
show-percentage-change-on-table: true | |
with-chart: false | |
with-branches: false | |
dir-prefix: '/var/www/html/' | |
table-below-coverage: 95 | |
icon-decreased: ":small_red_triangle_down:" | |
icon-increased: ":green_heart:" | |
- name: Run docker-compose down | |
run: docker compose down |