Skip to content

Commit

Permalink
Fix MacOS compatibility issues
Browse files Browse the repository at this point in the history
  • Loading branch information
essobedo committed Feb 8, 2023
1 parent 426f2bc commit d7ca1cf
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ jobs:
matrix:
knative_version:
- v1.9.0
- v1.8.1
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
Expand Down
9 changes: 9 additions & 0 deletions kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ main() {

install_kind
install_kubectl
install_docker
create_kind_cluster

}
Expand Down Expand Up @@ -169,6 +170,14 @@ install_kubectl() {
kubectl version --client --output=yaml
}

install_docker() {
if [ "$RUNNER_OS" == "macOS" ] && ! [ -x "$(command -v docker)" ]; then
echo 'Installing docker...'
brew install docker colima
colima start
fi
}

create_kind_cluster() {
echo 'Creating kind cluster...'
local args=(create cluster "--name=$cluster_name" "--wait=$wait")
Expand Down
8 changes: 6 additions & 2 deletions knative.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,12 @@ parse_command_line() {

install_prerequisites() {
echo "Installing yq for patching Knative resources..."
wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/local/bin/yq
chmod +x /usr/local/bin/yq
if [ "$RUNNER_OS" == "macOS" ]; then
brew install yq
else
wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/local/bin/yq
chmod +x /usr/local/bin/yq
fi
yq --version
}

Expand Down
4 changes: 2 additions & 2 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ main() {
args_knative+=(--knative-eventing "${INPUT_KNATIVE_EVENTING}")
fi

if [[ -z "${INPUT_REGISTRY:-}" ]] || [[ "${INPUT_REGISTRY,,}" = "true" ]]; then
if [[ -z "${INPUT_REGISTRY:-}" ]] || [[ "$(echo ${INPUT_REGISTRY} | tr '[:upper:]' '[:lower:]')" = "true" ]]; then
if [[ ${args:+exist} == "exist" ]] && [[ ${#args[@]} -gt 0 ]]; then
"$SCRIPT_DIR/registry.sh" "${args[@]}"
else
Expand All @@ -82,7 +82,7 @@ main() {
"$SCRIPT_DIR/kind.sh"
fi

if [[ -z "${INPUT_REGISTRY:-}" ]] || [[ "${INPUT_REGISTRY,,}" = "true" ]]; then
if [[ -z "${INPUT_REGISTRY:-}" ]] || [[ "$(echo ${INPUT_REGISTRY} | tr '[:upper:]' '[:lower:]')" = "true" ]]; then
if [[ ${args:+exist} == "exist" ]] && [[ ${#args[@]} -gt 0 ]]; then
"$SCRIPT_DIR/registry.sh" "--document" "true" "${args[@]}"
else
Expand Down
15 changes: 10 additions & 5 deletions registry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ main() {

if [[ "$document" = "false" ]]
then
install_docker
create_registry
connect_registry
create_kind_config
Expand Down Expand Up @@ -121,16 +122,20 @@ parse_command_line() {
done
}

create_registry() {
echo "Creating registry \"$registry_name\" on port $registry_port from image \"$registry_image\"..."
install_docker() {
if [ "$RUNNER_OS" == "macOS" ] && ! [ -x "$(command -v docker)" ]; then
brew install docker colima
colima start
echo 'Installing docker...'
brew install docker colima
colima start
fi
}

create_registry() {
echo "Creating registry \"$registry_name\" on port $registry_port from image \"$registry_image\"..."
docker run -d --restart=always -p "${registry_port}:5000" --name "${registry_name}" $registry_image > /dev/null

# Adding registry to /etc/hosts
sudo -- bash -c 'echo "127.0.0.1 $registry_name" >> /etc/hosts'
echo "127.0.0.1 $registry_name" | sudo tee -a /etc/hosts

# Exporting the registry location for subsequent jobs
echo "KIND_REGISTRY=${registry_name}:${registry_port}" >> $GITHUB_ENV
Expand Down

0 comments on commit d7ca1cf

Please sign in to comment.