Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add the ability to download kind/kubectl on macOS GHA runners #89

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/test.yaml
Expand Up @@ -68,6 +68,22 @@ jobs:
- name: Test kind works and there is no cluster started
run: |
[[ $(kind get clusters | wc -l) -eq 0 ]]

test-with-macos-install-only:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Comment on lines +71 to +76
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
test-with-macos-install-only:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
test-with-macos-install-only:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup docker
run: |
brew install docker
colima start

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this fix on my fork, it works: musse#1

Check this thread for details: actions/runner-images#17 (comment)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think this is right; you shouldn't need colima running if the action is in install_only mode


- name: Only install kind without starting a cluster
uses: ./
with:
install_only: true
ignore_failed_clean: true

- name: Test kind works and there is no cluster started
run: |
[[ $(kind get clusters | wc -l) -eq 0 ]]

test-with-custom-kubectl-version:
runs-on: ubuntu-latest
Expand Down
31 changes: 22 additions & 9 deletions kind.sh
Expand Up @@ -56,14 +56,27 @@ main() {
exit 1
fi

local arch
case $(uname -m) in
i386) arch="386" ;;
i686) arch="386" ;;
x86_64) arch="amd64" ;;
arm|aarch64|arm64) arch="arm64" ;;
local os="linux"
case $(uname) in
Darwin) os="darwin" ;;
esac
local cache_dir="${RUNNER_TOOL_CACHE}/kind/${version}/${arch}"

local arch
if [[ "$os" == "darwin" ]]; then
case $(uname -m) in
x86_64) arch="amd64" ;;
arm|arm64) arch="arm64" ;;
esac
else
case $(uname -m) in
i386) arch="386" ;;
i686) arch="386" ;;
x86_64) arch="amd64" ;;
arm|aarch64|arm64) arch="arm64" ;;
esac
fi

local cache_dir="${RUNNER_TOOL_CACHE}/kind/${version}/${os}/${arch}"

local kind_dir="${cache_dir}/kind/bin/"
if [[ ! -x "${kind_dir}/kind" ]]; then
Expand Down Expand Up @@ -188,7 +201,7 @@ install_kind() {

mkdir -p "${kind_dir}"

curl -sSLo "${kind_dir}/kind" "https://github.com/kubernetes-sigs/kind/releases/download/${version}/kind-linux-${arch}"
curl -sSLo "${kind_dir}/kind" "https://github.com/kubernetes-sigs/kind/releases/download/${version}/kind-${os}-${arch}"
chmod +x "${kind_dir}/kind"
}

Expand All @@ -197,7 +210,7 @@ install_kubectl() {

mkdir -p "${kubectl_dir}"

curl -sSLo "${kubectl_dir}/kubectl" "https://storage.googleapis.com/kubernetes-release/release/${kubectl_version}/bin/linux/${arch}/kubectl"
curl -sSLo "${kubectl_dir}/kubectl" "https://storage.googleapis.com/kubernetes-release/release/${kubectl_version}/bin/${os}/${arch}/kubectl"
chmod +x "${kubectl_dir}/kubectl"
}

Expand Down