Skip to content

Commit

Permalink
build: Make use of brewed python deps
Browse files Browse the repository at this point in the history
  • Loading branch information
janw committed Feb 4, 2024
1 parent f57269f commit a169e9d
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 10 deletions.
46 changes: 43 additions & 3 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
tags:
- "*"

env:
HOMEBREW_NO_AUTO_UPDATE: "1"

jobs:
pytest:
runs-on: ubuntu-latest
Expand All @@ -21,13 +24,13 @@ jobs:
name: pytest-${{ matrix.python-version }}
steps:
- name: Check out
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install poetry
run: pipx install poetry

- name: Set up python environment
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
cache: 'poetry'
python-version: ${{ matrix.python-version }}
Expand All @@ -37,8 +40,45 @@ jobs:
- run: poetry run pytest --cov-report=xml

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
name: coverage-${{ matrix.python-version }}

test-formula:
runs-on: macos-latest
steps:
- name: Check out
uses: actions/checkout@v4

- name: Install poetry + poetry-brew
run: |
pipx install 'poetry>=1.7.0'
pipx inject poetry poetry-homebrew-formula
- name: Configure cache
uses: actions/cache@v4
with:
path: |
~/Library/Caches/Homebrew/podcast-archiver--*
~/Library/Caches/Homebrew/downloads/*--podcast-archiver-*
key: brew-${{ hashFiles('poetry.lock') }}
restore-keys: brew-

- name: Render formula template
shell: bash
run: |
brew tap-new --no-git janw/testing
poetry homebrew-formula \
--verbose \
--template brew/template.rb.j2 \
--output "$(brew --repo janw/testing)/Formula/podcast-archiver.rb"
- name: Install formula
shell: bash
run: brew install podcast-archiver

- name: Test formula
shell: bash
run: brew test podcast-archiver
19 changes: 12 additions & 7 deletions brew/template.rb.j2
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,24 @@ class {{ formula_name }} < Formula

{{ PACKAGE_URL }}

depends_on "python3"
depends_on "[email protected]"
depends_on "rust" => :build

{{ RESOURCES }}
def python3
"python3.12"
end

def install
virtualenv_create(libexec, "python3")
virtualenv_install_with_resources
def std_pip_args(prefix: self.prefix, build_isolation: false)
["--verbose", "--ignore-installed"]
end

generate_completions_from_executable(bin/"podcast-archiver", shells: [:bash, :zsh, :fish], shell_parameter_format: :click)
def install
venv = virtualenv_create(libexec, python3, system_site_packages: false)
venv.pip_install_and_link buildpath
generate_completions_from_executable(bin/"podcast-archiver", shells: [:zsh, :fish], shell_parameter_format: :click)
end

test do
false
assert_match "podcast-archiver, ", shell_output(bin/"podcast-archiver --version")
end
end

0 comments on commit a169e9d

Please sign in to comment.