From aaf6143c1aa2c6094cfb453f01c579292efba1a9 Mon Sep 17 00:00:00 2001 From: JR Tashjian Date: Sat, 29 Apr 2023 13:39:31 -0400 Subject: [PATCH 1/5] Initial setup from what Gutenberg has --- .github/workflows/build-and-test.yml | 76 +++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 3829a63..20b8e66 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -81,15 +81,87 @@ jobs: - name: Linting code run: npm run lint-css + # From the Gutenberg project + # https://github.com/WordPress/gutenberg/blob/trunk/.github/workflows/unit-test.yml#L78-L187 test_unit_php: runs-on: ubuntu-latest needs: [lint_php] strategy: + fail-fast: true matrix: php: [7.4, 8.0, 8.1] multisite: [0, 1] + env: + WP_ENV_PHP_VERSION: ${{ matrix.php }} + WP_ENV_CORE: 'https://wordpress.org/wordpress-latest.zip' + steps: - - name: Placeholder - run: echo "Placeholder ${{ matrix.php }}" \ No newline at end of file + - name: Checkout code + uses: actions/checkout@v2 + + - name: Restore npm dependency cache + uses: ./.github/actions/restore-npm-cache + + - name: Restore composer dependency cache + uses: ./.github/actions/restore-composer-cache + + ## + # This allows Composer dependencies to be installed using a single step. + # + # Since the tests are currently run within the Docker containers where the PHP version varies, + # the same PHP version needs to be configured for the action runner machine so that the correct + # dependency versions are installed and cached. + ## + - name: Set up PHP + uses: shivammathur/setup-php@d30ad8b1843ace22e6698ab99bbafaa747b6bd0d # v2.24.0 + with: + php-version: '${{ matrix.php }}' + ini-file: development + coverage: none + + - name: Install node dependencies + run: npm install + + - name: Install PHP-Scoper + run: | + wget https://github.com/humbug/php-scoper/releases/download/0.18.2/php-scoper.phar -O /usr/local/bin/php-scoper + chmod +x /usr/local/bin/php-scoper + + - name: Install composer dependencies + run: | + composer run phpscoper + composer install + + - name: Build the plugin + run: npm run build + + - name: Docker debug information + run: | + docker -v + docker-compose -v + + - name: General debug information + run: | + npm --version + node --version + curl --version + git --version + svn --version + locale -a + + - name: Start Docker environment + run: npm run wp-env start + + - name: Log running Docker containers + run: docker ps -a + + - name: Docker container debug information + run: | + npm run wp-env run tests-mysql "mysql --version" + npm run wp-env run tests-wordpress "php --version" + npm run wp-env run tests-wordpress "php -m" + npm run wp-env run tests-wordpress "php -i" + npm run wp-env run tests-wordpress "/var/www/html/wp-content/plugins/gutenberg/vendor/bin/phpunit --version" + npm run wp-env run tests-wordpress "locale -a" \ No newline at end of file From 11f648f7a2bf5f071ab436425233dd9bf65864dc Mon Sep 17 00:00:00 2001 From: JR Tashjian Date: Sat, 29 Apr 2023 13:43:59 -0400 Subject: [PATCH 2/5] Ensure that Composer installs the correct versions of packages. --- .github/workflows/build-and-test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 20b8e66..fc230e6 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -121,6 +121,10 @@ jobs: ini-file: development coverage: none + # Ensure that Composer installs the correct versions of packages. + - name: Override PHP version in composer.json + run: composer config platform.php ${{ matrix.php }} + - name: Install node dependencies run: npm install From 2799229cffa0780d154e5426529492a3348f11cb Mon Sep 17 00:00:00 2001 From: JR Tashjian Date: Sat, 29 Apr 2023 13:53:57 -0400 Subject: [PATCH 3/5] Store vendor_prefixed dir for later --- .github/workflows/build-and-test.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index fc230e6..7e2683c 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -39,6 +39,12 @@ jobs: name: plugin-build-dir path: ./build + - name: Save vendor_prefixed dir + uses: actions/upload-artifact@v2 + with: + name: plugin-vendor_prefixed-dir + path: ./vendor_prefixed + lint_php: runs-on: ubuntu-latest needs: [build] @@ -125,18 +131,16 @@ jobs: - name: Override PHP version in composer.json run: composer config platform.php ${{ matrix.php }} + - name: Download vendor_prefixed dir + uses: actions/download-artifact@v3 + with: + name: plugin-vendor_prefixed-dir + - name: Install node dependencies run: npm install - - name: Install PHP-Scoper - run: | - wget https://github.com/humbug/php-scoper/releases/download/0.18.2/php-scoper.phar -O /usr/local/bin/php-scoper - chmod +x /usr/local/bin/php-scoper - - name: Install composer dependencies - run: | - composer run phpscoper - composer install + run: composer install - name: Build the plugin run: npm run build From 57f898e9c0d8fed747e4b7cb36e80c0430f9eeeb Mon Sep 17 00:00:00 2001 From: JR Tashjian Date: Sat, 29 Apr 2023 14:00:09 -0400 Subject: [PATCH 4/5] try restoring from build job --- .github/workflows/build-and-test.yml | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 7e2683c..5abf90a 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -113,6 +113,9 @@ jobs: - name: Restore composer dependency cache uses: ./.github/actions/restore-composer-cache + - name: Download artifacts + uses: actions/download-artifact@v3 + ## # This allows Composer dependencies to be installed using a single step. # @@ -127,24 +130,6 @@ jobs: ini-file: development coverage: none - # Ensure that Composer installs the correct versions of packages. - - name: Override PHP version in composer.json - run: composer config platform.php ${{ matrix.php }} - - - name: Download vendor_prefixed dir - uses: actions/download-artifact@v3 - with: - name: plugin-vendor_prefixed-dir - - - name: Install node dependencies - run: npm install - - - name: Install composer dependencies - run: composer install - - - name: Build the plugin - run: npm run build - - name: Docker debug information run: | docker -v From bdad4a9cadc10d1324b98748549751cc3d853288 Mon Sep 17 00:00:00 2001 From: JR Tashjian Date: Sat, 29 Apr 2023 14:06:22 -0400 Subject: [PATCH 5/5] modify download-artifact --- .github/workflows/build-and-test.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 5abf90a..bd3fefc 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -33,7 +33,7 @@ jobs: - name: Build the plugin run: npm run build - - name: Save compiled assets + - name: Save build dir uses: actions/upload-artifact@v2 with: name: plugin-build-dir @@ -113,8 +113,17 @@ jobs: - name: Restore composer dependency cache uses: ./.github/actions/restore-composer-cache - - name: Download artifacts - uses: actions/download-artifact@v3 + - name: Download build dir + uses: actions/download-artifact@v2 + with: + name: plugin-build-dir + path: ./build + + - name: Download vendor_prefixed dir + uses: actions/download-artifact@v2 + with: + name: plugin-vendor_prefixed-dir + path: ./vendor_prefixed ## # This allows Composer dependencies to be installed using a single step.