Make brew style happy #288
Workflow file for this run
This file contains 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: continuous-integration | |
on: | |
pull_request: | |
branches: [ master ] | |
env: | |
HOMEBREW_DEVELOPER: 1 | |
HOMEBREW_NO_AUTO_UPDATE: 1 | |
HOMEBREW_NO_INSTALL_FROM_API: 1 | |
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
jobs: | |
generate-matrix: | |
outputs: | |
matrix: ${{ steps.generate-matrix.outputs.matrix }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Homebrew | |
id: set-up-homebrew | |
uses: Homebrew/actions/setup-homebrew@master | |
with: | |
core: false | |
cask: true | |
test-bot: false | |
- name: Check out Pull Request | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
- name: Generate CI matrix | |
id: generate-matrix | |
run: | | |
brew ruby -- "$(brew --repository homebrew/cask)/cmd/lib/generate-matrix.rb" --url="${{ github.event.pull_request.url }}" | |
test: | |
name: ${{ matrix.name }} | |
needs: generate-matrix | |
runs-on: ${{ matrix.runner }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} | |
steps: | |
- name: Set up Homebrew | |
id: set-up-homebrew | |
uses: Homebrew/actions/setup-homebrew@master | |
with: | |
core: false | |
cask: true | |
test-bot: false | |
- name: Tap isen-ng/dotnet-sdk-versions | |
run: brew tap isen-ng/dotnet-sdk-versions | |
- name: Checkout pull request | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
- name: Cache Homebrew Gems | |
id: cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.set-up-homebrew.outputs.gems-path }} | |
key: ${{ matrix.runner }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }} | |
restore-keys: ${{ matrix.runner }}-rubygems- | |
- name: Install Homebrew Gems | |
id: gems | |
run: brew install-bundler-gems | |
if: steps.cache.outputs.cache-hit != 'true' | |
- name: Run brew readall ${{ matrix.tap }} | |
id: readall | |
run: brew readall --os=all --arch=all '${{ matrix.tap }}' | |
if: always() && steps.gems.outcome == 'success' | |
- name: Run brew style ${{ matrix.tap }} | |
run: brew style '${{ matrix.tap }}' | |
if: always() && steps.readall.outcome == 'success' && !matrix.cask | |
- name: Run brew audit --tap=${{ matrix.tap }} | |
run: brew audit --tap='${{ matrix.tap }}' | |
timeout-minutes: 30 | |
if: always() && steps.gems.outcome == 'success' && !matrix.skip_audit && !matrix.cask.token | |
- name: Run brew style ${{ matrix.cask.token }} | |
run: brew style '${{ matrix.cask.path }}' | |
if: always() && steps.gems.outcome == 'success' && matrix.cask.token | |
- name: Run brew audit --cask ${{ matrix.cask.token }} | |
run: brew audit --cask ${{ join(matrix.audit_args, ' ') }} '${{ matrix.cask.token }}' | |
timeout-minutes: 30 | |
if: always() && steps.gems.outcome == 'success' && !matrix.skip_audit && matrix.cask.token | |
- name: Gather cask information | |
id: info | |
run: | | |
brew ruby <<'EOF' | |
require 'cask/cask_loader' | |
require 'cask/installer' | |
cask = Cask::CaskLoader.load('${{ matrix.cask.path }}') | |
was_installed = cask.installed? | |
manual_installer = cask.artifacts.any? { |artifact| | |
artifact.is_a?(Cask::Artifact::Installer::ManualInstaller) | |
} | |
macos_requirement_satisfied = if macos_requirement = cask.depends_on.macos | |
macos_requirement.satisfied? | |
else | |
true | |
end | |
cask_conflicts = cask.conflicts_with&.dig(:cask).to_a.select { |c| Cask::CaskLoader.load(c).installed? } | |
formula_conflicts = cask.conflicts_with&.dig(:formula).to_a.select { |f| Formula[f].any_version_installed? } | |
installer = Cask::Installer.new(cask) | |
cask_and_formula_dependencies = installer.missing_cask_and_formula_dependencies | |
cask_dependencies = cask_and_formula_dependencies.select { |d| d.is_a?(Cask::Cask) }.map(&:full_name) | |
formula_dependencies = cask_and_formula_dependencies.select { |d| d.is_a?(Formula) }.map(&:full_name) | |
puts "::set-output name=was_installed::#{JSON.generate(was_installed)}" | |
puts "::set-output name=manual_installer::#{JSON.generate(manual_installer)}" | |
puts "::set-output name=macos_requirement_satisfied::#{JSON.generate(macos_requirement_satisfied)}" | |
puts "::set-output name=cask_conflicts::#{JSON.generate(cask_conflicts)}" | |
puts "::set-output name=cask_dependencies::#{JSON.generate(cask_dependencies)}" | |
puts "::set-output name=formula_conflicts::#{JSON.generate(formula_conflicts)}" | |
puts "::set-output name=formula_dependencies::#{JSON.generate(formula_dependencies)}" | |
EOF | |
if: always() && steps.gems.outcome == 'success' && matrix.cask | |
- name: Uninstall conflicting formulae | |
run: | | |
brew uninstall --formula ${{ join(fromJSON(steps.info.outputs.formula_conflicts), ' ') }} | |
if: always() && steps.info.outcome == 'success' && join(fromJSON(steps.info.outputs.formula_conflicts)) != '' | |
timeout-minutes: 30 | |
- name: Uninstall conflicting casks | |
run: | | |
brew uninstall --cask ${{ join(fromJSON(steps.info.outputs.cask_conflicts), ' ') }} | |
if: always() && steps.info.outcome == 'success' && join(fromJSON(steps.info.outputs.cask_conflicts)) != '' | |
timeout-minutes: 30 | |
- name: Run brew uninstall --cask --zap ${{ matrix.cask.token }} | |
run: | | |
brew uninstall --cask --zap '${{ matrix.cask.path }}' | |
if: always() && steps.info.outcome == 'success' && fromJSON(steps.info.outputs.was_installed) | |
timeout-minutes: 30 | |
- name: Run pkgutil before installation | |
id: packages-before-installation | |
run: | | |
PACKAGES=$(pkgutil --pkgs) | |
echo "PACKAGES_BEFORE_INSTALL<<EOF" >> $GITHUB_ENV | |
echo "$PACKAGES" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
if: always() && steps.info.outcome == 'success' && !matrix.skip_install | |
timeout-minutes: 1 | |
- name: Run brew install --cask ${{ matrix.cask.token }} | |
id: install | |
run: brew install --cask '${{ matrix.cask.path }}' | |
if: > | |
always() && steps.info.outcome == 'success' && | |
fromJSON(steps.info.outputs.macos_requirement_satisfied) && | |
!matrix.skip_install | |
timeout-minutes: 30 | |
- name: List installed packages | |
id: packages-after-installation | |
run: | | |
PACKAGES=$(pkgutil --pkgs) >> $GITHUB_ENV | |
echo "PACKAGES_AFTER_INSTALL<<EOF" >> $GITHUB_ENV | |
echo "$PACKAGES" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
diff <(echo "${{ env.PACKAGES_BEFORE_INSTALL }}") <(echo "$PACKAGES") || true | |
if: always() && steps.info.outcome == 'success' && !matrix.skip_install | |
timeout-minutes: 1 | |
- name: Run brew uninstall --cask ${{ matrix.cask.token }} | |
run: brew uninstall --cask '${{ matrix.cask.path }}' | |
if: always() && steps.install.outcome == 'success' && !fromJSON(steps.info.outputs.manual_installer) | |
timeout-minutes: 30 | |
- name: List uninstalled packages | |
run: diff <(echo "${{ env.PACKAGES_AFTER_INSTALL }}") <(pkgutil --pkgs) || true | |
if: always() && steps.info.outcome == 'success' && !matrix.skip_install | |
timeout-minutes: 1 | |
- name: Uninstall formula dependencies | |
run: | | |
brew uninstall --formula ${{ join(fromJSON(steps.info.outputs.formula_dependencies), ' ') }} | |
if: always() && steps.install.outcome == 'success' && join(fromJSON(steps.info.outputs.formula_dependencies)) != '' | |
timeout-minutes: 30 | |
- name: Uninstall cask dependencies | |
run: | | |
brew uninstall --cask ${{ join(fromJSON(steps.info.outputs.cask_dependencies), ' ') }} | |
if: always() && steps.install.outcome == 'success' && join(fromJSON(steps.info.outputs.cask_dependencies)) != '' | |
timeout-minutes: 30 | |
conclusion: | |
name: conclusion | |
needs: test | |
runs-on: ubuntu-latest | |
if: always() | |
steps: | |
- name: Result | |
run: ${{ needs.test.result == 'success' }} |