2019-10-10 17:47:17 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# GitHub Action for Symfony with PostgreSQL
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-08 18:12:54 +05:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								name: Testing Symfony with PostgreSQL
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								on: [push, pull_request]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								jobs:
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-10 17:47:17 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  symfony:
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-08 18:12:54 +05:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    name: Symfony (PHP ${{ matrix.php-versions }})
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    runs-on: ubuntu-latest
							 | 
						
					
						
							
								
									
										
										
										
											2022-04-03 04:24:07 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    # Docs: https://docs.github.com/en/actions/using-containerized-services
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-08 18:12:54 +05:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    services:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      postgres:
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-15 16:49:10 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        image: postgres:latest
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-08 18:12:54 +05:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        env:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          POSTGRES_USER: postgres
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          POSTGRES_PASSWORD: postgres
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          POSTGRES_DB: postgres
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        ports:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          - 5432/tcp
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    strategy:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      fail-fast: false
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      matrix:
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-15 16:49:10 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        php-versions: ['7.4', '8.0', '8.1']
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-08 18:12:54 +05:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    steps:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      - name: Checkout
							 | 
						
					
						
							
								
									
										
										
										
											2025-10-12 11:05:16 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        uses: actions/checkout@v5
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-15 16:49:10 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      # Docs: https://github.com/shivammathur/setup-php
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      - name: Setup PHP
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        uses: shivammathur/setup-php@v2
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-08 18:12:54 +05:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        with:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          php-version: ${{ matrix.php-versions }}
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-17 11:49:03 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          tools: phpunit-bridge
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-28 02:18:01 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, pgsql
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-15 16:49:10 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          coverage: xdebug
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-04-03 04:24:07 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      # Local PostgreSQL service in GitHub hosted environments is disabled by default.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      # If you are using it instead of service containers, make sure you start it.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      # - name: Start postgresql service
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      #   run: sudo systemctl start postgresql.service
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-11-27 06:00:34 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      - name: Get composer cache directory
							 | 
						
					
						
							
								
									
										
										
										
											2020-11-12 18:26:26 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        id: composer-cache
							 | 
						
					
						
							
								
									
										
										
										
											2022-10-12 16:26:11 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-15 16:49:10 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-11-27 06:00:34 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      - name: Cache composer dependencies
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-21 15:40:20 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        uses: actions/cache@v3
							 | 
						
					
						
							
								
									
										
										
										
											2019-11-27 06:00:34 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        with:
							 | 
						
					
						
							
								
									
										
										
										
											2020-11-12 18:26:26 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          path: ${{ steps.composer-cache.outputs.dir }}
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-28 00:23:51 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          # Use composer.json for key, if composer.lock is not committed.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
							 | 
						
					
						
							
								
									
										
										
										
											2019-11-27 06:00:34 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          restore-keys: ${{ runner.os }}-composer-
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-15 16:49:10 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-08 18:12:54 +05:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      - name: Install Composer dependencies
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-17 11:49:03 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        run: composer install --no-progress --prefer-dist --optimize-autoloader
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-15 16:49:10 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-08 18:12:54 +05:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      - name: Run Migration
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        run: |
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-17 11:49:03 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          composer require --dev symfony/orm-pack
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-08 18:12:54 +05:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          php bin/console doctrine:schema:update --force || echo "No migrations found or schema update failed"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          php bin/console doctrine:migrations:migrate || echo "No migrations found or migration failed"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        env:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          DATABASE_URL: postgres://postgres:postgres@127.0.0.1:${{ job.services.postgres.ports[5432] }}/postgres?charset=UTF-8
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-15 16:49:10 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-17 11:49:03 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      - name: Install PHPUnit
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        run: simple-phpunit install
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-15 16:49:10 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-17 11:49:03 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      - name: Run tests
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        run: simple-phpunit --coverage-text
							 |