From 50110aace7d973f68b141289f5c278656e6e6944 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 26 Oct 2020 13:59:39 +0100 Subject: [PATCH 1/3] Enhancement: Use GithubActions for tests instead of Travis --- .github/workflows/ci.yml | 97 ++++++++++++++++++++++++++++++++++++++++ .travis.yml | 39 ---------------- phpunit.xml.dist | 2 +- 3 files changed, 98 insertions(+), 40 deletions(-) delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 206fecbd6..e58253185 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,9 @@ on: env: fail-fast: true + PHPUNIT_FLAGS: "-v" + SYMFONY_PHPUNIT_DIR: "$HOME/symfony-bridge/.phpunit" + SYMFONY_REQUIRE: ">=3.4" jobs: coding-standards: @@ -56,3 +59,97 @@ jobs: - name: "Run friendsofphp/php-cs-fixer" run: "vendor/bin/php-cs-fixer fix --dry-run --diff" + + test: + name: "PHP ${{ matrix.php-version }} + MAKER_TEST_VERSION: ${{ matrix.maker-test-version }} + composer 2" + + runs-on: ubuntu-latest + + services: + mysql: + image: mysql:5.7 + env: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: test_maker + ports: + - 3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + + continue-on-error: ${{ matrix.allow-failures }} + + env: + MAKER_TEST_VERSION: ${{ matrix.maker-test-version }} + + strategy: + matrix: + php-version: + - '7.1.33' + - '7.2.5' + - '7.3' + - '7.4' + maker-test-version: + - 'stable' + allow-failures: [false] + include: + - php-version: '7.4' + maker-test-version: 'dev' + allow-failures: true + - php-version: '8.0' + maker-test-version: 'stable' + allow-failures: true + + steps: + - name: "Checkout code" + uses: actions/checkout@v2.3.3 + + - name: "Start MySQL" + run: | + sudo /etc/init.d/mysql start + + - name: "Verify MySQL connection from host" + run: | + sudo apt-get install -y mysql-client + mysql --host 127.0.0.1 --port 3306 -uroot -proot -e "SHOW DATABASES;" + + - name: "Setup Database" + run: | + mysql --host 127.0.0.1 --port 3306 -uroot -proot -e "CREATE DATABASE IF NOT EXISTS test_maker;" + + - name: "Install PHP with extensions" + uses: shivammathur/setup-php@2.7.0 + with: + coverage: "none" + php-version: ${{ matrix.php-version }} + tools: composer:v2 + + - name: "Add PHPUnit matcher" + run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: "Set composer cache directory" + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: "Cache composer" + uses: actions/cache@v2.1.2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-${{ matrix.php-version }}-composer-${{ hashFiles('composer.json') }}-maker-test-version-${{ matrix.maker-test-version }}-allow-failures-${{ matrix.allow-failures }} + restore-keys: ${{ runner.os }}-${{ matrix.php-version }}-composer- + + - name: "Require symfony/flex" + run: composer global require --no-progress --no-scripts --no-plugins symfony/flex dev-main + + - if: matrix.php-version != '8.0' + run: composer update + + - if: matrix.php-version == '8.0' + run: composer update --ignore-platform-reqs + + - name: "Install PHPUnit" + run: vendor/bin/simple-phpunit install + + - name: "PHPUnit version" + run: vendor/bin/simple-phpunit --version + + - name: "Run tests" + run: vendor/bin/simple-phpunit ${{ env.PHPUNIT_FLAGS }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9c80bf791..000000000 --- a/.travis.yml +++ /dev/null @@ -1,39 +0,0 @@ -language: php -sudo: false -cache: - directories: - - $HOME/.composer/cache/files - - $HOME/symfony-bridge/.phpunit - -services: - - mysql - -env: - global: - - PHPUNIT_FLAGS="-v" - - SYMFONY_PHPUNIT_DIR="$HOME/symfony-bridge/.phpunit" - - SYMFONY_REQUIRE='>=3.4' - -matrix: - fast_finish: true - include: - - php: 7.1.33 - env: MAKER_TEST_VERSION=stable - - php: 7.3 - env: MAKER_TEST_VERSION=stable - - php: 7.4 - env: MAKER_TEST_VERSION=dev - allow_failures: - - php: 7.4 - env: MAKER_TEST_VERSION=dev - -before_install: - - find ~/.phpenv -name xdebug.ini -delete - - composer global require --no-progress --no-scripts --no-plugins symfony/flex dev-main - - composer update - -install: - - ./vendor/bin/simple-phpunit install - -script: - - ./vendor/bin/simple-phpunit $PHPUNIT_FLAGS diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 7b2bab935..18b167feb 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -11,7 +11,7 @@ > - + From 7742a57ecbc86b8e5b9456658747a594da597896 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Tue, 27 Oct 2020 20:15:44 +0100 Subject: [PATCH 2/3] Enhancement: Rename ENV var --- .github/workflows/ci.yml | 12 ++++++------ src/Test/MakerTestEnvironment.php | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e58253185..0ca4a59a3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,7 +61,7 @@ jobs: run: "vendor/bin/php-cs-fixer fix --dry-run --diff" test: - name: "PHP ${{ matrix.php-version }} + MAKER_TEST_VERSION: ${{ matrix.maker-test-version }} + composer 2" + name: "PHP ${{ matrix.php-version }} + symfony/skeleton@${{ matrix.symfony-skeleton-stability }}" runs-on: ubuntu-latest @@ -78,7 +78,7 @@ jobs: continue-on-error: ${{ matrix.allow-failures }} env: - MAKER_TEST_VERSION: ${{ matrix.maker-test-version }} + SYMFONY_SKELETON_STABILITY: ${{ matrix.symfony-skeleton-stability }} strategy: matrix: @@ -87,15 +87,15 @@ jobs: - '7.2.5' - '7.3' - '7.4' - maker-test-version: + symfony-skeleton-stability: - 'stable' allow-failures: [false] include: - php-version: '7.4' - maker-test-version: 'dev' + symfony-skeleton-stability: 'dev' allow-failures: true - php-version: '8.0' - maker-test-version: 'stable' + symfony-skeleton-stability: 'stable' allow-failures: true steps: @@ -133,7 +133,7 @@ jobs: uses: actions/cache@v2.1.2 with: path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-${{ matrix.php-version }}-composer-${{ hashFiles('composer.json') }}-maker-test-version-${{ matrix.maker-test-version }}-allow-failures-${{ matrix.allow-failures }} + key: ${{ runner.os }}-${{ matrix.php-version }}-composer-${{ hashFiles('composer.json') }}-symfony-skeleton-stability-${{ matrix.symfony-skeleton-stability }}-allow-failures-${{ matrix.allow-failures }} restore-keys: ${{ runner.os }}-${{ matrix.php-version }}-composer- - name: "Require symfony/flex" diff --git a/src/Test/MakerTestEnvironment.php b/src/Test/MakerTestEnvironment.php index 121ebe529..812e153dc 100644 --- a/src/Test/MakerTestEnvironment.php +++ b/src/Test/MakerTestEnvironment.php @@ -444,15 +444,15 @@ private function determineMissingDependencies(): array private function getTargetSkeletonVersion(): string { if (null === $this->targetSkeletonVersion) { - $targetVersion = $_SERVER['MAKER_TEST_VERSION'] ?? 'stable'; + $stability = $_SERVER['SYMFONY_SKELETON_STABILITY'] ?? 'stable'; - if ('stable' === $targetVersion) { + if ('stable' === $stability) { $this->targetSkeletonVersion = ''; return $this->targetSkeletonVersion; } - switch ($targetVersion) { + switch ($stability) { case 'stable-dev': $httpClient = HttpClient::create(); $response = $httpClient->request('GET', 'https://symfony.com/versions.json'); @@ -469,7 +469,7 @@ private function getTargetSkeletonVersion(): string break; default: - throw new \InvalidArgumentException('Invalid target version'); + throw new \InvalidArgumentException('Invalid stability'); } } From 32c471b0fce4d0b3ebaec1c70d94a432a9eb9b57 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Tue, 27 Oct 2020 16:25:40 -0400 Subject: [PATCH 3/3] using dev for php 8 So that unreleased packages can be used --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ca4a59a3..a200f8d0f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -95,7 +95,7 @@ jobs: symfony-skeleton-stability: 'dev' allow-failures: true - php-version: '8.0' - symfony-skeleton-stability: 'stable' + symfony-skeleton-stability: 'dev' allow-failures: true steps: