From 4d0977878d4529b019161bd340949dd79badd60f Mon Sep 17 00:00:00 2001 From: Matthew Oliveira Date: Fri, 10 Sep 2021 14:08:32 -0400 Subject: [PATCH 01/16] Add a Github Actions Workflow to run tests --- .github/workflows/test.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..65254b61 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,36 @@ +name: PHP Composer + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Validate composer.json and composer.lock + run: composer validate --strict + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v2 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- + + - name: Install dependencies + run: composer install --prefer-dist --no-progress + + # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" + # Docs: https://getcomposer.org/doc/articles/scripts.md + + # - name: Run test suite + # run: composer run-script test From 904b7ddd6cdc675b17cd6b2302c08f9b01a0811f Mon Sep 17 00:00:00 2001 From: Matthew Oliveira Date: Fri, 10 Sep 2021 14:11:42 -0400 Subject: [PATCH 02/16] Remove --strict from composer validate for now --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 65254b61..1069ba4e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: PHP Composer +name: Test on: push: @@ -15,7 +15,7 @@ jobs: - uses: actions/checkout@v2 - name: Validate composer.json and composer.lock - run: composer validate --strict + run: composer validate - name: Cache Composer packages id: composer-cache From 7f04ce9f87ceaba4f19adbf3cf641a7fb3c4c9ea Mon Sep 17 00:00:00 2001 From: Matthew Oliveira Date: Fri, 10 Sep 2021 14:14:20 -0400 Subject: [PATCH 03/16] Run phpunit tests in Github Actions workflow --- .github/workflows/test.yml | 7 ++----- composer.json | 3 +++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1069ba4e..9723e84f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,8 +29,5 @@ jobs: - name: Install dependencies run: composer install --prefer-dist --no-progress - # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" - # Docs: https://getcomposer.org/doc/articles/scripts.md - - # - name: Run test suite - # run: composer run-script test + - name: Run test suite + run: composer test diff --git a/composer.json b/composer.json index 880a9395..0f30356b 100644 --- a/composer.json +++ b/composer.json @@ -27,5 +27,8 @@ "php" : ">=5.5", "phpunit/phpunit": "4.8.* || ^6", "symfony/console": "^2.7.0" + }, + "scripts": { + "test": "phpunit tests" } } From e25805ebd3f2c33e4ab29184e6ab24e786ff0733 Mon Sep 17 00:00:00 2001 From: Matthew Oliveira Date: Fri, 10 Sep 2021 14:21:21 -0400 Subject: [PATCH 04/16] Only specify php requirement under require --- composer.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 0f30356b..53f7f736 100644 --- a/composer.json +++ b/composer.json @@ -10,8 +10,8 @@ "license": "Apache-2.0", "keywords": ["Drupal", "AMP", "mobile"], "homepage": "https://github.com/Lullabot/amp-library", - "require" : { - "php" : ">=5.5", + "require": { + "php": ">=5.5", "querypath/querypath": ">=3.0.4", "sebastian/diff": "^1.2 || ^2 || ^3", "marc1706/fast-image-size": "1.*", @@ -24,7 +24,6 @@ "psr-4": {"Lullabot\\AMP\\": "src"} }, "require-dev": { - "php" : ">=5.5", "phpunit/phpunit": "4.8.* || ^6", "symfony/console": "^2.7.0" }, From 450580e4f42160d9cbd74cd4a22ab3d6e36ad2b1 Mon Sep 17 00:00:00 2001 From: Matthew Oliveira Date: Fri, 10 Sep 2021 14:23:04 -0400 Subject: [PATCH 05/16] Fix the version constraint for querypath/querypath to pass composer --strict --- .github/workflows/test.yml | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9723e84f..c3aa61ee 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/checkout@v2 - name: Validate composer.json and composer.lock - run: composer validate + run: composer validate --strict - name: Cache Composer packages id: composer-cache diff --git a/composer.json b/composer.json index 53f7f736..80e478a0 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "homepage": "https://github.com/Lullabot/amp-library", "require": { "php": ">=5.5", - "querypath/querypath": ">=3.0.4", + "querypath/querypath": "^3.0.4", "sebastian/diff": "^1.2 || ^2 || ^3", "marc1706/fast-image-size": "1.*", "sabberworm/php-css-parser": "^8.0.0", From 70fa8d0c6e64b5a0db4686863f9540af510f4978 Mon Sep 17 00:00:00 2001 From: Matthew Oliveira Date: Fri, 10 Sep 2021 14:53:29 -0400 Subject: [PATCH 06/16] Store composer.lock file as an artifact --- .github/workflows/test.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c3aa61ee..f2fd8c6a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,6 +26,12 @@ jobs: restore-keys: | ${{ runner.os }}-php- + - name: Upload composer.lock + uses: actions/upload-artifact@v2 + with: + name: composer.lock + path: composer.lock + - name: Install dependencies run: composer install --prefer-dist --no-progress From 7bfdc72d77545eae99019e261cbb6f4257bc58ee Mon Sep 17 00:00:00 2001 From: Matthew Oliveira Date: Fri, 10 Sep 2021 14:54:53 -0400 Subject: [PATCH 07/16] Put the step to upload composer.lock in the right place :/ --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f2fd8c6a..ae9279d6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,14 +26,14 @@ jobs: restore-keys: | ${{ runner.os }}-php- + - name: Install dependencies + run: composer install --prefer-dist --no-progress + - name: Upload composer.lock uses: actions/upload-artifact@v2 with: name: composer.lock path: composer.lock - - name: Install dependencies - run: composer install --prefer-dist --no-progress - - name: Run test suite run: composer test From 5287a2ba8e491f35f89c5baad36a45fed66f3cd8 Mon Sep 17 00:00:00 2001 From: Matthew Oliveira Date: Fri, 10 Sep 2021 15:09:35 -0400 Subject: [PATCH 08/16] Try to setup build and test jobs sequentially --- .github/workflows/test.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ae9279d6..c0f35971 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,5 +35,9 @@ jobs: name: composer.lock path: composer.lock - - name: Run test suite - run: composer test + test: + needs: build + runs-on: ubuntu-latest + steps: + - name: Run test suite + run: composer test From 99fef36923794f67d887943fda1956a52c3c496c Mon Sep 17 00:00:00 2001 From: Matthew Oliveira Date: Fri, 10 Sep 2021 15:13:17 -0400 Subject: [PATCH 09/16] Revert "Try to setup build and test jobs sequentially" This reverts commit 5287a2ba8e491f35f89c5baad36a45fed66f3cd8. --- .github/workflows/test.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c0f35971..ae9279d6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,9 +35,5 @@ jobs: name: composer.lock path: composer.lock - test: - needs: build - runs-on: ubuntu-latest - steps: - - name: Run test suite - run: composer test + - name: Run test suite + run: composer test From 829cebc0c88f041219b17330c49db43a92dce906 Mon Sep 17 00:00:00 2001 From: Matthew Oliveira Date: Fri, 10 Sep 2021 15:33:48 -0400 Subject: [PATCH 10/16] Specify PHP version 7.4 for the environment --- .github/workflows/test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ae9279d6..8ba48a56 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,6 +14,10 @@ jobs: steps: - uses: actions/checkout@v2 + - uses: shivammathur/setup-php@v2 + with: + php-verson: 7.4 + - name: Validate composer.json and composer.lock run: composer validate --strict From cdf33b9d26cdd1d3a2b39571275b8ea68621b1ed Mon Sep 17 00:00:00 2001 From: Matthew Oliveira Date: Fri, 10 Sep 2021 15:34:41 -0400 Subject: [PATCH 11/16] Increase the minimum phpunit requirement such that old phpunit won't be installed in a PHP >= 8 environment --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 80e478a0..01d61b18 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "psr-4": {"Lullabot\\AMP\\": "src"} }, "require-dev": { - "phpunit/phpunit": "4.8.* || ^6", + "phpunit/phpunit": "^5.6.3 || ^6", "symfony/console": "^2.7.0" }, "scripts": { From 538312d3a15f84aced630704c6127bb5645072b1 Mon Sep 17 00:00:00 2001 From: Matthew Oliveira Date: Fri, 10 Sep 2021 15:36:16 -0400 Subject: [PATCH 12/16] Fix typo in github action workflow --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8ba48a56..2698d2d4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,7 +16,7 @@ jobs: - uses: shivammathur/setup-php@v2 with: - php-verson: 7.4 + php-version: 7.4 - name: Validate composer.json and composer.lock run: composer validate --strict From ac3e310e4246bf50b56115031263107d8f6b4d69 Mon Sep 17 00:00:00 2001 From: Matthew Oliveira Date: Fri, 10 Sep 2021 15:43:11 -0400 Subject: [PATCH 13/16] Try running tests using a matrix strategy of different PHP versions --- .github/workflows/test.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2698d2d4..5e0982cf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,12 +11,17 @@ jobs: runs-on: ubuntu-latest + strategy: + matrix: + php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4'] + steps: - uses: actions/checkout@v2 - - uses: shivammathur/setup-php@v2 + - name: Setup PHP + uses: shivammathur/setup-php@v2 with: - php-version: 7.4 + php-version: ${{ matrix.php-versions }} - name: Validate composer.json and composer.lock run: composer validate --strict From c40b19a38ff2c9a857acb254932272fa36be7f97 Mon Sep 17 00:00:00 2001 From: Matthew Oliveira Date: Fri, 10 Sep 2021 16:03:04 -0400 Subject: [PATCH 14/16] Remove Travis config --- .travis.yml | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5f0a043e..00000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -language: php -dist: trusty - -php: - - 5.5 - - 5.6 - - 7.0 - - 7.1 - - 7.2 - - 7.3 - - 7.4 - - nightly - -before_script: - - composer install - -script: - - vendor/bin/phpunit tests - -matrix: - fast_finish: true - allow_failures: - - php: nightly From 1f8c37770f02760f245acc001dba8c0730b44435 Mon Sep 17 00:00:00 2001 From: Matthew Oliveira Date: Fri, 10 Sep 2021 16:05:04 -0400 Subject: [PATCH 15/16] Express PHP dependency >= 5.6 since we're no longer expressly testing on 5.5 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 01d61b18..8fc6db67 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "keywords": ["Drupal", "AMP", "mobile"], "homepage": "https://github.com/Lullabot/amp-library", "require": { - "php": ">=5.5", + "php": ">=5.6", "querypath/querypath": "^3.0.4", "sebastian/diff": "^1.2 || ^2 || ^3", "marc1706/fast-image-size": "1.*", From 47431ccb0472e6a90ffdcf78c1f15e5265b24936 Mon Sep 17 00:00:00 2001 From: Matthew Oliveira Date: Fri, 10 Sep 2021 16:08:21 -0400 Subject: [PATCH 16/16] Couple of labeling tweaks to the test workflow --- .github/workflows/test.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5e0982cf..eb20eac5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,8 +7,8 @@ on: branches: [ master ] jobs: - build: - + test: + name: Test runs-on: ubuntu-latest strategy: @@ -16,7 +16,8 @@ jobs: php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4'] steps: - - uses: actions/checkout@v2 + - name: Checkout code + uses: actions/checkout@v2 - name: Setup PHP uses: shivammathur/setup-php@v2