Create the network in github action #124
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
name: Tests | |
on: | |
push: | |
pull_request: | |
branches: [ $default-branch ] | |
concurrency: | |
group: ${{ github.workflow }} | |
cancel-in-progress: true | |
jobs: | |
tests: | |
name: Tests | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: pull docker containers | |
run: docker compose pull mysql | |
- name: create docker network | |
run: docker network create my-shared-network | |
- uses: satackey/action-docker-layer-caching@v0.0.11 | |
continue-on-error: true | |
- name: build docker container | |
run: docker compose build | |
- name: PHP dependencies | |
run: docker compose run -u root:root weblingservice composer install | |
- name: env | |
run: cp .env.ci .env | |
- name: laravel key | |
run: docker compose run -u root:root weblingservice php artisan key:generate | |
- name: start containers | |
run: docker compose up -d mysql | |
- name: wait for mysql | |
run: | | |
while ! docker exec -t wsmysql_webling sh -c 'mysql -uroot -p"${MYSQL_ROOT_PASSWORD}" -e quit > /dev/null 2>&1'; do | |
sleep 1 | |
done | |
- name: run migrations | |
run: docker compose run -u root:root weblingservice php artisan migrate | |
- name: install passport | |
run: docker compose run -u root:root weblingservice php artisan passport:install | |
- name: run tests | |
env: | |
WEBLING_API_KEY: ${{ secrets.WEBLING_API_KEY }} | |
WEBLING_FINANCE_ADMIN_API_KEY: ${{ secrets.WEBLING_FINANCE_ADMIN_API_KEY }} | |
WEBLING_BASE_URL: ${{ secrets.WEBLING_BASE_URL }} | |
run: >- | |
docker compose | |
run | |
-u root:root | |
-e WEBLING_API_KEY=${WEBLING_API_KEY} | |
-e WEBLING_FINANCE_ADMIN_API_KEY=${WEBLING_FINANCE_ADMIN_API_KEY} | |
-e WEBLING_BASE_URL=${WEBLING_BASE_URL} | |
weblingservice | |
php | |
-dxdebug.mode=coverage | |
/var/www/html/vendor/phpunit/phpunit/phpunit | |
--configuration /var/www/html/phpunit.xml | |
--coverage-clover /var/www/html/build/logs/clover.xml | |
- name: Show logs if tests failed | |
if: ${{ failure() }} | |
run: cat storage/logs/laravel*.log | |
- name: publish coverage report | |
if: ${{ success() }} | |
env: | |
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: >- | |
docker-compose | |
run | |
-u root:root | |
-e GITHUB_REF=${GITHUB_REF} | |
-e GITHUB_ACTIONS=${GITHUB_ACTIONS} | |
-e GITHUB_RUN_ID=${GITHUB_RUN_ID} | |
-e GITHUB_EVENT_NAME=${GITHUB_EVENT_NAME} | |
-e COVERALLS_REPO_TOKEN=${COVERALLS_REPO_TOKEN} | |
weblingservice | |
sh | |
-c | |
'git config --global --add safe.directory /var/www/html | |
&& curl -L https://github.com/php-coveralls/php-coveralls/releases/download/v2.5.2/php-coveralls.phar > /tmp/php-coveralls | |
&& chmod u+x /tmp/php-coveralls | |
&& /tmp/php-coveralls --coverage_clover=/var/www/html/build/logs/clover.xml -v' |