From 9c3ccee1300be561d77520b4da958537abe6866d Mon Sep 17 00:00:00 2001 From: unfrgivn Date: Mon, 8 Jul 2024 13:04:04 -0500 Subject: [PATCH 01/12] feat: add new input FORMULA_INCLUDES --- homebrew_releaser/app.py | 2 ++ homebrew_releaser/constants.py | 1 + homebrew_releaser/formula.py | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/homebrew_releaser/app.py b/homebrew_releaser/app.py index 6fca2dc..d899c56 100644 --- a/homebrew_releaser/app.py +++ b/homebrew_releaser/app.py @@ -8,6 +8,7 @@ from homebrew_releaser.constants import ( CHECKSUM_FILE, CUSTOM_REQUIRE, + FORMULA_INCLUDES, DOWNLOAD_STRATEGY, FORMULA_FOLDER, GITHUB_OWNER, @@ -156,6 +157,7 @@ def run_github_action(): TEST, DOWNLOAD_STRATEGY, CUSTOM_REQUIRE, + FORMULA_INCLUDES, version_no_v if VERSION else None, ) diff --git a/homebrew_releaser/constants.py b/homebrew_releaser/constants.py index 3cec292..ce0dd5b 100644 --- a/homebrew_releaser/constants.py +++ b/homebrew_releaser/constants.py @@ -10,6 +10,7 @@ ) # Must check for string `false` since GitHub Actions passes the bool as a string DOWNLOAD_STRATEGY = os.getenv('INPUT_DOWNLOAD_STRATEGY') CUSTOM_REQUIRE = os.getenv('INPUT_CUSTOM_REQUIRE') +FORMULA_INCLUDES = os.getenv('INPUT_FORMULA_INCLUDES') VERSION = os.getenv('INPUT_VERSION') # App Constants diff --git a/homebrew_releaser/formula.py b/homebrew_releaser/formula.py index 98427b9..918b0de 100644 --- a/homebrew_releaser/formula.py +++ b/homebrew_releaser/formula.py @@ -31,6 +31,7 @@ def generate_formula_data( test: Optional[str] = None, download_strategy: Optional[str] = None, custom_require: Optional[str] = None, + formula_includes: str = None, version: Optional[str] = None, ) -> str: """Generates the formula data for Homebrew. @@ -138,6 +139,8 @@ class {{class_name}} < Formula license "{{license_type}}" {{/ license_type}} + {{{formula_includes}}} + {{# dependencies}} depends_on {{{dependency}}} {{/ dependencies}} @@ -212,6 +215,7 @@ def install 'test_instructions': test.strip() if test else None, 'download_strategy': download_strategy, 'custom_require': custom_require, + 'formula_includes': formula_includes.strip() if formula_includes else None, 'version': version, 'darwin_amd64_url': darwin_amd64_url, 'darwin_amd64_checksum': darwin_amd64_checksum, From 8e1614714878bbf14084323b36345006e242c580 Mon Sep 17 00:00:00 2001 From: unfrgivn Date: Mon, 8 Jul 2024 13:04:59 -0500 Subject: [PATCH 02/12] build: add INPUT_FORMULA_INCLUDES to docker-compose --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index a1a7ebf..34a8f0a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,6 +16,7 @@ services: - INPUT_TEST='assert_match("my script output", shell_output("my-script-command"))' - INPUT_DOWNLOAD_STRATEGY= - INPUT_CUSTOM_REQUIRE= + - INPUT_FORMULA_INCLUDES= - INPUT_TARGET_DARWIN_AMD64= - INPUT_TARGET_DARWIN_ARM64= - INPUT_TARGET_LINUX_AMD64= From caf770f337b3b4195c2a67ad94b0c4ec10e3ec2c Mon Sep 17 00:00:00 2001 From: unfrgivn Date: Mon, 8 Jul 2024 13:08:45 -0500 Subject: [PATCH 03/12] docs: update README with new parameter --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 9b4250f..a03790c 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,10 @@ jobs: # Optional - string custom_require: custom_download_strategy + # Allows you to add custom includes inside the formula class, before dependencies and install blocks. + # Optional - string + formula_includes: 'include Language::Python::Virtualenv' + # Override the automatically detected version of a formula with an explicit value. # This option should only be used if Homebrew cannot automatically detect the version when generating # the Homebrew formula. Including this when not necessary could lead to uninstallable formula that may From adbf5e689335ebac1557d6eb39cdcde4e83b8e64 Mon Sep 17 00:00:00 2001 From: unfrgivn Date: Mon, 8 Jul 2024 13:21:26 -0500 Subject: [PATCH 04/12] style: lint-fix files --- homebrew_releaser/app.py | 2 +- homebrew_releaser/readme_updater.py | 12 +-- test/unit/test_formula.py | 140 +++++++++++----------------- test/unit/test_git.py | 52 +++++------ 4 files changed, 87 insertions(+), 119 deletions(-) diff --git a/homebrew_releaser/app.py b/homebrew_releaser/app.py index d899c56..5b93ebb 100644 --- a/homebrew_releaser/app.py +++ b/homebrew_releaser/app.py @@ -8,9 +8,9 @@ from homebrew_releaser.constants import ( CHECKSUM_FILE, CUSTOM_REQUIRE, - FORMULA_INCLUDES, DOWNLOAD_STRATEGY, FORMULA_FOLDER, + FORMULA_INCLUDES, GITHUB_OWNER, GITHUB_REPO, GITHUB_TOKEN, diff --git a/homebrew_releaser/readme_updater.py b/homebrew_releaser/readme_updater.py index 139f31f..aa2b767 100644 --- a/homebrew_releaser/readme_updater.py +++ b/homebrew_releaser/readme_updater.py @@ -93,13 +93,11 @@ def generate_table(formulas: List) -> str: rows = [] for formula in formulas: - rows.append( - [ - f'[{formula["name"]}]({formula.get("homepage")})', - formula.get('desc'), - f'`brew install {formula["name"]}`', - ] - ) + rows.append([ + f'[{formula["name"]}]({formula.get("homepage")})', + formula.get('desc'), + f'`brew install {formula["name"]}`', + ]) table = pretty_tables.create( headers=headers, diff --git a/test/unit/test_formula.py b/test/unit/test_formula.py index bfdc8d4..1cf1703 100644 --- a/test/unit/test_formula.py +++ b/test/unit/test_formula.py @@ -67,14 +67,12 @@ def test_generate_formula(): owner=USERNAME, repo_name=mock_repo_name, repository=repository, - checksums=[ - { - f'{mock_repo_name}.tar.gz': { - 'checksum': CHECKSUM, - 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa - }, - } - ], + checksums=[{ + f'{mock_repo_name}.tar.gz': { + 'checksum': CHECKSUM, + 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa + }, + }], install=INSTALL, tar_url=mock_tar_url, depends_on=DEPENDS_ON, @@ -84,32 +82,20 @@ def test_generate_formula(): record_formula(formula_path, formula_filename, formula) # The following assertions are explicitly listed as the "gold standard" for generic formula generation - assert ( - '''# typed: true + assert '''# typed: true # frozen_string_literal: true -# This file was generated by Homebrew Releaser. DO NOT EDIT.''' - in formula - ) - assert ( - '''desc "Tool to release scripts, binaries, and executables to github" +# This file was generated by Homebrew Releaser. DO NOT EDIT.''' in formula + assert '''desc "Tool to release scripts, binaries, and executables to github" homepage "https://github.com/Justintime50/test-generate-formula" url "https://github.com/Justintime50/test-generate-formula/archive/refs/tags/v0.1.0.tar.gz" sha256 "0000000000000000000000000000000000000000000000000000000000000000" - license "MIT"''' - in formula - ) - assert ( - '''depends_on "bash" => :build - depends_on "gcc"''' - in formula - ) - assert ( - '''def install + license "MIT"''' in formula + assert '''depends_on "bash" => :build + depends_on "gcc"''' in formula + assert '''def install bin.install "src/secure-browser-kiosk.sh" => "secure-browser-kiosk" - end''' - in formula - ) + end''' in formula assert '''test do assert_match("my script output", shell_output("my-script-command")) end''' @@ -135,14 +121,12 @@ def test_generate_formula_no_article_description(): owner=USERNAME, repo_name=mock_repo_name, repository=repository, - checksums=[ - { - f'{mock_repo_name}.tar.gz': { - 'checksum': CHECKSUM, - 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa - }, - } - ], + checksums=[{ + f'{mock_repo_name}.tar.gz': { + 'checksum': CHECKSUM, + 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa + }, + }], install=INSTALL, tar_url=mock_tar_url, depends_on=None, @@ -174,14 +158,12 @@ def test_generate_formula_formula_name_starts_description(): owner=USERNAME, repo_name=mock_repo_name, repository=repository, - checksums=[ - { - f'{mock_repo_name}.tar.gz': { - 'checksum': CHECKSUM, - 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa - }, - } - ], + checksums=[{ + f'{mock_repo_name}.tar.gz': { + 'checksum': CHECKSUM, + 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa + }, + }], install=INSTALL, tar_url=mock_tar_url, depends_on=None, @@ -211,14 +193,12 @@ def test_generate_formula_no_depends_on(): owner=USERNAME, repo_name=mock_repo_name, repository=repository, - checksums=[ - { - f'{mock_repo_name}.tar.gz': { - 'checksum': CHECKSUM, - 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa - }, - } - ], + checksums=[{ + f'{mock_repo_name}.tar.gz': { + 'checksum': CHECKSUM, + 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa + }, + }], install=INSTALL, tar_url=mock_tar_url, depends_on=None, @@ -248,14 +228,12 @@ def test_generate_formula_no_test(): owner=USERNAME, repo_name=mock_repo_name, repository=repository, - checksums=[ - { - f'{mock_repo_name}.tar.gz': { - 'checksum': CHECKSUM, - 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa - }, - } - ], + checksums=[{ + f'{mock_repo_name}.tar.gz': { + 'checksum': CHECKSUM, + 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa + }, + }], install=INSTALL, tar_url=mock_tar_url, depends_on=DEPENDS_ON, @@ -523,14 +501,12 @@ def test_generate_formula_string_false_configs(): owner=USERNAME, repo_name=mock_repo_name, repository=repository, - checksums=[ - { - f'{mock_repo_name}.tar.gz': { - 'checksum': CHECKSUM, - 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa - }, - } - ], + checksums=[{ + f'{mock_repo_name}.tar.gz': { + 'checksum': CHECKSUM, + 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa + }, + }], install=INSTALL, tar_url=mock_tar_url, depends_on=None, @@ -562,14 +538,12 @@ def test_generate_formula_empty_fields(): owner=USERNAME, repo_name=mock_repo_name, repository=repository, - checksums=[ - { - f'{mock_repo_name}.tar.gz': { - 'checksum': CHECKSUM, - 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa - }, - } - ], + checksums=[{ + f'{mock_repo_name}.tar.gz': { + 'checksum': CHECKSUM, + 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa + }, + }], install=INSTALL, tar_url=mock_tar_url, depends_on=None, @@ -668,14 +642,12 @@ def test_generate_formula_override_version(): owner=USERNAME, repo_name=mock_repo_name, repository=repository, - checksums=[ - { - f'{mock_repo_name}.tar.gz': { - 'checksum': CHECKSUM, - 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa - }, - } - ], + checksums=[{ + f'{mock_repo_name}.tar.gz': { + 'checksum': CHECKSUM, + 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa + }, + }], install=INSTALL, tar_url=mock_tar_url, version='9.8.7', diff --git a/test/unit/test_git.py b/test/unit/test_git.py index 2ef9a99..19fcdeb 100644 --- a/test/unit/test_git.py +++ b/test/unit/test_git.py @@ -19,33 +19,31 @@ def test_setup(mock_subprocess): commit_email = 'user@example.com' Git.setup(homebrew_owner, commit_email, homebrew_owner, homebrew_tap) - mock_subprocess.assert_has_calls( - [ - call( - [ - 'git', - 'clone', - '--depth=1', - 'https://x-access-token:123@github.com/Justintime50/homebrew-formulas.git', - ], - stderr=-2, - text=True, - timeout=30, - ), - call( - ['git', '-C', 'homebrew-formulas', 'config', 'user.name', '"Justintime50"'], - stderr=-2, - text=True, - timeout=30, - ), - call( - ['git', '-C', 'homebrew-formulas', 'config', 'user.email', 'user@example.com'], - stderr=-2, - text=True, - timeout=30, - ), - ] - ) + mock_subprocess.assert_has_calls([ + call( + [ + 'git', + 'clone', + '--depth=1', + 'https://x-access-token:123@github.com/Justintime50/homebrew-formulas.git', + ], + stderr=-2, + text=True, + timeout=30, + ), + call( + ['git', '-C', 'homebrew-formulas', 'config', 'user.name', '"Justintime50"'], + stderr=-2, + text=True, + timeout=30, + ), + call( + ['git', '-C', 'homebrew-formulas', 'config', 'user.email', 'user@example.com'], + stderr=-2, + text=True, + timeout=30, + ), + ]) @patch('subprocess.check_output') From fe6815cce5088614615deed9d95296d997b2d238 Mon Sep 17 00:00:00 2001 From: unfrgivn Date: Tue, 9 Jul 2024 17:24:58 -0500 Subject: [PATCH 05/12] style: lint-fix files --- homebrew_releaser/readme_updater.py | 12 ++- test/unit/test_formula.py | 140 +++++++++++++++++----------- test/unit/test_git.py | 52 ++++++----- 3 files changed, 118 insertions(+), 86 deletions(-) diff --git a/homebrew_releaser/readme_updater.py b/homebrew_releaser/readme_updater.py index aa2b767..139f31f 100644 --- a/homebrew_releaser/readme_updater.py +++ b/homebrew_releaser/readme_updater.py @@ -93,11 +93,13 @@ def generate_table(formulas: List) -> str: rows = [] for formula in formulas: - rows.append([ - f'[{formula["name"]}]({formula.get("homepage")})', - formula.get('desc'), - f'`brew install {formula["name"]}`', - ]) + rows.append( + [ + f'[{formula["name"]}]({formula.get("homepage")})', + formula.get('desc'), + f'`brew install {formula["name"]}`', + ] + ) table = pretty_tables.create( headers=headers, diff --git a/test/unit/test_formula.py b/test/unit/test_formula.py index 1cf1703..bfdc8d4 100644 --- a/test/unit/test_formula.py +++ b/test/unit/test_formula.py @@ -67,12 +67,14 @@ def test_generate_formula(): owner=USERNAME, repo_name=mock_repo_name, repository=repository, - checksums=[{ - f'{mock_repo_name}.tar.gz': { - 'checksum': CHECKSUM, - 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa - }, - }], + checksums=[ + { + f'{mock_repo_name}.tar.gz': { + 'checksum': CHECKSUM, + 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa + }, + } + ], install=INSTALL, tar_url=mock_tar_url, depends_on=DEPENDS_ON, @@ -82,20 +84,32 @@ def test_generate_formula(): record_formula(formula_path, formula_filename, formula) # The following assertions are explicitly listed as the "gold standard" for generic formula generation - assert '''# typed: true + assert ( + '''# typed: true # frozen_string_literal: true -# This file was generated by Homebrew Releaser. DO NOT EDIT.''' in formula - assert '''desc "Tool to release scripts, binaries, and executables to github" +# This file was generated by Homebrew Releaser. DO NOT EDIT.''' + in formula + ) + assert ( + '''desc "Tool to release scripts, binaries, and executables to github" homepage "https://github.com/Justintime50/test-generate-formula" url "https://github.com/Justintime50/test-generate-formula/archive/refs/tags/v0.1.0.tar.gz" sha256 "0000000000000000000000000000000000000000000000000000000000000000" - license "MIT"''' in formula - assert '''depends_on "bash" => :build - depends_on "gcc"''' in formula - assert '''def install + license "MIT"''' + in formula + ) + assert ( + '''depends_on "bash" => :build + depends_on "gcc"''' + in formula + ) + assert ( + '''def install bin.install "src/secure-browser-kiosk.sh" => "secure-browser-kiosk" - end''' in formula + end''' + in formula + ) assert '''test do assert_match("my script output", shell_output("my-script-command")) end''' @@ -121,12 +135,14 @@ def test_generate_formula_no_article_description(): owner=USERNAME, repo_name=mock_repo_name, repository=repository, - checksums=[{ - f'{mock_repo_name}.tar.gz': { - 'checksum': CHECKSUM, - 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa - }, - }], + checksums=[ + { + f'{mock_repo_name}.tar.gz': { + 'checksum': CHECKSUM, + 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa + }, + } + ], install=INSTALL, tar_url=mock_tar_url, depends_on=None, @@ -158,12 +174,14 @@ def test_generate_formula_formula_name_starts_description(): owner=USERNAME, repo_name=mock_repo_name, repository=repository, - checksums=[{ - f'{mock_repo_name}.tar.gz': { - 'checksum': CHECKSUM, - 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa - }, - }], + checksums=[ + { + f'{mock_repo_name}.tar.gz': { + 'checksum': CHECKSUM, + 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa + }, + } + ], install=INSTALL, tar_url=mock_tar_url, depends_on=None, @@ -193,12 +211,14 @@ def test_generate_formula_no_depends_on(): owner=USERNAME, repo_name=mock_repo_name, repository=repository, - checksums=[{ - f'{mock_repo_name}.tar.gz': { - 'checksum': CHECKSUM, - 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa - }, - }], + checksums=[ + { + f'{mock_repo_name}.tar.gz': { + 'checksum': CHECKSUM, + 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa + }, + } + ], install=INSTALL, tar_url=mock_tar_url, depends_on=None, @@ -228,12 +248,14 @@ def test_generate_formula_no_test(): owner=USERNAME, repo_name=mock_repo_name, repository=repository, - checksums=[{ - f'{mock_repo_name}.tar.gz': { - 'checksum': CHECKSUM, - 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa - }, - }], + checksums=[ + { + f'{mock_repo_name}.tar.gz': { + 'checksum': CHECKSUM, + 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa + }, + } + ], install=INSTALL, tar_url=mock_tar_url, depends_on=DEPENDS_ON, @@ -501,12 +523,14 @@ def test_generate_formula_string_false_configs(): owner=USERNAME, repo_name=mock_repo_name, repository=repository, - checksums=[{ - f'{mock_repo_name}.tar.gz': { - 'checksum': CHECKSUM, - 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa - }, - }], + checksums=[ + { + f'{mock_repo_name}.tar.gz': { + 'checksum': CHECKSUM, + 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa + }, + } + ], install=INSTALL, tar_url=mock_tar_url, depends_on=None, @@ -538,12 +562,14 @@ def test_generate_formula_empty_fields(): owner=USERNAME, repo_name=mock_repo_name, repository=repository, - checksums=[{ - f'{mock_repo_name}.tar.gz': { - 'checksum': CHECKSUM, - 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa - }, - }], + checksums=[ + { + f'{mock_repo_name}.tar.gz': { + 'checksum': CHECKSUM, + 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa + }, + } + ], install=INSTALL, tar_url=mock_tar_url, depends_on=None, @@ -642,12 +668,14 @@ def test_generate_formula_override_version(): owner=USERNAME, repo_name=mock_repo_name, repository=repository, - checksums=[{ - f'{mock_repo_name}.tar.gz': { - 'checksum': CHECKSUM, - 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa - }, - }], + checksums=[ + { + f'{mock_repo_name}.tar.gz': { + 'checksum': CHECKSUM, + 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa + }, + } + ], install=INSTALL, tar_url=mock_tar_url, version='9.8.7', diff --git a/test/unit/test_git.py b/test/unit/test_git.py index 19fcdeb..2ef9a99 100644 --- a/test/unit/test_git.py +++ b/test/unit/test_git.py @@ -19,31 +19,33 @@ def test_setup(mock_subprocess): commit_email = 'user@example.com' Git.setup(homebrew_owner, commit_email, homebrew_owner, homebrew_tap) - mock_subprocess.assert_has_calls([ - call( - [ - 'git', - 'clone', - '--depth=1', - 'https://x-access-token:123@github.com/Justintime50/homebrew-formulas.git', - ], - stderr=-2, - text=True, - timeout=30, - ), - call( - ['git', '-C', 'homebrew-formulas', 'config', 'user.name', '"Justintime50"'], - stderr=-2, - text=True, - timeout=30, - ), - call( - ['git', '-C', 'homebrew-formulas', 'config', 'user.email', 'user@example.com'], - stderr=-2, - text=True, - timeout=30, - ), - ]) + mock_subprocess.assert_has_calls( + [ + call( + [ + 'git', + 'clone', + '--depth=1', + 'https://x-access-token:123@github.com/Justintime50/homebrew-formulas.git', + ], + stderr=-2, + text=True, + timeout=30, + ), + call( + ['git', '-C', 'homebrew-formulas', 'config', 'user.name', '"Justintime50"'], + stderr=-2, + text=True, + timeout=30, + ), + call( + ['git', '-C', 'homebrew-formulas', 'config', 'user.email', 'user@example.com'], + stderr=-2, + text=True, + timeout=30, + ), + ] + ) @patch('subprocess.check_output') From abafde2e6d984e340bf2ab8a5fa20da4521131fb Mon Sep 17 00:00:00 2001 From: unfrgivn Date: Tue, 9 Jul 2024 17:26:16 -0500 Subject: [PATCH 06/12] refactor: move include above the metadata per Homebrew docs --- homebrew_releaser/formula.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homebrew_releaser/formula.py b/homebrew_releaser/formula.py index 918b0de..dc6521e 100644 --- a/homebrew_releaser/formula.py +++ b/homebrew_releaser/formula.py @@ -128,6 +128,8 @@ def generate_formula_data( # This file was generated by Homebrew Releaser. DO NOT EDIT. class {{class_name}} < Formula + {{{formula_includes}}} + desc "{{description}}" homepage "https://github.com/{{owner}}/{{repo_name}}" url "{{tar_url}}"{{# download_strategy}}, using: {{download_strategy}}{{/ download_strategy}} @@ -139,8 +141,6 @@ class {{class_name}} < Formula license "{{license_type}}" {{/ license_type}} - {{{formula_includes}}} - {{# dependencies}} depends_on {{{dependency}}} {{/ dependencies}} From 99927935534b07e3a6073b340b9c0611476968be Mon Sep 17 00:00:00 2001 From: unfrgivn Date: Tue, 9 Jul 2024 18:09:26 -0500 Subject: [PATCH 07/12] test: add test scenario for formula_includes --- test/unit/test_formula.py | 44 ++++++++++++++++++++++++++++++++ test/unit/test_readme_updater.py | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/test/unit/test_formula.py b/test/unit/test_formula.py index bfdc8d4..cc212c1 100644 --- a/test/unit/test_formula.py +++ b/test/unit/test_formula.py @@ -684,3 +684,47 @@ def test_generate_formula_override_version(): record_formula(formula_path, formula_filename, formula) assert '9.8.7' in formula + + +def test_generate_formula_formula_includes(): + """Tests that we generate the formula content correctly when all parameters are passed + (except a matrix so that we can test the auto-generate URL/checksum from GitHub). + + NOTE: See docstring in `record_formula` for more details on how recording formulas works. + """ + formula_filename = f'{inspect.stack()[0][3]}.rb' + mock_repo_name = formula_filename.replace('_', '-').replace('.rb', '') + mock_tar_url = f'https://github.com/{USERNAME}/{mock_repo_name}/archive/refs/tags/v0.1.0.tar.gz' + + repository = { + # We use a badly written description string here on purpose to test our formatting code, this includes: + # - starting with an article + # - punctuation + # - trailing whitespace + # - extra capitilization + 'description': 'A tool to release... scripts, binaries, and executables to GitHub. ', + 'license': LICENSE, + } + + formula = Formula.generate_formula_data( + owner=USERNAME, + repo_name=mock_repo_name, + repository=repository, + checksums=[ + { + f'{mock_repo_name}.tar.gz': { + 'checksum': CHECKSUM, + 'url': f'https://github.com/justintime50/{mock_repo_name}/releases/download/{VERSION}/{mock_repo_name}-{VERSION}.tar.gz', # noqa + }, + } + ], + install=INSTALL, + tar_url=mock_tar_url, + depends_on=DEPENDS_ON, + test=TEST, + formula_includes='include Language::Python::Virtualenv', + ) + + record_formula(formula_path, formula_filename, formula) + + assert 'include Language::Python::Virtualenv' in formula diff --git a/test/unit/test_readme_updater.py b/test/unit/test_readme_updater.py index 9c72494..8d91211 100644 --- a/test/unit/test_readme_updater.py +++ b/test/unit/test_readme_updater.py @@ -75,7 +75,7 @@ def test_format_formula_data(): """ formulas = ReadmeUpdater.format_formula_data('./test') - assert len(formulas) == 13 + assert len(formulas) == 14 assert formulas[0] == { 'name': 'test-generate-formula', 'desc': 'Tool to release scripts, binaries, and executables to github', From 9d3bb3c5e1f5c875736efc2ac0c8fea0c64beb95 Mon Sep 17 00:00:00 2001 From: unfrgivn Date: Tue, 9 Jul 2024 18:09:56 -0500 Subject: [PATCH 08/12] style: rebuild test formulas --- test/formulas/test_generate_formula.rb | 2 ++ .../test_generate_formula_complete_matrix.rb | 2 ++ .../test_generate_formula_darwin_matrix.rb | 2 ++ ...test_generate_formula_download_strategy.rb | 2 ++ .../test_generate_formula_empty_fields.rb | 2 ++ .../test_generate_formula_formula_includes.rb | 24 +++++++++++++++++++ ...formula_formula_name_starts_description.rb | 2 ++ .../test_generate_formula_linux_matrix.rb | 2 ++ ...generate_formula_no_article_description.rb | 2 ++ .../test_generate_formula_no_depends_on.rb | 2 ++ .../formulas/test_generate_formula_no_test.rb | 2 ++ .../test_generate_formula_override_version.rb | 2 ++ ...t_generate_formula_string_false_configs.rb | 2 ++ test/formulas/test_one_of_each_matrix.rb | 2 ++ 14 files changed, 50 insertions(+) create mode 100644 test/formulas/test_generate_formula_formula_includes.rb diff --git a/test/formulas/test_generate_formula.rb b/test/formulas/test_generate_formula.rb index 459474c..807a6d8 100644 --- a/test/formulas/test_generate_formula.rb +++ b/test/formulas/test_generate_formula.rb @@ -3,6 +3,8 @@ # This file was generated by Homebrew Releaser. DO NOT EDIT. class TestGenerateFormula < Formula + + desc "Tool to release scripts, binaries, and executables to github" homepage "https://github.com/Justintime50/test-generate-formula" url "https://github.com/Justintime50/test-generate-formula/archive/refs/tags/v0.1.0.tar.gz" diff --git a/test/formulas/test_generate_formula_complete_matrix.rb b/test/formulas/test_generate_formula_complete_matrix.rb index 29ac255..291341b 100644 --- a/test/formulas/test_generate_formula_complete_matrix.rb +++ b/test/formulas/test_generate_formula_complete_matrix.rb @@ -3,6 +3,8 @@ # This file was generated by Homebrew Releaser. DO NOT EDIT. class TestGenerateFormulaCompleteMatrix < Formula + + desc "Release scripts, binaries, and executables to github" homepage "https://github.com/Justintime50/test-generate-formula-complete-matrix" url "https://github.com/Justintime50/test-generate-formula-complete-matrix/archive/refs/tags/v0.1.0.tar.gz" diff --git a/test/formulas/test_generate_formula_darwin_matrix.rb b/test/formulas/test_generate_formula_darwin_matrix.rb index 1868346..6faf346 100644 --- a/test/formulas/test_generate_formula_darwin_matrix.rb +++ b/test/formulas/test_generate_formula_darwin_matrix.rb @@ -3,6 +3,8 @@ # This file was generated by Homebrew Releaser. DO NOT EDIT. class TestGenerateFormulaDarwinMatrix < Formula + + desc "Release scripts, binaries, and executables to github" homepage "https://github.com/Justintime50/test-generate-formula-darwin-matrix" url "https://github.com/Justintime50/test-generate-formula-darwin-matrix/archive/refs/tags/v0.1.0.tar.gz" diff --git a/test/formulas/test_generate_formula_download_strategy.rb b/test/formulas/test_generate_formula_download_strategy.rb index 6a0f449..a3ac70f 100644 --- a/test/formulas/test_generate_formula_download_strategy.rb +++ b/test/formulas/test_generate_formula_download_strategy.rb @@ -5,6 +5,8 @@ # This file was generated by Homebrew Releaser. DO NOT EDIT. class TestGenerateFormulaDownloadStrategy < Formula + + desc "Release scripts, binaries, and executables to github" homepage "https://github.com/Justintime50/test-generate-formula-download-strategy" url "https://github.com/Justintime50/test-generate-formula-download-strategy/archive/refs/tags/v0.1.0.tar.gz", using: CustomDownloadStrategy diff --git a/test/formulas/test_generate_formula_empty_fields.rb b/test/formulas/test_generate_formula_empty_fields.rb index ccc214b..dbb09a9 100644 --- a/test/formulas/test_generate_formula_empty_fields.rb +++ b/test/formulas/test_generate_formula_empty_fields.rb @@ -3,6 +3,8 @@ # This file was generated by Homebrew Releaser. DO NOT EDIT. class TestGenerateFormulaEmptyFields < Formula + + desc "NA" homepage "https://github.com/Justintime50/test-generate-formula-empty-fields" url "https://github.com/Justintime50/test-generate-formula-empty-fields/archive/refs/tags/v0.1.0.tar.gz" diff --git a/test/formulas/test_generate_formula_formula_includes.rb b/test/formulas/test_generate_formula_formula_includes.rb new file mode 100644 index 0000000..e2b74e1 --- /dev/null +++ b/test/formulas/test_generate_formula_formula_includes.rb @@ -0,0 +1,24 @@ +# typed: true +# frozen_string_literal: true + +# This file was generated by Homebrew Releaser. DO NOT EDIT. +class TestGenerateFormulaFormulaIncludes < Formula + include Language::Python::Virtualenv + + desc "Tool to release scripts, binaries, and executables to github" + homepage "https://github.com/Justintime50/test-generate-formula-formula-includes" + url "https://github.com/Justintime50/test-generate-formula-formula-includes/archive/refs/tags/v0.1.0.tar.gz" + sha256 "0000000000000000000000000000000000000000000000000000000000000000" + license "MIT" + + depends_on "bash" => :build + depends_on "gcc" + + def install + bin.install "src/secure-browser-kiosk.sh" => "secure-browser-kiosk" + end + + test do + assert_match("my script output", shell_output("my-script-command")) + end +end diff --git a/test/formulas/test_generate_formula_formula_name_starts_description.rb b/test/formulas/test_generate_formula_formula_name_starts_description.rb index a383ca0..1555547 100644 --- a/test/formulas/test_generate_formula_formula_name_starts_description.rb +++ b/test/formulas/test_generate_formula_formula_name_starts_description.rb @@ -3,6 +3,8 @@ # This file was generated by Homebrew Releaser. DO NOT EDIT. class TestGenerateFormulaFormulaNameStartsDescription < Formula + + desc "Is a tool" homepage "https://github.com/Justintime50/test-generate-formula-formula-name-starts-description" url "https://github.com/Justintime50/test-generate-formula-formula-name-starts-description/archive/refs/tags/v0.1.0.tar.gz" diff --git a/test/formulas/test_generate_formula_linux_matrix.rb b/test/formulas/test_generate_formula_linux_matrix.rb index 12f7dac..30fedc9 100644 --- a/test/formulas/test_generate_formula_linux_matrix.rb +++ b/test/formulas/test_generate_formula_linux_matrix.rb @@ -3,6 +3,8 @@ # This file was generated by Homebrew Releaser. DO NOT EDIT. class TestGenerateFormulaLinuxMatrix < Formula + + desc "Release scripts, binaries, and executables to github" homepage "https://github.com/Justintime50/test-generate-formula-linux-matrix" url "https://github.com/Justintime50/test-generate-formula-linux-matrix/archive/refs/tags/v0.1.0.tar.gz" diff --git a/test/formulas/test_generate_formula_no_article_description.rb b/test/formulas/test_generate_formula_no_article_description.rb index 9b57d56..f8a9262 100644 --- a/test/formulas/test_generate_formula_no_article_description.rb +++ b/test/formulas/test_generate_formula_no_article_description.rb @@ -3,6 +3,8 @@ # This file was generated by Homebrew Releaser. DO NOT EDIT. class TestGenerateFormulaNoArticleDescription < Formula + + desc "Release scripts, binaries, and executables to github" homepage "https://github.com/Justintime50/test-generate-formula-no-article-description" url "https://github.com/Justintime50/test-generate-formula-no-article-description/archive/refs/tags/v0.1.0.tar.gz" diff --git a/test/formulas/test_generate_formula_no_depends_on.rb b/test/formulas/test_generate_formula_no_depends_on.rb index be64fa5..0979219 100644 --- a/test/formulas/test_generate_formula_no_depends_on.rb +++ b/test/formulas/test_generate_formula_no_depends_on.rb @@ -3,6 +3,8 @@ # This file was generated by Homebrew Releaser. DO NOT EDIT. class TestGenerateFormulaNoDependsOn < Formula + + desc "Release scripts, binaries, and executables to github" homepage "https://github.com/Justintime50/test-generate-formula-no-depends-on" url "https://github.com/Justintime50/test-generate-formula-no-depends-on/archive/refs/tags/v0.1.0.tar.gz" diff --git a/test/formulas/test_generate_formula_no_test.rb b/test/formulas/test_generate_formula_no_test.rb index 5f86452..577d3c8 100644 --- a/test/formulas/test_generate_formula_no_test.rb +++ b/test/formulas/test_generate_formula_no_test.rb @@ -3,6 +3,8 @@ # This file was generated by Homebrew Releaser. DO NOT EDIT. class TestGenerateFormulaNoTest < Formula + + desc "Release scripts, binaries, and executables to github" homepage "https://github.com/Justintime50/test-generate-formula-no-test" url "https://github.com/Justintime50/test-generate-formula-no-test/archive/refs/tags/v0.1.0.tar.gz" diff --git a/test/formulas/test_generate_formula_override_version.rb b/test/formulas/test_generate_formula_override_version.rb index 9d376ff..d8f9de5 100644 --- a/test/formulas/test_generate_formula_override_version.rb +++ b/test/formulas/test_generate_formula_override_version.rb @@ -3,6 +3,8 @@ # This file was generated by Homebrew Releaser. DO NOT EDIT. class TestGenerateFormulaOverrideVersion < Formula + + desc "Release scripts, binaries, and executables to github" homepage "https://github.com/Justintime50/test-generate-formula-override-version" url "https://github.com/Justintime50/test-generate-formula-override-version/archive/refs/tags/v0.1.0.tar.gz" diff --git a/test/formulas/test_generate_formula_string_false_configs.rb b/test/formulas/test_generate_formula_string_false_configs.rb index 4a3289a..2df06d0 100644 --- a/test/formulas/test_generate_formula_string_false_configs.rb +++ b/test/formulas/test_generate_formula_string_false_configs.rb @@ -3,6 +3,8 @@ # This file was generated by Homebrew Releaser. DO NOT EDIT. class TestGenerateFormulaStringFalseConfigs < Formula + + desc "Release scripts, binaries, and executables to github" homepage "https://github.com/Justintime50/test-generate-formula-string-false-configs" url "https://github.com/Justintime50/test-generate-formula-string-false-configs/archive/refs/tags/v0.1.0.tar.gz" diff --git a/test/formulas/test_one_of_each_matrix.rb b/test/formulas/test_one_of_each_matrix.rb index 6773346..67f82bd 100644 --- a/test/formulas/test_one_of_each_matrix.rb +++ b/test/formulas/test_one_of_each_matrix.rb @@ -3,6 +3,8 @@ # This file was generated by Homebrew Releaser. DO NOT EDIT. class TestOneOfEachMatrix < Formula + + desc "Release scripts, binaries, and executables to github" homepage "https://github.com/Justintime50/test-one-of-each-matrix" url "https://github.com/Justintime50/test-one-of-each-matrix/archive/refs/tags/v0.1.0.tar.gz" From f84f6861ff6036930abb7711d619d23c824cd119 Mon Sep 17 00:00:00 2001 From: unfrgivn Date: Tue, 9 Jul 2024 18:18:44 -0500 Subject: [PATCH 09/12] fix: strict typing on formula_includes param --- homebrew_releaser/formula.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homebrew_releaser/formula.py b/homebrew_releaser/formula.py index dc6521e..6d7eedc 100644 --- a/homebrew_releaser/formula.py +++ b/homebrew_releaser/formula.py @@ -31,7 +31,7 @@ def generate_formula_data( test: Optional[str] = None, download_strategy: Optional[str] = None, custom_require: Optional[str] = None, - formula_includes: str = None, + formula_includes: Optional[str] = None, version: Optional[str] = None, ) -> str: """Generates the formula data for Homebrew. From b4d453dbc4a6bfe233d7663c9ff6132733b4ee0b Mon Sep 17 00:00:00 2001 From: unfrgivn Date: Tue, 9 Jul 2024 18:26:56 -0500 Subject: [PATCH 10/12] fix: remove whitespace if no formula_includes --- homebrew_releaser/formula.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/homebrew_releaser/formula.py b/homebrew_releaser/formula.py index 6d7eedc..6235a37 100644 --- a/homebrew_releaser/formula.py +++ b/homebrew_releaser/formula.py @@ -128,8 +128,10 @@ def generate_formula_data( # This file was generated by Homebrew Releaser. DO NOT EDIT. class {{class_name}} < Formula + {{# formula_includes}} {{{formula_includes}}} + {{/ formula_includes}} desc "{{description}}" homepage "https://github.com/{{owner}}/{{repo_name}}" url "{{tar_url}}"{{# download_strategy}}, using: {{download_strategy}}{{/ download_strategy}} From c143df24df84ce4721dc5a8984c4a64629c10173 Mon Sep 17 00:00:00 2001 From: unfrgivn Date: Tue, 9 Jul 2024 18:40:54 -0500 Subject: [PATCH 11/12] style: rebuild test formulas --- test/formulas/test_generate_formula.rb | 2 -- test/formulas/test_generate_formula_complete_matrix.rb | 2 -- test/formulas/test_generate_formula_darwin_matrix.rb | 2 -- test/formulas/test_generate_formula_download_strategy.rb | 2 -- test/formulas/test_generate_formula_empty_fields.rb | 2 -- .../test_generate_formula_formula_name_starts_description.rb | 2 -- test/formulas/test_generate_formula_linux_matrix.rb | 2 -- test/formulas/test_generate_formula_no_article_description.rb | 2 -- test/formulas/test_generate_formula_no_depends_on.rb | 2 -- test/formulas/test_generate_formula_no_test.rb | 2 -- test/formulas/test_generate_formula_override_version.rb | 2 -- test/formulas/test_generate_formula_string_false_configs.rb | 2 -- test/formulas/test_one_of_each_matrix.rb | 2 -- 13 files changed, 26 deletions(-) diff --git a/test/formulas/test_generate_formula.rb b/test/formulas/test_generate_formula.rb index 807a6d8..459474c 100644 --- a/test/formulas/test_generate_formula.rb +++ b/test/formulas/test_generate_formula.rb @@ -3,8 +3,6 @@ # This file was generated by Homebrew Releaser. DO NOT EDIT. class TestGenerateFormula < Formula - - desc "Tool to release scripts, binaries, and executables to github" homepage "https://github.com/Justintime50/test-generate-formula" url "https://github.com/Justintime50/test-generate-formula/archive/refs/tags/v0.1.0.tar.gz" diff --git a/test/formulas/test_generate_formula_complete_matrix.rb b/test/formulas/test_generate_formula_complete_matrix.rb index 291341b..29ac255 100644 --- a/test/formulas/test_generate_formula_complete_matrix.rb +++ b/test/formulas/test_generate_formula_complete_matrix.rb @@ -3,8 +3,6 @@ # This file was generated by Homebrew Releaser. DO NOT EDIT. class TestGenerateFormulaCompleteMatrix < Formula - - desc "Release scripts, binaries, and executables to github" homepage "https://github.com/Justintime50/test-generate-formula-complete-matrix" url "https://github.com/Justintime50/test-generate-formula-complete-matrix/archive/refs/tags/v0.1.0.tar.gz" diff --git a/test/formulas/test_generate_formula_darwin_matrix.rb b/test/formulas/test_generate_formula_darwin_matrix.rb index 6faf346..1868346 100644 --- a/test/formulas/test_generate_formula_darwin_matrix.rb +++ b/test/formulas/test_generate_formula_darwin_matrix.rb @@ -3,8 +3,6 @@ # This file was generated by Homebrew Releaser. DO NOT EDIT. class TestGenerateFormulaDarwinMatrix < Formula - - desc "Release scripts, binaries, and executables to github" homepage "https://github.com/Justintime50/test-generate-formula-darwin-matrix" url "https://github.com/Justintime50/test-generate-formula-darwin-matrix/archive/refs/tags/v0.1.0.tar.gz" diff --git a/test/formulas/test_generate_formula_download_strategy.rb b/test/formulas/test_generate_formula_download_strategy.rb index a3ac70f..6a0f449 100644 --- a/test/formulas/test_generate_formula_download_strategy.rb +++ b/test/formulas/test_generate_formula_download_strategy.rb @@ -5,8 +5,6 @@ # This file was generated by Homebrew Releaser. DO NOT EDIT. class TestGenerateFormulaDownloadStrategy < Formula - - desc "Release scripts, binaries, and executables to github" homepage "https://github.com/Justintime50/test-generate-formula-download-strategy" url "https://github.com/Justintime50/test-generate-formula-download-strategy/archive/refs/tags/v0.1.0.tar.gz", using: CustomDownloadStrategy diff --git a/test/formulas/test_generate_formula_empty_fields.rb b/test/formulas/test_generate_formula_empty_fields.rb index dbb09a9..ccc214b 100644 --- a/test/formulas/test_generate_formula_empty_fields.rb +++ b/test/formulas/test_generate_formula_empty_fields.rb @@ -3,8 +3,6 @@ # This file was generated by Homebrew Releaser. DO NOT EDIT. class TestGenerateFormulaEmptyFields < Formula - - desc "NA" homepage "https://github.com/Justintime50/test-generate-formula-empty-fields" url "https://github.com/Justintime50/test-generate-formula-empty-fields/archive/refs/tags/v0.1.0.tar.gz" diff --git a/test/formulas/test_generate_formula_formula_name_starts_description.rb b/test/formulas/test_generate_formula_formula_name_starts_description.rb index 1555547..a383ca0 100644 --- a/test/formulas/test_generate_formula_formula_name_starts_description.rb +++ b/test/formulas/test_generate_formula_formula_name_starts_description.rb @@ -3,8 +3,6 @@ # This file was generated by Homebrew Releaser. DO NOT EDIT. class TestGenerateFormulaFormulaNameStartsDescription < Formula - - desc "Is a tool" homepage "https://github.com/Justintime50/test-generate-formula-formula-name-starts-description" url "https://github.com/Justintime50/test-generate-formula-formula-name-starts-description/archive/refs/tags/v0.1.0.tar.gz" diff --git a/test/formulas/test_generate_formula_linux_matrix.rb b/test/formulas/test_generate_formula_linux_matrix.rb index 30fedc9..12f7dac 100644 --- a/test/formulas/test_generate_formula_linux_matrix.rb +++ b/test/formulas/test_generate_formula_linux_matrix.rb @@ -3,8 +3,6 @@ # This file was generated by Homebrew Releaser. DO NOT EDIT. class TestGenerateFormulaLinuxMatrix < Formula - - desc "Release scripts, binaries, and executables to github" homepage "https://github.com/Justintime50/test-generate-formula-linux-matrix" url "https://github.com/Justintime50/test-generate-formula-linux-matrix/archive/refs/tags/v0.1.0.tar.gz" diff --git a/test/formulas/test_generate_formula_no_article_description.rb b/test/formulas/test_generate_formula_no_article_description.rb index f8a9262..9b57d56 100644 --- a/test/formulas/test_generate_formula_no_article_description.rb +++ b/test/formulas/test_generate_formula_no_article_description.rb @@ -3,8 +3,6 @@ # This file was generated by Homebrew Releaser. DO NOT EDIT. class TestGenerateFormulaNoArticleDescription < Formula - - desc "Release scripts, binaries, and executables to github" homepage "https://github.com/Justintime50/test-generate-formula-no-article-description" url "https://github.com/Justintime50/test-generate-formula-no-article-description/archive/refs/tags/v0.1.0.tar.gz" diff --git a/test/formulas/test_generate_formula_no_depends_on.rb b/test/formulas/test_generate_formula_no_depends_on.rb index 0979219..be64fa5 100644 --- a/test/formulas/test_generate_formula_no_depends_on.rb +++ b/test/formulas/test_generate_formula_no_depends_on.rb @@ -3,8 +3,6 @@ # This file was generated by Homebrew Releaser. DO NOT EDIT. class TestGenerateFormulaNoDependsOn < Formula - - desc "Release scripts, binaries, and executables to github" homepage "https://github.com/Justintime50/test-generate-formula-no-depends-on" url "https://github.com/Justintime50/test-generate-formula-no-depends-on/archive/refs/tags/v0.1.0.tar.gz" diff --git a/test/formulas/test_generate_formula_no_test.rb b/test/formulas/test_generate_formula_no_test.rb index 577d3c8..5f86452 100644 --- a/test/formulas/test_generate_formula_no_test.rb +++ b/test/formulas/test_generate_formula_no_test.rb @@ -3,8 +3,6 @@ # This file was generated by Homebrew Releaser. DO NOT EDIT. class TestGenerateFormulaNoTest < Formula - - desc "Release scripts, binaries, and executables to github" homepage "https://github.com/Justintime50/test-generate-formula-no-test" url "https://github.com/Justintime50/test-generate-formula-no-test/archive/refs/tags/v0.1.0.tar.gz" diff --git a/test/formulas/test_generate_formula_override_version.rb b/test/formulas/test_generate_formula_override_version.rb index d8f9de5..9d376ff 100644 --- a/test/formulas/test_generate_formula_override_version.rb +++ b/test/formulas/test_generate_formula_override_version.rb @@ -3,8 +3,6 @@ # This file was generated by Homebrew Releaser. DO NOT EDIT. class TestGenerateFormulaOverrideVersion < Formula - - desc "Release scripts, binaries, and executables to github" homepage "https://github.com/Justintime50/test-generate-formula-override-version" url "https://github.com/Justintime50/test-generate-formula-override-version/archive/refs/tags/v0.1.0.tar.gz" diff --git a/test/formulas/test_generate_formula_string_false_configs.rb b/test/formulas/test_generate_formula_string_false_configs.rb index 2df06d0..4a3289a 100644 --- a/test/formulas/test_generate_formula_string_false_configs.rb +++ b/test/formulas/test_generate_formula_string_false_configs.rb @@ -3,8 +3,6 @@ # This file was generated by Homebrew Releaser. DO NOT EDIT. class TestGenerateFormulaStringFalseConfigs < Formula - - desc "Release scripts, binaries, and executables to github" homepage "https://github.com/Justintime50/test-generate-formula-string-false-configs" url "https://github.com/Justintime50/test-generate-formula-string-false-configs/archive/refs/tags/v0.1.0.tar.gz" diff --git a/test/formulas/test_one_of_each_matrix.rb b/test/formulas/test_one_of_each_matrix.rb index 67f82bd..6773346 100644 --- a/test/formulas/test_one_of_each_matrix.rb +++ b/test/formulas/test_one_of_each_matrix.rb @@ -3,8 +3,6 @@ # This file was generated by Homebrew Releaser. DO NOT EDIT. class TestOneOfEachMatrix < Formula - - desc "Release scripts, binaries, and executables to github" homepage "https://github.com/Justintime50/test-one-of-each-matrix" url "https://github.com/Justintime50/test-one-of-each-matrix/archive/refs/tags/v0.1.0.tar.gz" From ea5c8c69c50557c6bc95b7ece1abff4a34ba7ea6 Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Thu, 11 Jul 2024 11:22:38 -0600 Subject: [PATCH 12/12] chore: cleanup new test --- .../test_generate_formula_formula_includes.rb | 9 +-------- test/unit/test_formula.py | 12 ++---------- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/test/formulas/test_generate_formula_formula_includes.rb b/test/formulas/test_generate_formula_formula_includes.rb index e2b74e1..d9f8ee0 100644 --- a/test/formulas/test_generate_formula_formula_includes.rb +++ b/test/formulas/test_generate_formula_formula_includes.rb @@ -5,20 +5,13 @@ class TestGenerateFormulaFormulaIncludes < Formula include Language::Python::Virtualenv - desc "Tool to release scripts, binaries, and executables to github" + desc "Release scripts, binaries, and executables to github" homepage "https://github.com/Justintime50/test-generate-formula-formula-includes" url "https://github.com/Justintime50/test-generate-formula-formula-includes/archive/refs/tags/v0.1.0.tar.gz" sha256 "0000000000000000000000000000000000000000000000000000000000000000" license "MIT" - depends_on "bash" => :build - depends_on "gcc" - def install bin.install "src/secure-browser-kiosk.sh" => "secure-browser-kiosk" end - - test do - assert_match("my script output", shell_output("my-script-command")) - end end diff --git a/test/unit/test_formula.py b/test/unit/test_formula.py index cc212c1..771131d 100644 --- a/test/unit/test_formula.py +++ b/test/unit/test_formula.py @@ -687,8 +687,7 @@ def test_generate_formula_override_version(): def test_generate_formula_formula_includes(): - """Tests that we generate the formula content correctly when all parameters are passed - (except a matrix so that we can test the auto-generate URL/checksum from GitHub). + """Tests that we generate the formula content correctly when using the formula_includes param. NOTE: See docstring in `record_formula` for more details on how recording formulas works. """ @@ -697,12 +696,7 @@ def test_generate_formula_formula_includes(): mock_tar_url = f'https://github.com/{USERNAME}/{mock_repo_name}/archive/refs/tags/v0.1.0.tar.gz' repository = { - # We use a badly written description string here on purpose to test our formatting code, this includes: - # - starting with an article - # - punctuation - # - trailing whitespace - # - extra capitilization - 'description': 'A tool to release... scripts, binaries, and executables to GitHub. ', + 'description': DESCRIPTION, 'license': LICENSE, } @@ -720,8 +714,6 @@ def test_generate_formula_formula_includes(): ], install=INSTALL, tar_url=mock_tar_url, - depends_on=DEPENDS_ON, - test=TEST, formula_includes='include Language::Python::Virtualenv', )