-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script and GH action to verify taps (#183)
* Add script and GH action to verify taps * Add checkout action * Setup Homebrew from action * Fix older taps * Refactor gh action namning * Fix checksums in [email protected]
- Loading branch information
Showing
8 changed files
with
110 additions
and
10 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Homebrew Tests | ||
|
||
on: | ||
push: | ||
branches: [ 'main' ] | ||
|
||
pull_request: | ||
branches: [ 'main' ] | ||
|
||
jobs: | ||
test: | ||
name: Verify Install | ||
strategy: | ||
matrix: | ||
os: [ "ubuntu-latest", "macos-latest" ] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Git checkout | ||
uses: actions/checkout@v4 | ||
- name: Set up Homebrew | ||
id: set-up-homebrew | ||
uses: Homebrew/actions/setup-homebrew@master | ||
- name: Install Bash 4 on MacOS | ||
if: matrix.os == 'macos-latest' | ||
run: | | ||
brew install bash | ||
echo "/usr/local/bin" >> $GITHUB_PATH | ||
echo "$(brew --prefix)/opt/gnu-sed/libexec/gnubin" >> $GITHUB_PATH | ||
- name: Execute tests | ||
run: | | ||
./hack/verify-taps.sh |
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#! /usr/bin/env bash | ||
|
||
# Copyright 2024 The Knative Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
[[ ! -v REPO_ROOT_DIR ]] && REPO_ROOT_DIR="$(git rev-parse --show-toplevel)" | ||
readonly REPO_ROOT_DIR | ||
|
||
# List all *.rb files and try to install them as local Homebrew Tap formula | ||
function verify_install() { | ||
|
||
pushd "${REPO_ROOT_DIR}" | ||
local failed=() | ||
|
||
for filename in *.rb; do | ||
local name | ||
name=$(echo "${filename}" | cut -d '.' -f1 | cut -d '@' -f1) | ||
|
||
echo "Installing from: ${filename}" | ||
echo "Plugin name: ${name}" | ||
|
||
brew install -v --formula ./"${filename}" --force || echo "Failed: ${filename}" | ||
|
||
if ! command -v kn-${name} >/dev/null; then | ||
echo "Plugin $name not found. Installation probably failed." | ||
failed+=("${filename}") | ||
else | ||
echo "Successfully verified: ${name}" | ||
fi | ||
|
||
# Remove to not clash with other version, continue | ||
brew remove -v --formula "${filename}" --force || echo "Failed uninstall: ${filename}" | ||
done | ||
|
||
if (( ${#failed[@]} > 0 )); then | ||
echo "#####" | ||
echo "Test failed!" | ||
echo "Files: ${failed[*]}" | ||
echo "#####" | ||
exit 1 | ||
fi | ||
|
||
popd | ||
echo "Test success!" | ||
} | ||
|
||
# Adding main for convenience. It might be useful if we have more tests. | ||
function main() { | ||
verify_install | ||
} | ||
|
||
main "$@" |
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
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