setup database before running tests #12
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: Run tests | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
TEST_DB_NAME: cafe_test | |
DB_USER: root # do not change | |
DB_PASSWORD: root # do not change | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup database | |
run: | | |
sudo /etc/init.d/mysql start | |
mysql -e "CREATE DATABASE IF NOT EXISTS $TEST_DB_NAME;" -u$DB_USER -p$DB_PASSWORD | |
mysql -D$TEST_DB_NAME -u$DB_USER -p$DB_PASSWORD -hlocalhost -P3306 < "resources/database/dump/cafe.sql" | |
- name: Create .env file | |
env: | |
ENV: | | |
PUBLIC_ROOT="http://localhost/steamy-sips/public" | |
DB_HOST="localhost" | |
DB_USERNAME="root" | |
DB_PASSWORD="root" | |
TEST_DB_NAME="cafe_test" | |
BUSINESS_GMAIL="" | |
BUSINESS_GMAIL_PASSWORD="" | |
run: echo "$ENV" > src/core/.env | |
- name: Validate composer.json and composer.lock | |
run: composer validate --strict | |
- name: Cache Composer packages | |
id: composer-cache | |
uses: actions/cache@v4 | |
with: | |
path: vendor | |
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-php- | |
- name: Install Composer dependencies | |
run: composer install --prefer-dist --no-progress | |
- name: Run test suite | |
run: composer test |