From 51963d458591aad06103d0f59ca155203b7395b5 Mon Sep 17 00:00:00 2001 From: Devin Buhl Date: Sat, 28 Dec 2024 20:18:44 -0500 Subject: [PATCH] fix(workflows): use homebrew and not mise Signed-off-by: Devin Buhl --- .github/workflows/helm-repository-sync.yaml | 11 ++- .github/workflows/pre-pull-images.yaml | 20 ++--- .github/workflows/schemas.yaml | 16 ++-- hack/crd-extractor.sh | 98 --------------------- 4 files changed, 25 insertions(+), 120 deletions(-) delete mode 100755 hack/crd-extractor.sh diff --git a/.github/workflows/helm-repository-sync.yaml b/.github/workflows/helm-repository-sync.yaml index b1595aba1a578..d32ec49e5807d 100644 --- a/.github/workflows/helm-repository-sync.yaml +++ b/.github/workflows/helm-repository-sync.yaml @@ -34,13 +34,12 @@ jobs: token: "${{ steps.app-token.outputs.token }}" fetch-depth: 0 + - name: Setup Homebrew + uses: Homebrew/actions/setup-homebrew@master + - name: Setup Workflow Tools - uses: jdx/mise-action@v2 - with: - mise_toml: | - [tools] - "aqua:fluxcd/flux2" = "latest" - "aqua:mikefarah/yq" = "latest" + shell: bash + run: brew install fluxcd/tap/flux yq - if: ${{ github.event.inputs.helmRepoNamespace == '' && github.event.inputs.helmRepoName == '' }} name: Get Changed Files diff --git a/.github/workflows/pre-pull-images.yaml b/.github/workflows/pre-pull-images.yaml index f13a06415b94b..e1990d79938bd 100644 --- a/.github/workflows/pre-pull-images.yaml +++ b/.github/workflows/pre-pull-images.yaml @@ -27,12 +27,12 @@ jobs: app-id: "${{ secrets.BOT_APP_ID }}" private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}" + - name: Setup Homebrew + uses: Homebrew/actions/setup-homebrew@master + - name: Setup Workflow Tools - uses: jdx/mise-action@v2 - with: - mise_toml: | - [tools] - "aqua:mikefarah/yq" = "latest" + shell: bash + run: brew install yq - name: Checkout Default Branch uses: actions/checkout@v4 @@ -100,12 +100,12 @@ jobs: max-parallel: 4 fail-fast: false steps: + - name: Setup Homebrew + uses: Homebrew/actions/setup-homebrew@master + - name: Setup Workflow Tools - uses: jdx/mise-action@v2 - with: - mise_toml: | - [tools] - "aqua:siderolabs/talos" = "latest" + shell: bash + run: brew install siderolabs/tap/talosctl - name: Pre-pull Image run: talosctl -n $NODE_IP image pull ${{ matrix.images }} diff --git a/.github/workflows/schemas.yaml b/.github/workflows/schemas.yaml index 7fcf9b72d9b39..079d90d858ccf 100644 --- a/.github/workflows/schemas.yaml +++ b/.github/workflows/schemas.yaml @@ -30,12 +30,12 @@ jobs: with: token: "${{ steps.app-token.outputs.token }}" + - name: Setup Homebrew + uses: Homebrew/actions/setup-homebrew@master + - name: Setup Workflow Tools - uses: jdx/mise-action@v2 - with: - mise_toml: | - [tools] - "aqua:kubernetes/kubectl" = "latest" + shell: bash + run: brew install kubectl - name: Setup Python uses: actions/setup-python@v5 @@ -52,7 +52,11 @@ jobs: - name: Download and run crd-extractor shell: bash - run: ./hack/crd-extractor.sh + run: | + curl -fsSL -o $GITHUB_WORKSPACE/crd-extractor.sh \ + https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/Utilities/crd-extractor.sh + chmod +x $GITHUB_WORKSPACE/crd-extractor.sh + bash $GITHUB_WORKSPACE/crd-extractor.sh - name: Deploy to Cloudflare Pages uses: cloudflare/wrangler-action@v3 diff --git a/hack/crd-extractor.sh b/hack/crd-extractor.sh deleted file mode 100755 index 6713ad91d67ab..0000000000000 --- a/hack/crd-extractor.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -# Function to fetch a CRD -fetch_crd() { - local crd="$1" - local crd_file="$TMP_CRD_DIR/$crd.yaml" - if ! kubectl get crds "$crd" -o yaml >"$crd_file" 2>/dev/null; then - printf "Failed to fetch CRD: %s\n" "$crd" - return 1 - fi -} - -# Directories -TMP_CRD_DIR="$HOME/.datree/crds" -SCHEMAS_DIR="$HOME/.datree/crdSchemas" - -# Initialize directories -mkdir -p "$TMP_CRD_DIR" "$SCHEMAS_DIR" -cd "$SCHEMAS_DIR" || { echo "Failed to change to schemas directory"; exit 1; } - -# Fetch list of CRDs -printf "Fetching list of CRDs...\n" -kubectl get crds | awk 'NR>1 {print $1}' >"$TMP_CRD_DIR/crd_list.txt" - -# Read CRDs into an array -CRD_LIST=() -while IFS= read -r line; do - CRD_LIST+=("$line") -done <"$TMP_CRD_DIR/crd_list.txt" - -# Check if there are any CRDs -if [ "${#CRD_LIST[@]}" -eq 0 ]; then - printf "No CRDs found in the cluster, exiting...\n" - exit 0 -fi - -# Fetch CRDs in parallel -FETCHED_CRDS=0 -PARALLELISM=10 -for crd in "${CRD_LIST[@]}"; do - printf "Fetching CRD %d/%d: %s\n" $((FETCHED_CRDS + 1)) "${#CRD_LIST[@]}" "$crd" - - fetch_crd "$crd" & - - # Ensure a maximum of $PARALLELISM jobs run in parallel - while [ "$(jobs -r | wc -l)" -ge "$PARALLELISM" ]; do - wait -n - done - - FETCHED_CRDS=$((FETCHED_CRDS + 1)) -done - -# Wait for all background jobs to finish -wait - -# Download converter script -CONVERTER_SCRIPT="$TMP_CRD_DIR/openapi2jsonschema.py" -printf "Downloading OpenAPI to JSON schema converter script...\n" -if ! curl -sSL "https://raw.githubusercontent.com/yannh/kubeconform/master/scripts/openapi2jsonschema.py" -o "$CONVERTER_SCRIPT"; then - printf "Failed to download converter script\n" - exit 1 -fi - -# Convert CRDs to JSON schema -printf "Converting CRDs to JSON schema...\n" -if ! FILENAME_FORMAT="{fullgroup}_{kind}_{version}" python3 "$CONVERTER_SCRIPT" "$TMP_CRD_DIR"/*.yaml; then - printf "Failed to convert CRDs to JSON schema\n" - exit 1 -fi - -# Prepare master-standalone directory -rm -rf "$SCHEMAS_DIR/master-standalone" -mkdir -p "$SCHEMAS_DIR/master-standalone" - -# Rename and copy JSON files -for json_file in "$SCHEMAS_DIR"/*.json; do - base_name=$(basename "$json_file") - new_name=${base_name//_/-stable-} - cp "$json_file" "$SCHEMAS_DIR/master-standalone/$new_name" -done - -# Organize schemas by group -for schema in "$SCHEMAS_DIR"/*.json; do - crd_file_name=$(basename "$schema") - crd_group="${crd_file_name%%_*}" - out_name="${crd_file_name#*_}" - group_dir="$SCHEMAS_DIR/$crd_group" - mkdir -p "$group_dir" - mv "$schema" "$group_dir/$out_name" -done - -# Print success message -printf "Successfully converted %d CRDs to JSON schema\n" "$FETCHED_CRDS" - -# Cleanup -rm -rf "$TMP_CRD_DIR"