From 3742ce6d7cef4b74c74bb4f0987b4b0d2003011e Mon Sep 17 00:00:00 2001 From: Martin Price Date: Sat, 6 Jun 2026 22:56:54 +0100 Subject: [PATCH 1/2] Issue #471: Use GITHUB_TOKEN for tests if exists. --- .github/workflows/tests.yml | 2 ++ tests/backdrop/DownloadCommandsTest.php | 30 ++++++++++++++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 996bcee7..2e38bfa0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -35,6 +35,8 @@ jobs: # Runs PHPUnit tests. - name: PHPUnit + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | cd $GITHUB_WORKSPACE lando run-tests diff --git a/tests/backdrop/DownloadCommandsTest.php b/tests/backdrop/DownloadCommandsTest.php index 7e9986a5..7d477736 100644 --- a/tests/backdrop/DownloadCommandsTest.php +++ b/tests/backdrop/DownloadCommandsTest.php @@ -14,15 +14,24 @@ class DownloadCommandsTest extends TestCase { * Make sure that the download command works. */ public function test_download_command_works() { + // Get GITHUB_TOKEN if running on GitHub. + $token_string = ''; + foreach (getenv() as $settingKey => $settingValue) { + if ($settingKey == 'GH_TOKEN') { + $token = $settingValue; + $token_string = " --github-token=$token"; + } + } + global $bee_test_root; // Single module. - $output_single = shell_exec('bee download simplify'); + $output_single = shell_exec('bee download' . $token_string . ' simplify'); $pattern = '/\'simplify\' \([\w\s\.\W]*\) was downloaded into \'' . preg_quote($bee_test_root, '/') . '\/backdrop\/modules\/simplify\'/'; $this->assertMatchesRegularExpression($pattern, $output_single); $this->assertTrue(file_exists("$bee_test_root/backdrop/modules/simplify/simplify.info")); // Multiple projects (theme and layout). - $output_multiple = shell_exec('bee download lumi bamboo'); + $output_multiple = shell_exec('bee download' . $token_string . ' lumi bamboo'); $pattern = '/\'lumi\' \([\w\s\.\W]*\) was downloaded into \'' . preg_quote($bee_test_root, '/') . '\/backdrop\/themes\/lumi\'/'; $this->assertMatchesRegularExpression($pattern, $output_multiple); $this->assertTrue(file_exists("$bee_test_root/backdrop/themes/lumi/lumi.info")); @@ -31,7 +40,7 @@ public function test_download_command_works() { $this->assertTrue(file_exists("$bee_test_root/backdrop/layouts/bamboo/bamboo.info")); // Defined release. - $output_defined_release = shell_exec('bee download layout_custom_theme:1.x-1.0.4'); + $output_defined_release = shell_exec('bee download' . $token_string . ' layout_custom_theme:1.x-1.0.4'); $pattern = '/\'layout_custom_theme\' \(1\.x\-1\.0\.4\, published at 2024\-02\-01T[\w\s\.\W]*\) was downloaded into \'' . preg_quote($bee_test_root, '/') . '\/backdrop\/modules\/layout_custom_theme\'/'; // Cleanup downloads. exec("rm -fr $bee_test_root/backdrop/modules/simplify $bee_test_root/backdrop/themes/lumi $bee_test_root/backdrop/layouts/bamboo $bee_test_root/backdrop/modules/layout_custom_theme"); @@ -41,21 +50,30 @@ public function test_download_command_works() { * Make sure that the download-core command works. */ public function test_download_core_command_works() { + // Get GITHUB_TOKEN if running on GitHub. + $token_string = ''; + foreach (getenv() as $settingKey => $settingValue) { + if ($settingKey == 'GH_TOKEN') { + $token = $settingValue; + $token_string = " --github-token=$token"; + } + } + global $bee_test_root; // Download to current directory. - $output_current = shell_exec("mkdir $bee_test_root/current && cd $bee_test_root/current && bee download-core"); + $output_current = shell_exec("mkdir $bee_test_root/current && cd $bee_test_root/current && bee download-core" . $token_string); $pattern = '/Backdrop \([\w\s\.\W]*\) was downloaded into \'' . preg_quote($bee_test_root, '/') . '\/current\'/'; $this->assertMatchesRegularExpression($pattern, $output_current); $this->assertTrue(file_exists("$bee_test_root/current/index.php")); // Download to specified directory. - $output_directory = shell_exec("bee download-core $bee_test_root/directory"); + $output_directory = shell_exec("bee download-core $bee_test_root/directory" . $token_string); $pattern = '/Backdrop \([\w\s\.\W]*\) was downloaded into \'' . preg_quote($bee_test_root, '/') . '\/directory\'/'; $this->assertMatchesRegularExpression($pattern, $output_directory); $this->assertTrue(file_exists("$bee_test_root/directory/index.php")); // Download a defined release. - $output_defined_release = shell_exec("bee download-core $bee_test_root/defined_release --version=1.30.0"); + $output_defined_release = shell_exec("bee download-core $bee_test_root/defined_release --version=1.30.0" . $token_string); $pattern = '/Backdrop \(1\.30\.0\, published at 2025\-01\-1\dT[\w\s\.\W]*\) was downloaded into \'' . preg_quote($bee_test_root, '/') . '\/defined_release\'/'; $this->assertMatchesRegularExpression($pattern, $output_defined_release); $this->assertTrue(file_exists("$bee_test_root/defined_release/index.php")); From 0f176dec6e3ded675b43326969e4a0a7f4ea4076 Mon Sep 17 00:00:00 2001 From: Martin Price Date: Sat, 6 Jun 2026 23:08:35 +0100 Subject: [PATCH 2/2] UPdate CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9886b488..9ae2145c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ system for each contributed module, theme and layout. - Warnings if dependency does not exist in the Backdrop Contributed Modules space (e.g. CiviCRM). +### Changed +- Update Download tests to use GitHub Token when running on GitHub. + ## [1.x-1.2.0] - 2026-02-25 ### Added