-
Notifications
You must be signed in to change notification settings - Fork 506
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3940 from ushahidi/github-actions-test
ci(github): run tests on github actions
- Loading branch information
Showing
1 changed file
with
85 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
name: Test | ||
|
||
on: | ||
- push | ||
- pull_request | ||
|
||
env: | ||
MYSQL_ROOT_PASSWORD: root | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
|
||
strategy: | ||
matrix: | ||
php_version: | ||
- 7.2 | ||
- 7.3 | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@master | ||
with: | ||
php-version: ${{ matrix.php_version }} | ||
|
||
- name: Get Composer Cache Directory | ||
id: composer-cache | ||
run: | | ||
echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
- uses: actions/cache@v1 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-composer- | ||
- name: Setup environment | ||
run: | | ||
set -e; | ||
cp .env.testing .env ; | ||
. .env ; | ||
. docker/common.sh ; | ||
wait_for_mysql ; | ||
cat > $HOME/.my.cnf <<EOF | ||
[client] | ||
host=${DB_HOST} | ||
port=${DB_PORT} | ||
database=mysql | ||
user=root | ||
password=${MYSQL_ROOT_PASSWORD} | ||
EOF | ||
mysql -e "SELECT version();" ; | ||
mysql -e "SET GLOBAL sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'" ; | ||
composer install --no-interaction ; | ||
- name: Run tests | ||
run: | | ||
set -e; | ||
composer pre-test; | ||
mysql -e 'SET @@GLOBAL.wait_timeout=1800'; | ||
( cd httpdocs/; php -S localhost:8000 -t . index.php &) | ||
composer test ; | ||
services: | ||
mysql: | ||
image: mysql:5.7 | ||
env: | ||
MYSQL_DATABASE: ushahidi | ||
MYSQL_USER: ushahidi | ||
MYSQL_PASSWORD: ushahidi | ||
MYSQL_ROOT_PASSWORD: ${{ env.MYSQL_ROOT_PASSWORD }} | ||
ports: | ||
- 3306:3306 | ||
options: --health-cmd "mysqladmin ping -h localhost" | ||
--health-interval 10s --health-timeout 5s | ||
--health-retries 60 | ||
|