-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Carl Borgas
committed
Aug 25, 2023
1 parent
d9d397a
commit 6858292
Showing
4 changed files
with
40 additions
and
47 deletions.
There are no files selected for viewing
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,4 @@ | ||
APP_ENV=test | ||
APP_SECRET=71efaefeaba2aad666e29cbe1166d172 | ||
DATABASE_VERSION=15 | ||
DATABASE_NAME=books_test | ||
DATABASE_USER=main | ||
DATABASE_PASSWORD=main | ||
DATABASE_HOST=postgres | ||
DATABASE_PORT=5432 | ||
DATABASE_URL=postgresql://main:main@postgres:5432/books_test |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
name: Build and test | ||
name: Test | ||
|
||
on: [push] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
runs-on: ubuntu-20.04 | ||
|
||
services: | ||
postgres: | ||
|
@@ -14,41 +14,46 @@ jobs: | |
POSTGRES_USER: main | ||
POSTGRES_DB: books,books_test | ||
ports: | ||
- 5432:5432 | ||
- 5432/tcp | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Build Docker image | ||
run: docker build -t books-api-image -f Dockerfile . | ||
|
||
- name: Run Docker container | ||
run: | | ||
NETWORK_NAME=$(docker network ls -q) \ | ||
docker run -d \ | ||
--name books-api \ | ||
-v $PWD:/var/www/books \ | ||
-e APP_ENV=test \ | ||
-p 8000:8000 \ | ||
books-api-image \ | ||
symfony server:start --no-tls --port=8000 --dir=/var/www/books | ||
- name: Install Composer dependencies | ||
run: docker exec books-api composer install | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup test dependencies | ||
run: docker exec books-api composer build:test | ||
|
||
- name: Run tests | ||
run: docker exec books-api composer test | ||
|
||
- name: Stop and remove Docker container | ||
run: | | ||
docker stop books-api | ||
docker rm books-api | ||
- name: Setup PHP with PECL extension | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '8.2' | ||
extensions: pgsql | ||
coverage: xdebug | ||
|
||
- name: Get composer cache directory | ||
id: composer-cache | ||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
|
||
- name: Cache composer dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
|
||
- name: Install Composer dependencies | ||
run: composer install --prefer-dist --optimize-autoloader | ||
|
||
- name: Setup test dependencies | ||
run: composer build:test | ||
env: | ||
APP_ENV: test | ||
DATABASE_URL: postgres://main:[email protected]:5432/books_test | ||
|
||
- name: Run tests | ||
run: composer test | ||
env: | ||
APP_ENV: test | ||
DATABASE_URL: postgres://main:[email protected]:5432/books_test |
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