Skip to content

Commit

Permalink
fix: tap for tapall at read (this is executed event in dry run mode
Browse files Browse the repository at this point in the history
test: update following dry run banner update, parse env update
test: add tap in tests/conftest.py (need taps otherwize can not separate formula/casks to each taps)
test: fix execute_on_err (no default Brewfile environment, need to apply monkeypatch to functions)
test:: use Path to check path
test: install python@3.10 for testing
chore: separate trigger and dispatch
chore: run `pre-commit run -a` before combine
chore: continue-on-error when debug_enabled
chore: use env instead of output: steps.output or inputs can not be passed to the composite action
  • Loading branch information
rcmdnk committed Feb 5, 2023
1 parent a62c9d7 commit 8152cfc
Show file tree
Hide file tree
Showing 10 changed files with 330 additions and 250 deletions.
93 changes: 93 additions & 0 deletions .github/workflows/dispatch.yml
@@ -0,0 +1,93 @@
name: test

on:
workflow_dispatch:
inputs:
main_branch:
description: "Main branch for coverage/tmate."
type: string
required: false
default: "master"
main_os:
description: "Main os for coverage/tmate."
type: choice
default: "macos-12"
options:
- "macos-12"
- "ubuntu-latest"
main_py_ver:
description: "Main python version for coverage/tmate."
type: choice
default: "3.10"
options:
- "3.10"
tmate:
type: boolean
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate). This is only for main strategy and others will be stopped.'
required: false
default: false

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
install:
strategy:
matrix:
os: [macos-12, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install test
run: |
curl -o install.sh -fsSL https://raw.github.com/rcmdnk/homebrew-file/install/install.sh
chmod 755 ./install.sh
./install.sh
rm -f install.sh
test:
strategy:
fail-fast: false
matrix:
os: [macos-12, ubuntu-latest]
python-version: ['3.10']
permissions:
contents: write
runs-on: ${{ matrix.os }}
steps:
- name: Check is main
id: is_main
run: |
main_branch="${{ inputs.main_branch }}"
main_branch=${main_branch:-master}
main_os="${{ inputs.main_os }}"
main_os=${main_os:-macos-12}
main_py_ver="${{ inputs.main_py_ver }}"
main_py_ver=${main_py_ver:-3.10}
echo "MAIN_BRANCH=$main_branch" >> $GITHUB_ENV
echo "MAIN_OS=$main_os" >> $GITHUB_ENV
echo "MAIN_PY_VER=$main_py_ver" >> $GITHUB_ENV
if [ "${{ github.ref }}" = "refs/heads/$main_branch" ] && [ "${{ matrix.os }}" = "$main_os" ] && [ "${{ matrix.python-version }}" = "$main_py_ver" ];then
echo "IS_MAIN=1" >> $GITHUB_ENV
is_main=1
else
echo "IS_MAIN=0" >> $GITHUB_ENV
is_main=0
fi
if [ "${{ inputs.tmate }}" = "true" ];then
if [ "$is_main" = 0 ];then
echo "Tmate is enabled and this is not main, skip tests"
exit 1
fi
echo "DEBUG=1" >> $GITHUB_ENV
else
echo "DEBUG=0" >> $GITHUB_ENV
fi
- name: Homebrew installation
run: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
- uses: rcmdnk/python-action@v1
with:
pytest-cov-path: "bin"
coverage-push: "${{ env.IS_MAIN }}"
coverage-push-condition: "branch=${{ env.MAIN_BRANCH }}, os=${{ env.MAIN_OS }}, python_version=${{ env.MAIN_PY_VER }}"
pre-commit: "${{ env.IS_MAIN }}"
tmate: "${{ env.DEBUG }}"
62 changes: 0 additions & 62 deletions .github/workflows/test.yml

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/trigger.yml
@@ -0,0 +1,28 @@
---
name: trigger

on:
push:
branches-ignore:
- "coverage"
- "renovate/**"
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
trigger:
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- uses: convictional/trigger-workflow-and-wait@v1.6.5
with:
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
ref: ${{ github.ref }}
github_token: ${{ github.token }}
workflow_file_name: dispatch.yml
propagate_failure: true
1 change: 1 addition & 0 deletions bin/brew-file
Expand Up @@ -522,6 +522,7 @@ class BrewInfo:
case "tap":
self.tap_input.append(p)
case "tapall":
self.helper.proc(f"brew tap {p}")
self.tap_input.append(p)
for tp in self.get_tap_packs(p):
self.brew_input.append(tp)
Expand Down
6 changes: 1 addition & 5 deletions combine.sh
@@ -1,16 +1,12 @@
#!/usr/bin/env bash

pre-commit run -a

dest="./bin/brew-file"
tmp_backup=$(mktemp -t brew-file)
mv "$dest" "$tmp_backup"
echo "Old brew-file was moved to $tmp_backup"

black src/brew_file/
isort src/brew_file
autoflake --in-place src/brew_file
autopep8 --in-place src/brew_file

{
echo "#!/usr/bin/env python3"
grep -E "(^from|^import)" src/brew_file/*.py|grep -v "from \."| cut -d ":" -f2| sort -u
Expand Down
1 change: 1 addition & 0 deletions src/brew_file/brew_info.py
Expand Up @@ -259,6 +259,7 @@ def read(self) -> None:
case "tap":
self.tap_input.append(p)
case "tapall":
self.helper.proc(f"brew tap {p}")
self.tap_input.append(p)
for tp in self.get_tap_packs(p):
self.brew_input.append(tp)
Expand Down
13 changes: 13 additions & 0 deletions tests/conftest.py
Expand Up @@ -11,6 +11,19 @@ def check_brew():
brew_file.BrewFile({})


@pytest.fixture(scope="session", autouse=False)
def tap():
bf = brew_file.BrewFile({})
bf.helper.proc("brew tap rcmdnk/rcmdnkpac")
bf.helper.proc("brew tap rcmdnk/rcmdnkcask")


@pytest.fixture(scope="session", autouse=False)
def python():
bf = brew_file.BrewFile({})
bf.helper.proc("brew install python@3.10")


@pytest.fixture
def ch() -> logging.StreamHandler:
ch = logging.StreamHandler(stream=sys.stdout)
Expand Down

0 comments on commit 8152cfc

Please sign in to comment.