Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ permissions: {}

on:
pull_request:
branches:
- master
types:
- opened
- synchronize
- reopened
push:
branches:
- master
Expand Down
10 changes: 2 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ permissions: {}

on:
pull_request:
branches:
- master
types:
- opened
- synchronize
- reopened
push:
branches:
- master
Expand Down Expand Up @@ -75,13 +69,13 @@ jobs:
- name: Process variables in with parameters
id: process-with
env:
ENV_GH_BOT_NAME: ${{ vars.GH_BOT_NAME }}
ENV_GITHUB_EVENT_PR_NUMBER: ${{ github.event.pull_request.number }}
ENV_GITHUB_EVENT_REPO_HTML_URL: ${{ github.event.repository.html_url }}
ENV_GITHUB_EVENT_REPO_NAME: ${{ github.event.repository.name }}
SECRETS_FACEBOOK_ACCESS_TOKEN: ${{ secrets.FACEBOOK_ACCESS_TOKEN }}
SECRETS_FACEBOOK_PAGE_ID: ${{ secrets.FACEBOOK_PAGE_ID }}
SECRETS_GH_BOT_EMAIL: ${{ secrets.GH_BOT_EMAIL }}
SECRETS_GH_BOT_NAME: ${{ secrets.GH_BOT_NAME }}
SECRETS_GH_BOT_TOKEN: ${{ secrets.GH_BOT_TOKEN }}
SECRETS_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SECRETS_VIRUSTOTAL_API_KEY: ${{ secrets.VIRUSTOTAL_API_KEY }}
Expand All @@ -97,13 +91,13 @@ jobs:
-e "s|\${ github.run_id }|${GITHUB_RUN_ID}|g" \
-e "s|\${ github.workspace }|${GITHUB_WORKSPACE}|g" \
-e "s|\${ runner.os }|${RUNNER_OS}|g" \
-e "s|\${ vars.GH_BOT_NAME }|${ENV_GH_BOT_NAME}|g" \
-e "s|\${ github.event.pull_request.number }|${ENV_GITHUB_EVENT_PR_NUMBER}|g" \
-e "s|\${ github.event.repository.html_url }|${ENV_GITHUB_EVENT_REPO_HTML_URL}|g" \
-e "s|\${ github.event.repository.name }|${ENV_GITHUB_EVENT_REPO_NAME}|g" \
-e "s|\${ secrets.FACEBOOK_ACCESS_TOKEN }|${SECRETS_FACEBOOK_ACCESS_TOKEN}|g" \
-e "s|\${ secrets.FACEBOOK_PAGE_ID }|${SECRETS_FACEBOOK_PAGE_ID}|g" \
-e "s|\${ secrets.GH_BOT_EMAIL }|${SECRETS_GH_BOT_EMAIL}|g" \
-e "s|\${ secrets.GH_BOT_NAME }|${SECRETS_GH_BOT_NAME}|g" \
-e "s|\${ secrets.GH_BOT_TOKEN }|${SECRETS_GH_BOT_TOKEN}|g" \
-e "s|\${ secrets.GITHUB_TOKEN }|${SECRETS_GITHUB_TOKEN}|g" \
-e "s|\${ secrets.VIRUSTOTAL_API_KEY }|${SECRETS_VIRUSTOTAL_API_KEY}|g" \
Expand Down
1 change: 1 addition & 0 deletions actions/release_homebrew/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ steps:

| Name | Description | Default | Required |
|-------------------------------|-------------------------------------------------------------------------------------------|--------------------------------|----------|
| actionlint_config | Contents of actionlint config file, used to override the default brew config. | | `false` |
| contribute_to_homebrew_core | Whether to contribute to homebrew-core. | `false` | `false` |
| formula_file | The full path to the formula file. | | `true` |
| git_email | The email to use for the commit. | | `true` |
Expand Down
5 changes: 5 additions & 0 deletions actions/release_homebrew/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ branding:
color: green

inputs:
actionlint_config:
description: 'Contents of actionlint config file, used to override the default brew config.'
default: ''
required: false
contribute_to_homebrew_core:
description: 'Whether to contribute to homebrew-core.'
default: 'false'
Expand Down Expand Up @@ -164,6 +168,7 @@ runs:

