Skip to content

Commit

Permalink
Update ci.yml.
Browse files Browse the repository at this point in the history
  • Loading branch information
reitermarkus authored Jul 7, 2023
1 parent 3bf8a46 commit a53ae96
Showing 1 changed file with 46 additions and 52 deletions.
98 changes: 46 additions & 52 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on: pull_request
env:
HOMEBREW_DEVELOPER: 1
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_FROM_API: 1
HOMEBREW_GITHUB_API_TOKEN: ${{ github.token }}

concurrency:
Expand All @@ -18,12 +19,14 @@ jobs:
generate-matrix:
outputs:
matrix: ${{ steps.generate-matrix.outputs.matrix }}
runs-on: ubuntu-latest
runs-on: macos-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
Expand All @@ -35,23 +38,31 @@ jobs:
- name: Generate CI matrix
id: generate-matrix
run: |
brew tap homebrew/cask
brew ruby -- "$(brew --repository homebrew/cask)/cmd/lib/generate-matrix.rb" "${{ 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: Enable debug mode
run: |
echo 'HOMEBREW_DEBUG=1' >> "${GITHUB_ENV}"
echo 'HOMEBREW_VERBOSE=1' >> "${GITHUB_ENV}"
if: runner.debug

- name: Check out Pull Request
uses: actions/checkout@v3
with:
Expand All @@ -65,18 +76,11 @@ jobs:
echo '::warning::Removing Visual Studio is no longer necessary.'
fi
fi
if ! brew uninstall --cask julia && ! rm -r /Applications/Julia-*.app; then
echo '::warning::Removing Julia is no longer necessary.'
fi
if ! rm /usr/local/share/man/man1/al.1 || \
! sudo rm /etc/paths.d/mono-commands || \
! sudo rm -r /Library/Frameworks/Mono.framework || \
! sudo pkgutil --forget com.xamarin.mono-MDK.pkg; then
echo '::warning::Uninstalling Mono is no longer necessary.'
fi
if ! rm /usr/local/bin/dotnet; then
echo '::warning::Removing `dotnet` symlink is no longer necessary.'
fi
Expand All @@ -85,61 +89,55 @@ jobs:
echo '::warning::Removing `cocoapods` symlink is no longer necessary.'
fi
if ! rm /usr/local/bin/conda; then
echo '::warning::Removing `conda` symlink is no longer necessary.'
fi
brew unlink python && brew link --overwrite python
if: runner.os == 'macOS'

# Workaround until the `cache` action uses the changes from
# https://github.com/actions/toolkit/pull/580.
- name: Unlink workspace
run: |
mv "${GITHUB_WORKSPACE}" "${GITHUB_WORKSPACE}-link"
mkdir "${GITHUB_WORKSPACE}"
- name: Cache Homebrew Gems
id: cache
uses: actions/cache@v3
with:
path: ${{ steps.set-up-homebrew.outputs.gems-path }}
key: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }}
restore-keys: ${{ runner.os }}-rubygems-

# Workaround until the `cache` action uses the changes from
# https://github.com/actions/toolkit/pull/580.
- name: Re-link workspace
run: |
rmdir "${GITHUB_WORKSPACE}"
mv "${GITHUB_WORKSPACE}-link" "${GITHUB_WORKSPACE}"
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 '${{ matrix.tap }}'
if: always() && steps.gems.outcome == 'success'
if: >
always() &&
contains(fromJSON('["success", "skipped"]'), steps.gems.outcome) &&
!matrix.skip_readall
- name: Run brew style ${{ matrix.tap }}
run: brew style '${{ matrix.tap }}'
if: always() && steps.readall.outcome == 'success' && !matrix.cask
if: >
always() &&
contains(fromJSON('["success", "skipped"]'), steps.readall.outcome) &&
!matrix.cask
- name: Run brew fetch --cask ${{ matrix.cask.token }}
id: fetch
run: |
brew fetch --cask --retry --force '${{ matrix.cask.path }}'
brew fetch --cask --retry --force ${{ join(matrix.fetch_args, ' ') }} '${{ matrix.cask.path }}'
timeout-minutes: 30
if: always() && steps.readall.outcome == 'success' && matrix.cask
if: >
always() &&
contains(fromJSON('["success", "skipped"]'), steps.readall.outcome) &&
matrix.cask
- name: Run brew audit --cask${{ (matrix.cask && ' ') || ' --tap ' }}${{ matrix.cask.token || matrix.tap }}
id: audit
run: |
brew audit --cask ${{ join(matrix.audit_args, ' ') }}${{ (matrix.cask && ' --signing ') || ' --tap ' }}'${{ matrix.cask.path || matrix.tap }}'
brew audit --cask ${{ join(matrix.audit_args, ' ') }}${{ (matrix.cask && ' ') || ' --tap ' }}'${{ matrix.cask.token || matrix.tap }}'
timeout-minutes: 30
if: >
always() && steps.readall.outcome == 'success' &&
always() &&
contains(fromJSON('["success", "skipped"]'), steps.readall.outcome) &&
(!matrix.cask || steps.fetch.outcome == 'success') &&
!matrix.skip_audit
Expand Down Expand Up @@ -173,13 +171,15 @@ jobs:
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)}"
File.open(ENV.fetch("GITHUB_OUTPUT"), "a") do |f|
f.puts "was_installed=#{JSON.generate(was_installed)}"
f.puts "manual_installer=#{JSON.generate(manual_installer)}"
f.puts "macos_requirement_satisfied=#{JSON.generate(macos_requirement_satisfied)}"
f.puts "cask_conflicts=#{JSON.generate(cask_conflicts)}"
f.puts "cask_dependencies=#{JSON.generate(cask_dependencies)}"
f.puts "formula_conflicts=#{JSON.generate(formula_conflicts)}"
f.puts "formula_dependencies=#{JSON.generate(formula_dependencies)}"
end
EOF
if: always() && steps.fetch.outcome == 'success' && matrix.cask

Expand All @@ -205,7 +205,9 @@ jobs:
id: snapshot
run: |
brew ruby -r "$(brew --repository homebrew/cask)/cmd/lib/check.rb" <<'EOF'
puts "::set-output name=before::#{JSON.generate(Check.all)}"
File.open(ENV.fetch("GITHUB_OUTPUT"), "a") do |f|
f.puts "before=#{JSON.generate(Check.all)}"
end
EOF
if: always() && steps.info.outcome == 'success'

Expand All @@ -217,8 +219,6 @@ jobs:
fromJSON(steps.info.outputs.macos_requirement_satisfied) &&
!matrix.skip_install
timeout-minutes: 30
env:
HOMEBREW_DEBUG: 1

- name: Run brew uninstall --cask ${{ matrix.cask.token }}
run: brew uninstall --cask '${{ matrix.cask.path }}'
Expand Down Expand Up @@ -260,12 +260,6 @@ jobs:
EOF
if: always() && steps.snapshot.outcome == 'success'

# Workaround until the `cache` action uses the changes from
# https://github.com/actions/toolkit/pull/580.
- name: Unlink workspace
run: |
rm "${GITHUB_WORKSPACE}"
mkdir "${GITHUB_WORKSPACE}"
conclusion:
name: conclusion
needs: test
Expand Down

0 comments on commit a53ae96

Please sign in to comment.