test: Refactor CI workflow: disable prior test jobs, add Homebrew for… #795
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: test | |
permissions: | |
contents: read | |
on: | |
push: | |
branches-ignore: | |
- "coverage" | |
- "renovate/**" | |
pull_request: | |
workflow_dispatch: | |
inputs: | |
main_branch: | |
description: "Main branch for coverage/tmate." | |
type: string | |
required: false | |
default: "main" | |
main_os: | |
description: "Main os for coverage/tmate." | |
type: choice | |
default: "macos-latest" | |
options: | |
- "macos-latest" | |
- "ubuntu-latest" | |
main_py_ver: | |
description: "Main python version for coverage/tmate." | |
type: choice | |
default: "3.9" | |
options: | |
- "3.12" | |
- "3.11" | |
- "3.10" | |
- "3.9" | |
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 | |
env: | |
MAIN_BRANCH: ${{ inputs.main_branch || 'main' }} | |
MAIN_OS: ${{ inputs.main_os || 'macos-latest' }} | |
MAIN_PY_VER: ${{ inputs.main_py_ver || '3.10' }} | |
TMATE: ${{ inputs.tmate || 'false' }} | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
# install: | |
# strategy: | |
# matrix: | |
# os: [macos-latest, ubuntu-latest] | |
# runs-on: ${{ matrix.os }} | |
# steps: | |
# - name: Exit workflow | |
# if: ${{ github.event_name == 'workflow_dispatch' && env.tmate == 'true' }} | |
# run: exit 1 | |
# - 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 | |
# formula: | |
# strategy: | |
# matrix: | |
# os: [macos-latest, ubuntu-latest] | |
# runs-on: ${{ matrix.os }} | |
# steps: | |
# - name: Exit workflow | |
# if: ${{ github.event_name == 'workflow_dispatch' && env.tmate == 'true' }} | |
# run: exit 1 | |
# - name: Set up Homebrew | |
# id: set-up-homebrew | |
# uses: Homebrew/actions/setup-homebrew@master | |
# with: | |
# test-bot: false | |
# - name: Install homebrew-file | |
# run: brew install rcmdnk/file/brew-file | |
# test: | |
# strategy: | |
# fail-fast: false | |
# matrix: | |
# os: [macos-latest, ubuntu-latest] | |
# python-version: ['3.13', '3.12', '3.11', '3.10', '3.9'] | |
# permissions: | |
# contents: write | |
# runs-on: ${{ matrix.os }} | |
# steps: | |
# - name: Check is main | |
# id: is_main | |
# run: | | |
# if [ "${{ github.ref }}" = "refs/heads/${{ env.MAIN_BRANCH }}" ] && [ "${{ matrix.os }}" = "${{ env.MAIN_OS }}" ] && [ "${{ matrix.python-version }}" = "${{ env.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 [ "${{ env.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: Set up Homebrew | |
# id: set-up-homebrew | |
# uses: Homebrew/actions/setup-homebrew@master | |
# with: | |
# test-bot: false | |
# - name: Install wget | |
# run: brew install wget | |
# - uses: rcmdnk/python-action@v3 | |
# with: | |
# checkout: 1 | |
# setup-python: 1 | |
# python-version: "${{ matrix.python-version }}" | |
# setup-type: 'uv' | |
# pytest: 1 | |
# pytest-tests-path: 'tests/' | |
# pytest-ignore: '' | |
# pytest-separate-benchmark: 0 | |
# coverage: 1 | |
# 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 }}" | |
# github_token: "${{github.token}}" | |
# pre-commit: "${{ env.IS_MAIN }}" | |
# tmate: "${{ env.DEBUG }}" | |
# test-serial: | |
# strategy: | |
# fail-fast: false | |
# matrix: | |
# python-version: ['3.9'] | |
# test-path: | |
# - 'tests/test_serial.py::test_init' | |
# - 'tests/test_serial.py::test_install_clean[default]' | |
# - 'tests/test_serial.py::test_install_clean[on-request]' | |
# - 'tests/test_serial.py::test_install_clean[top-packages]' | |
# runs-on: macos-latest | |
# steps: | |
# - name: Set up Homebrew | |
# id: set-up-homebrew | |
# uses: Homebrew/actions/setup-homebrew@master | |
# with: | |
# test-bot: false | |
# - uses: rcmdnk/python-action@v3 | |
# with: | |
# checkout: 1 | |
# setup-python: 1 | |
# python-version: "${{ matrix.python-version }}" | |
# setup-type: 'uv' | |
# pytest: 1 | |
# pytest-tests-path: "${{ matrix.test-path }}" | |
# pytest-ignore: '' | |
# pytest-separate-benchmark: 0 | |
# coverage: 0 | |
# pytest-cov-path: "" | |
# pytest-opt: "-n0 -m serial" | |
# coverage-push: 0 | |
# github_token: "" | |
# pre-commit: 0 | |
# tmate: 0 | |
# - name: fix Homebrew for post setup | |
# # setup-homebrew makes links from $GITHUB_WORKSPACE to taps. | |
# # And it tries to remove these links at post setup event if it is | |
# # untapped. | |
# # Need to tap again after test cleanup otherwise Post Setup Homebrew | |
# # makes an error. | |
# run: | | |
# rm -rf /opt/homebrew/Library/Taps/rcmdnk/homebrew-file | |
# mkdir -p /opt/homebrew/Library/Taps/rcmdnk | |
# touch /opt/homebrew/Library/Taps/rcmdnk/homebrew-file | |
test1: | |
strategy: | |
fail-fast: false | |
runs-on: macos-latest | |
steps: | |
- name: Set up Homebrew | |
id: set-up-homebrew | |
uses: Homebrew/actions/setup-homebrew@master | |
with: | |
test-bot: false | |
- name: brew test | |
run: | | |
brew install rcmdnk/file/brew-file | |
brew uninstall brew-file | |
brew untap rcmdnk/file | |
test2: | |
strategy: | |
fail-fast: false | |
runs-on: macos-latest | |
steps: | |
- name: Set up Homebrew | |
id: set-up-homebrew | |
uses: Homebrew/actions/setup-homebrew@master | |
with: | |
test-bot: false | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
fetch-depth: 0 | |
- name: brew test | |
run: | | |
brew install rcmdnk/file/brew-file | |
brew uninstall brew-file | |
brew untap rcmdnk/file |