1+ name : PHP 8.5
2+
3+ on :
4+ push :
5+ branches : [ main, dev ]
6+ pull_request :
7+ branches : [ main ]
8+
9+ concurrency :
10+ group : ${{ github.workflow }}-${{ github.ref }}
11+ cancel-in-progress : true
12+
13+ jobs :
14+ test :
15+ runs-on : ubuntu-latest
16+ timeout-minutes : 10
17+
18+ env :
19+ SA_SQL_SERVER_PASSWORD : ${{ secrets.SA_SQL_SERVER_PASSWORD }}
20+ MYSQL_ROOT_PASSWORD : ${{ secrets.MYSQL_ROOT_PASSWORD }}
21+
22+ services :
23+ sqlserver :
24+ image : mcr.microsoft.com/mssql/server:2019-latest
25+ env :
26+ SA_PASSWORD : ${{ secrets.SA_SQL_SERVER_PASSWORD }}
27+ ACCEPT_EULA : Y
28+ MSSQL_PID : Express
29+ ports :
30+ - " 1433:1433"
31+ mysql :
32+ image : mysql:8.0
33+ env :
34+ MYSQL_ROOT_PASSWORD : ${{ secrets.MYSQL_ROOT_PASSWORD }}
35+ MYSQL_DATABASE : testing_db
36+ MYSQL_ROOT_HOST : ' %'
37+ ports :
38+ - 3306:3306
39+ options : --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
40+ strategy :
41+ fail-fast : true
42+
43+ name : Run PHPUnit Tests
44+
45+ steps :
46+ - name : Clone Repo
47+ uses : actions/checkout@v4
48+
49+ - name : Setup PHP
50+ uses : shivammathur/setup-php@v2
51+ with :
52+ php-version : 8.5
53+ extensions : mysqli, mbstring, sqlsrv
54+ tools : phpunit:12.5.4, composer
55+
56+ - name : Install ODBC Driver for SQL Server
57+ run : |
58+ curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc
59+ curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
60+ sudo apt update
61+ sudo ACCEPT_EULA=Y apt install mssql-tools18 unixodbc-dev msodbcsql18
62+
63+ - name : Wait for SQL Server
64+ run : |
65+ for i in {1..12}; do
66+ if /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P '${{ secrets.SA_SQL_SERVER_PASSWORD }}' -Q 'SELECT 1' -C > /dev/null 2>&1; then
67+ echo "SQL Server is ready"
68+ break
69+ fi
70+ echo "Waiting for SQL Server... ($i/12)"
71+ sleep 10
72+ done
73+
74+ - name : Create SQL Server Database
75+ run : /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P '${{ secrets.SA_SQL_SERVER_PASSWORD }}' -Q 'create database testing_db' -C
76+
77+ - name : Setup MySQL Client
78+ run : |
79+ sudo apt update
80+ sudo apt install mysql-client-core-8.0
81+
82+ - name : Wait for MySQL
83+ run : |
84+ until mysqladmin ping -h 127.0.0.1 --silent; do
85+ echo 'waiting for mysql...'
86+ sleep 1
87+ done
88+
89+ - name : Create MySQL Database
90+ run : |
91+ mysql -h 127.0.0.1 -u root -p${{ secrets.MYSQL_ROOT_PASSWORD }} -e "CREATE DATABASE IF NOT EXISTS testing_db;"
92+
93+ - name : Install Dependencies
94+ run : composer install --prefer-source --no-interaction
95+
96+ - name : Execute Tests
97+ run : phpunit --configuration=tests/phpunit10.xml --coverage-clover=clover.xml
98+
99+ - name : Rename coverage report
100+ run : |
101+ mv clover.xml php-8.5-coverage.xml
102+
103+ - name : Upload Coverage Report
104+ uses : actions/upload-artifact@v4
105+ with :
106+ name : code-coverage
107+ path : php-8.5-coverage.xml
108+
109+
110+ code-coverage :
111+ name : Coverage
112+ needs : test
113+ uses : WebFiori/workflows/.github/workflows/coverage-codecov.yaml@v1.2.1
114+ with :
115+ php-version : ' 8.5'
116+ coverage-file : ' php-8.5-coverage.xml'
117+ secrets :
118+ CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
119+
120+ code-quality :
121+ name : Code Quality
122+ needs : test
123+ uses : WebFiori/workflows/.github/workflows/quality-sonarcloud.yaml@v1.2.1
124+ secrets :
125+ SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
126+
127+ release-prod :
128+ name : Prepare Production Release Branch / Publish Release
129+ needs : [code-coverage, code-quality]
130+ uses : WebFiori/workflows/.github/workflows/release-php.yaml@v1.2.1
131+ with :
132+ branch : ' main'
0 commit comments