Skip to content

Commit 6e8df8e

Browse files
committed
minor #701 Enhancement: Use GithubActions for tests instead of Travis + PHP 8.0 tests (OskarStark, weaverryan)
This PR was merged into the 1.0-dev branch. Discussion ---------- Enhancement: Use GithubActions for tests instead of Travis + PHP 8.0 tests Commits ------- 32c471b using dev for php 8 7742a57 Enhancement: Rename ENV var 50110aa Enhancement: Use GithubActions for tests instead of Travis
2 parents 5e955fe + 32c471b commit 6e8df8e

File tree

4 files changed

+102
-44
lines changed

4 files changed

+102
-44
lines changed

.github/workflows/ci.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88

99
env:
1010
fail-fast: true
11+
PHPUNIT_FLAGS: "-v"
12+
SYMFONY_PHPUNIT_DIR: "$HOME/symfony-bridge/.phpunit"
13+
SYMFONY_REQUIRE: ">=3.4"
1114

1215
jobs:
1316
coding-standards:
@@ -56,3 +59,97 @@ jobs:
5659
-
5760
name: "Run friendsofphp/php-cs-fixer"
5861
run: "vendor/bin/php-cs-fixer fix --dry-run --diff"
62+
63+
test:
64+
name: "PHP ${{ matrix.php-version }} + symfony/skeleton@${{ matrix.symfony-skeleton-stability }}"
65+
66+
runs-on: ubuntu-latest
67+
68+
services:
69+
mysql:
70+
image: mysql:5.7
71+
env:
72+
MYSQL_ROOT_PASSWORD: root
73+
MYSQL_DATABASE: test_maker
74+
ports:
75+
- 3306
76+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
77+
78+
continue-on-error: ${{ matrix.allow-failures }}
79+
80+
env:
81+
SYMFONY_SKELETON_STABILITY: ${{ matrix.symfony-skeleton-stability }}
82+
83+
strategy:
84+
matrix:
85+
php-version:
86+
- '7.1.33'
87+
- '7.2.5'
88+
- '7.3'
89+
- '7.4'
90+
symfony-skeleton-stability:
91+
- 'stable'
92+
allow-failures: [false]
93+
include:
94+
- php-version: '7.4'
95+
symfony-skeleton-stability: 'dev'
96+
allow-failures: true
97+
- php-version: '8.0'
98+
symfony-skeleton-stability: 'dev'
99+
allow-failures: true
100+
101+
steps:
102+
- name: "Checkout code"
103+
uses: actions/[email protected]
104+
105+
- name: "Start MySQL"
106+
run: |
107+
sudo /etc/init.d/mysql start
108+
109+
- name: "Verify MySQL connection from host"
110+
run: |
111+
sudo apt-get install -y mysql-client
112+
mysql --host 127.0.0.1 --port 3306 -uroot -proot -e "SHOW DATABASES;"
113+
114+
- name: "Setup Database"
115+
run: |
116+
mysql --host 127.0.0.1 --port 3306 -uroot -proot -e "CREATE DATABASE IF NOT EXISTS test_maker;"
117+
118+
- name: "Install PHP with extensions"
119+
uses: shivammathur/[email protected]
120+
with:
121+
coverage: "none"
122+
php-version: ${{ matrix.php-version }}
123+
tools: composer:v2
124+
125+
- name: "Add PHPUnit matcher"
126+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
127+
128+
- name: "Set composer cache directory"
129+
id: composer-cache
130+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
131+
132+
- name: "Cache composer"
133+
uses: actions/[email protected]
134+
with:
135+
path: ${{ steps.composer-cache.outputs.dir }}
136+
key: ${{ runner.os }}-${{ matrix.php-version }}-composer-${{ hashFiles('composer.json') }}-symfony-skeleton-stability-${{ matrix.symfony-skeleton-stability }}-allow-failures-${{ matrix.allow-failures }}
137+
restore-keys: ${{ runner.os }}-${{ matrix.php-version }}-composer-
138+
139+
- name: "Require symfony/flex"
140+
run: composer global require --no-progress --no-scripts --no-plugins symfony/flex dev-main
141+
142+
- if: matrix.php-version != '8.0'
143+
run: composer update
144+
145+
- if: matrix.php-version == '8.0'
146+
run: composer update --ignore-platform-reqs
147+
148+
- name: "Install PHPUnit"
149+
run: vendor/bin/simple-phpunit install
150+
151+
- name: "PHPUnit version"
152+
run: vendor/bin/simple-phpunit --version
153+
154+
- name: "Run tests"
155+
run: vendor/bin/simple-phpunit ${{ env.PHPUNIT_FLAGS }}

.travis.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
>
1212
<php>
1313
<ini name="error_reporting" value="-1" />
14-
<env name="TEST_DATABASE_DSN" value="mysql://root:@127.0.0.1:3306/test_maker" />
14+
<env name="TEST_DATABASE_DSN" value="mysql://root:root@127.0.0.1:3306/test_maker" />
1515
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0"/>
1616
</php>
1717

src/Test/MakerTestEnvironment.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,15 +444,15 @@ private function determineMissingDependencies(): array
444444
private function getTargetSkeletonVersion(): string
445445
{
446446
if (null === $this->targetSkeletonVersion) {
447-
$targetVersion = $_SERVER['MAKER_TEST_VERSION'] ?? 'stable';
447+
$stability = $_SERVER['SYMFONY_SKELETON_STABILITY'] ?? 'stable';
448448

449-
if ('stable' === $targetVersion) {
449+
if ('stable' === $stability) {
450450
$this->targetSkeletonVersion = '';
451451

452452
return $this->targetSkeletonVersion;
453453
}
454454

455-
switch ($targetVersion) {
455+
switch ($stability) {
456456
case 'stable-dev':
457457
$httpClient = HttpClient::create();
458458
$response = $httpClient->request('GET', 'https://symfony.com/versions.json');
@@ -469,7 +469,7 @@ private function getTargetSkeletonVersion(): string
469469

470470
break;
471471
default:
472-
throw new \InvalidArgumentException('Invalid target version');
472+
throw new \InvalidArgumentException('Invalid stability');
473473
}
474474
}
475475

0 commit comments

Comments
 (0)