- name: Homebrew tests
env:
INPUT_ACTIONLINT_CONFIG: ${{ inputs.actionlint_config }}
INPUT_FORMULA_FILE: ${{ inputs.formula_file }}
INPUT_CONTRIBUTE_TO_HOMEBREW_CORE: ${{ inputs.contribute_to_homebrew_core }}
INPUT_GIT_EMAIL: ${{ inputs.git_email }}
Expand Down
9 changes: 6 additions & 3 deletions actions/release_homebrew/ci-matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
{
"runs-on": "macos-latest",
"with": {
"actionlint_config": "---\n# empty config",
"contribute_to_homebrew_core": true,
"formula_file": "${ github.workspace }/tests/release_homebrew/Formula/hello_world.rb",
"git_email": "${ secrets.GH_BOT_EMAIL }",
"git_username": "${ secrets.GH_BOT_NAME }",
"git_username": "${ vars.GH_BOT_NAME }",
"org_homebrew_repo": "LizardByte/homebrew-homebrew",
"org_homebrew_repo_base_branch": "master",
"publish": false,
Expand All @@ -16,10 +17,11 @@
{
"runs-on": "ubuntu-latest",
"with": {
"actionlint_config": "---\n# empty config",
"contribute_to_homebrew_core": true,
"formula_file": "${ github.workspace }/tests/release_homebrew/Formula/hello_world.rb",
"git_email": "${ secrets.GH_BOT_EMAIL }",
"git_username": "${ secrets.GH_BOT_NAME }",
"git_username": "${ vars.GH_BOT_NAME }",
"org_homebrew_repo": "LizardByte/homebrew-homebrew",
"org_homebrew_repo_base_branch": "master",
"publish": false,
Expand All @@ -30,10 +32,11 @@
{
"runs-on": "ubuntu-latest",
"with": {
"actionlint_config": "---\n# empty config",
"contribute_to_homebrew_core": false,
"formula_file": "${ github.workspace }/tests/release_homebrew/Formula/hello_world.rb",
"git_email": "${ secrets.GH_BOT_EMAIL }",
"git_username": "${ secrets.GH_BOT_NAME }",
"git_username": "${ vars.GH_BOT_NAME }",
"publish": true,
"remove_labels": "",
"token": "${ secrets.GH_BOT_TOKEN }",
Expand Down
33 changes: 33 additions & 0 deletions actions/release_homebrew/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,36 @@ def process_input_formula(formula_file: str) -> str:
return formula


def override_actionlint_config() -> None:
"""
Override the default actionlint config file if INPUT_ACTIONLINT_CONFIG is provided.
"""
actionlint_config_content = os.getenv('INPUT_ACTIONLINT_CONFIG', '').strip()

if not actionlint_config_content:
print('No custom actionlint config provided, using default')
return

start_group('Overriding actionlint config')

# Get the brew repository path
brew_repo = get_brew_repository()
actionlint_config_file = os.path.join(brew_repo, '.github', 'actionlint.yaml')

print(f'Overriding actionlint config at: {actionlint_config_file}')

# Create the .github directory if it doesn't exist
github_dir = os.path.dirname(actionlint_config_file)
os.makedirs(github_dir, exist_ok=True)

# Write the custom config
with open(actionlint_config_file, 'w') as f:
f.write(actionlint_config_content)

print('Successfully overrode actionlint config')
end_group()


def is_brew_installed() -> bool:
print('Checking if Homebrew is installed')
return _run_subprocess(
Expand Down Expand Up @@ -970,6 +1000,9 @@ def main():
print(f'::error:: Formula {formula} failed audit')
FAILURES.append('audit')

# Override actionlint config if provided
override_actionlint_config()

if not brew_test_bot_only_tap_syntax():
print('::error:: brew test-bot --only-tap-syntax failed')
FAILURES.append('tap-syntax')
Expand Down
37 changes: 37 additions & 0 deletions tests/release_homebrew/test_release_homebrew.py
Original file line number Diff line number Diff line change
Expand Up @@ -1193,3 +1193,40 @@ def test_process_input_formula_skips_commit_for_non_git_repo(capsys, operating_s
captured = capsys.readouterr()
assert 'Skipping commit for' in captured.out
assert '(not a git repository)' in captured.out


def test_override_actionlint_config_no_config(capsys, monkeypatch, operating_system):
"""Test override_actionlint_config when no custom config is provided."""
monkeypatch.setenv('INPUT_ACTIONLINT_CONFIG', '')

main.override_actionlint_config()

captured = capsys.readouterr()
assert 'No custom actionlint config provided, using default' in captured.out


def test_override_actionlint_config_with_config(capsys, monkeypatch, operating_system, tmp_path):
"""Test override_actionlint_config with a custom config."""
# Create a mock brew repository
mock_brew_repo = tmp_path / "brew_repo"
mock_brew_repo.mkdir()

# Mock get_brew_repository to return our temp directory
with patch.object(main, 'get_brew_repository', return_value=str(mock_brew_repo)):
custom_config = 'self-hosted-runner:\n labels:\n - self-hosted'
monkeypatch.setenv('INPUT_ACTIONLINT_CONFIG', custom_config)

main.override_actionlint_config()

# Check that the file was created
actionlint_config_file = mock_brew_repo / '.github' / 'actionlint.yaml'
assert actionlint_config_file.exists()

# Check the content
with open(actionlint_config_file, 'r') as f:
content = f.read()
assert content == custom_config

captured = capsys.readouterr()
assert 'Overriding actionlint config' in captured.out
assert 'Successfully overrode actionlint config' in captured.out
Loading