From f34746bbedf2287a37d186f400594e07d729ba51 Mon Sep 17 00:00:00 2001 From: cploujoux Date: Wed, 25 Jun 2025 09:01:52 -0400 Subject: [PATCH 1/7] Add retry when downloading toolkit --- .github/workflows/test-action.yml | 62 +++++++++++++++++++ .github/workflows/test.yml | 32 ---------- action.yml | 39 +++++++++++- .../anthropic-beamlit-organization.yml | 8 --- .../cohere-beamlit-organization.yaml | 8 --- .../hf-beamlit-organization.yml | 8 --- .../mistral-beamlit-organization.yml | 8 --- .../openai-beamlit-organization.yml | 8 --- .../xai-beamlit-organization.yaml | 8 --- blaxel/0-policies/eu-and-na.yml | 13 ---- blaxel/0-policies/only-eu.yml | 10 --- blaxel/0-policies/only-us.yml | 11 ---- blaxel/1-models/all-minilm-l6-v2.yml | 14 ----- blaxel/1-models/claude-35-sonnet.yml | 13 ---- blaxel/1-models/gpt-4o-mini.yml | 13 ---- blaxel/1-models/ministral-3b-2410.yml | 13 ---- blaxel/2-functions/github.yml | 13 ---- blaxel/2-functions/math.yml | 9 --- blaxel/2-functions/search.yml | 13 ---- blaxel/3-agents/agent-github.yml | 18 ------ blaxel/3-agents/agent-gpt-4o-mini.yml | 24 ------- 21 files changed, 99 insertions(+), 246 deletions(-) create mode 100644 .github/workflows/test-action.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 blaxel/0-integration-connection/anthropic-beamlit-organization.yml delete mode 100644 blaxel/0-integration-connection/cohere-beamlit-organization.yaml delete mode 100644 blaxel/0-integration-connection/hf-beamlit-organization.yml delete mode 100644 blaxel/0-integration-connection/mistral-beamlit-organization.yml delete mode 100644 blaxel/0-integration-connection/openai-beamlit-organization.yml delete mode 100644 blaxel/0-integration-connection/xai-beamlit-organization.yaml delete mode 100644 blaxel/0-policies/eu-and-na.yml delete mode 100644 blaxel/0-policies/only-eu.yml delete mode 100644 blaxel/0-policies/only-us.yml delete mode 100644 blaxel/1-models/all-minilm-l6-v2.yml delete mode 100644 blaxel/1-models/claude-35-sonnet.yml delete mode 100644 blaxel/1-models/gpt-4o-mini.yml delete mode 100644 blaxel/1-models/ministral-3b-2410.yml delete mode 100644 blaxel/2-functions/github.yml delete mode 100644 blaxel/2-functions/math.yml delete mode 100644 blaxel/2-functions/search.yml delete mode 100644 blaxel/3-agents/agent-github.yml delete mode 100644 blaxel/3-agents/agent-gpt-4o-mini.yml diff --git a/.github/workflows/test-action.yml b/.github/workflows/test-action.yml new file mode 100644 index 0000000..abde254 --- /dev/null +++ b/.github/workflows/test-action.yml @@ -0,0 +1,62 @@ +name: Test Action + +on: + push: + branches: [ main, develop ] + pull_request: + branches: [ main ] + workflow_dispatch: + +env: + BL_ENV: ${{ github.ref == 'refs/heads/main' && 'prod' || 'dev' }} + BL_WORKSPACE: ${{ vars.BL_WORKSPACE }} + BL_API_KEY: ${{ secrets.BL_API_KEY }} + +jobs: + test-action: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Test bl-action + uses: ./ # This references the action in the current repo + with: + workspace: ${{ secrets.BL_WORKSPACE || 'test-workspace' }} + apikey: ${{ secrets.BL_API_KEY || 'test-key' }} + - name: List agents + run: bl get agents + - name: List functions + run: bl get functions + - name: List models + run: bl get models + - name: List sandboxes + run: bl get sandboxes + + test-installation-only: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Test installation without deploy + uses: ./ + with: + workspace: ${{ secrets.BL_WORKSPACE || 'test-workspace' }} + apikey: ${{ secrets.BL_API_KEY || 'test-key' }} + # No deploy parameter to test that path + + test-matrix: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, ubuntu-20.04] + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Test on ${{ matrix.os }} + uses: ./ + with: + workspace: ${{ secrets.BL_WORKSPACE || 'test-workspace' }} + apikey: ${{ secrets.BL_API_KEY || 'test-key' }} \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index ce7d65f..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Test - -on: - workflow_dispatch: - -jobs: - test: - runs-on: ubuntu-latest - env: - TAVILY_API_KEY: ${{ secrets.TAVILY_API_KEY }} - GH_PAT: ${{ secrets.GH_PAT }} - MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }} - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - HF_API_TOKEN: ${{ secrets.HF_API_TOKEN }} - ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} - COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }} - XAI_API_KEY: ${{ secrets.XAI_API_KEY }} - steps: - - uses: actions/checkout@v4 - - uses: blaxel/blaxel-action@v1 - with: - workspace: main - apikey: ${{ secrets.BL_API_KEY }} - deploy: blaxel - - name: List policies - run: bl get policies - - name: List models - run: bl get models - - name: List functions - run: bl get functions - - name: List agents - run: bl get agents diff --git a/action.yml b/action.yml index fe46efc..44ecc35 100644 --- a/action.yml +++ b/action.yml @@ -23,11 +23,46 @@ runs: run: | mkdir -p $HOME/.local/bin + # Function to download with retry logic + download_with_retry() { + local url=$1 + local max_attempts=5 + local delay=2 + local attempt=1 + + while [ $attempt -le $max_attempts ]; do + if curl -fsSL --connect-timeout 30 --max-time 300 "$url" | BINDIR=$HOME/.local/bin sh; then + return 0 + else + local exit_code=$? + + if [ $attempt -eq $max_attempts ]; then + return $exit_code + fi + + sleep $delay + delay=$((delay * 2)) # Exponential backoff + attempt=$((attempt + 1)) + fi + done + } + + # Download the installation script with retry logic + INSTALL_URL="https://raw.githubusercontent.com/blaxel-ai/toolkit/main/install.sh" + if [ "$BL_ENV" = "dev" ]; then - curl -fsSL https://raw.githubusercontent.com/blaxel-ai/toolkit/main/install.sh | BINDIR=$HOME/.local/bin sh + download_with_retry "$INSTALL_URL" else - curl -fsSL https://raw.githubusercontent.com/blaxel-ai/toolkit/main/install.sh | BINDIR=$HOME/.local/bin sh + download_with_retry "$INSTALL_URL" + fi + + # Verify installation + if [ ! -f "$HOME/.local/bin/blaxel" ]; then + echo "Error: blaxel installation failed" + exit 1 fi + + # Create symlink and add to PATH cp $HOME/.local/bin/blaxel $HOME/.local/bin/bl echo "$HOME/.local/bin" >> $GITHUB_PATH - name: Login to Blaxel diff --git a/blaxel/0-integration-connection/anthropic-beamlit-organization.yml b/blaxel/0-integration-connection/anthropic-beamlit-organization.yml deleted file mode 100644 index 40e447a..0000000 --- a/blaxel/0-integration-connection/anthropic-beamlit-organization.yml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: blaxel.ai/v1alpha1 -kind: IntegrationConnection -metadata: - name: anthropic-blaxel-organization -spec: - integration: anthropic - secret: - apiKey: ${ANTHROPIC_API_KEY} diff --git a/blaxel/0-integration-connection/cohere-beamlit-organization.yaml b/blaxel/0-integration-connection/cohere-beamlit-organization.yaml deleted file mode 100644 index b8804da..0000000 --- a/blaxel/0-integration-connection/cohere-beamlit-organization.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: blaxel.ai/v1alpha1 -kind: IntegrationConnection -metadata: - name: cohere-blaxel-organization -spec: - integration: cohere - secret: - apiKey: ${COHERE_API_KEY} diff --git a/blaxel/0-integration-connection/hf-beamlit-organization.yml b/blaxel/0-integration-connection/hf-beamlit-organization.yml deleted file mode 100644 index f3ab75c..0000000 --- a/blaxel/0-integration-connection/hf-beamlit-organization.yml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: blaxel.ai/v1alpha1 -kind: IntegrationConnection -metadata: - name: hf-blaxel-organization -spec: - integration: huggingface - secret: - apiKey: ${HF_API_TOKEN} diff --git a/blaxel/0-integration-connection/mistral-beamlit-organization.yml b/blaxel/0-integration-connection/mistral-beamlit-organization.yml deleted file mode 100644 index 9bc4cc9..0000000 --- a/blaxel/0-integration-connection/mistral-beamlit-organization.yml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: blaxel.ai/v1alpha1 -kind: IntegrationConnection -metadata: - name: mistral-blaxel-organization -spec: - integration: mistral - secret: - apiKey: ${MISTRAL_API_KEY} diff --git a/blaxel/0-integration-connection/openai-beamlit-organization.yml b/blaxel/0-integration-connection/openai-beamlit-organization.yml deleted file mode 100644 index 8969474..0000000 --- a/blaxel/0-integration-connection/openai-beamlit-organization.yml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: blaxel.ai/v1alpha1 -kind: IntegrationConnection -metadata: - name: openai-blaxel-organization -spec: - integration: openai - secret: - apiKey: ${OPENAI_API_KEY} diff --git a/blaxel/0-integration-connection/xai-beamlit-organization.yaml b/blaxel/0-integration-connection/xai-beamlit-organization.yaml deleted file mode 100644 index eafa2f5..0000000 --- a/blaxel/0-integration-connection/xai-beamlit-organization.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: blaxel.ai/v1alpha1 -kind: IntegrationConnection -metadata: - name: xai-blaxel-organization -spec: - integration: xai - secret: - apiKey: ${XAI_API_KEY} diff --git a/blaxel/0-policies/eu-and-na.yml b/blaxel/0-policies/eu-and-na.yml deleted file mode 100644 index 4c30d3b..0000000 --- a/blaxel/0-policies/eu-and-na.yml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: blaxel.ai/v1alpha1 -kind: Policy -metadata: - name: eu-and-na - displayName: EU and NA -spec: - type: location - flavors: [] - locations: - - name: eu - type: continent - - name: na - type: continent \ No newline at end of file diff --git a/blaxel/0-policies/only-eu.yml b/blaxel/0-policies/only-eu.yml deleted file mode 100644 index 30bbc66..0000000 --- a/blaxel/0-policies/only-eu.yml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: blaxel.ai/v1alpha1 -kind: Policy -metadata: - name: only-eu - displayName: Only EU -spec: - type: location - locations: - - name: eu - type: continent \ No newline at end of file diff --git a/blaxel/0-policies/only-us.yml b/blaxel/0-policies/only-us.yml deleted file mode 100644 index f870514..0000000 --- a/blaxel/0-policies/only-us.yml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: blaxel.ai/v1alpha1 -kind: Policy -metadata: - name: only-us - displayName: Only US -spec: - type: location - flavors: [] - locations: - - name: na - type: continent \ No newline at end of file diff --git a/blaxel/1-models/all-minilm-l6-v2.yml b/blaxel/1-models/all-minilm-l6-v2.yml deleted file mode 100644 index a46297c..0000000 --- a/blaxel/1-models/all-minilm-l6-v2.yml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: blaxel.ai/v1alpha1 -kind: Model -metadata: - name: all-minilm-l6-v2 - displayName: All MiniLM L6 v2 -spec: - enabled: true - policies: ["only-eu"] - integrationConnections: - - hf-blaxel-organization - flavors: [] - runtime: - model: sentence-transformers/all-MiniLM-L6-v2 - type: huggingface diff --git a/blaxel/1-models/claude-35-sonnet.yml b/blaxel/1-models/claude-35-sonnet.yml deleted file mode 100644 index a71572f..0000000 --- a/blaxel/1-models/claude-35-sonnet.yml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: blaxel.ai/v1alpha1 -kind: Model -metadata: - name: claude-3-5-sonnet - displayName: Claude 3.5 Sonnet -spec: - enabled: true - policies: ["only-eu"] - integrationConnections: - - anthropic-blaxel-organization - runtime: - model: claude-3-5-sonnet-20241022 - type: anthropic diff --git a/blaxel/1-models/gpt-4o-mini.yml b/blaxel/1-models/gpt-4o-mini.yml deleted file mode 100644 index 2c87f8b..0000000 --- a/blaxel/1-models/gpt-4o-mini.yml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: blaxel.ai/v1alpha1 -kind: Model -metadata: - name: gpt-4o-mini - displayName: GPT 4o Mini -spec: - enabled: true - integrationConnections: - - openai-blaxel-organization - policies: ["only-eu"] - runtime: - model: gpt-4o-mini - type: openai diff --git a/blaxel/1-models/ministral-3b-2410.yml b/blaxel/1-models/ministral-3b-2410.yml deleted file mode 100644 index 535c03b..0000000 --- a/blaxel/1-models/ministral-3b-2410.yml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: blaxel.ai/v1alpha1 -kind: Model -metadata: - name: ministral-3b-2410 - displayName: Ministral 3b 2410 -spec: - enabled: true - policies: ["only-eu"] - integrationConnections: - - mistral-blaxel-organization - runtime: - model: ministral-3b-2410 - type: mistral diff --git a/blaxel/2-functions/github.yml b/blaxel/2-functions/github.yml deleted file mode 100644 index 21df091..0000000 --- a/blaxel/2-functions/github.yml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: blaxel.ai/v1alpha1 -kind: Function -metadata: - name: github - displayName: Github -spec: - enabled: true - policies: ["only-eu"] - configuration: - github_token: - value: ${GH_PAT} - secret: true - storeId: "github" \ No newline at end of file diff --git a/blaxel/2-functions/math.yml b/blaxel/2-functions/math.yml deleted file mode 100644 index 05e45bd..0000000 --- a/blaxel/2-functions/math.yml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: blaxel.ai/v1alpha1 -kind: Function -metadata: - name: math - displayName: Math -spec: - enabled: true - policies: ["only-eu"] - storeId: "math" diff --git a/blaxel/2-functions/search.yml b/blaxel/2-functions/search.yml deleted file mode 100644 index 7a8660f..0000000 --- a/blaxel/2-functions/search.yml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: blaxel.ai/v1alpha1 -kind: Function -metadata: - name: search - displayName: Search -spec: - enabled: true - policies: ["only-eu"] - configuration: - tavily_api_key: - value: ${TAVILY_API_KEY} - secret: true - storeId: "search" \ No newline at end of file diff --git a/blaxel/3-agents/agent-github.yml b/blaxel/3-agents/agent-github.yml deleted file mode 100644 index d32dbdc..0000000 --- a/blaxel/3-agents/agent-github.yml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: blaxel.ai/v1alpha1 -kind: Agent -metadata: - name: agent-github - displayName: Agent Github -spec: - functions: - - github - model: gpt-4o-mini - policies: ["only-eu"] - description: Agent to execute request on github repositories aside from controlplane and store - runtime: - image: ghcr.io/blaxel/agents/blaxel-agent:latest - resources: - limits: - memory: 128M - requests: - memory: 128M diff --git a/blaxel/3-agents/agent-gpt-4o-mini.yml b/blaxel/3-agents/agent-gpt-4o-mini.yml deleted file mode 100644 index 7e2cbfc..0000000 --- a/blaxel/3-agents/agent-gpt-4o-mini.yml +++ /dev/null @@ -1,24 +0,0 @@ -apiVersion: blaxel.ai/v1alpha1 -kind: Agent -metadata: - name: agent-gpt-4o-mini - displayName: Agent GPT 4o mini -spec: - enabled: true - policies: ["only-eu"] - functions: - - search - - math - agentChain: - - name: agent-github - enabled: true - description: "" - model: gpt-4o-mini - description: "" - runtime: - image: ghcr.io/blaxel/agents/blaxel-agent:latest - resources: - limits: - memory: 128M - requests: - memory: 128M From 8787fbbda604cbf9c1eeba3c110c7c679de68f05 Mon Sep 17 00:00:00 2001 From: cploujoux Date: Wed, 25 Jun 2025 09:04:23 -0400 Subject: [PATCH 2/7] Fix environment --- .github/workflows/test-action.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test-action.yml b/.github/workflows/test-action.yml index abde254..5cdd455 100644 --- a/.github/workflows/test-action.yml +++ b/.github/workflows/test-action.yml @@ -14,6 +14,7 @@ env: jobs: test-action: + environment: ${{ env.BL_ENV }} runs-on: ubuntu-latest steps: - name: Checkout @@ -22,8 +23,8 @@ jobs: - name: Test bl-action uses: ./ # This references the action in the current repo with: - workspace: ${{ secrets.BL_WORKSPACE || 'test-workspace' }} - apikey: ${{ secrets.BL_API_KEY || 'test-key' }} + workspace: ${{ vars.BL_WORKSPACE }} + apikey: ${{ secrets.BL_API_KEY }} - name: List agents run: bl get agents - name: List functions @@ -34,6 +35,7 @@ jobs: run: bl get sandboxes test-installation-only: + environment: ${{ env.BL_ENV }} runs-on: ubuntu-latest steps: - name: Checkout @@ -42,12 +44,13 @@ jobs: - name: Test installation without deploy uses: ./ with: - workspace: ${{ secrets.BL_WORKSPACE || 'test-workspace' }} - apikey: ${{ secrets.BL_API_KEY || 'test-key' }} + workspace: ${{ vars.BL_WORKSPACE }} + apikey: ${{ secrets.BL_API_KEY }} # No deploy parameter to test that path test-matrix: runs-on: ${{ matrix.os }} + environment: ${{ env.BL_ENV }} strategy: matrix: os: [ubuntu-latest, ubuntu-20.04] @@ -58,5 +61,5 @@ jobs: - name: Test on ${{ matrix.os }} uses: ./ with: - workspace: ${{ secrets.BL_WORKSPACE || 'test-workspace' }} - apikey: ${{ secrets.BL_API_KEY || 'test-key' }} \ No newline at end of file + workspace: ${{ vars.BL_WORKSPACE }} + apikey: ${{ secrets.BL_API_KEY }} \ No newline at end of file From 7844cae3c121c9a8c861889f4dc272ae855bca2b Mon Sep 17 00:00:00 2001 From: cploujoux Date: Wed, 25 Jun 2025 09:05:10 -0400 Subject: [PATCH 3/7] Fix variable usage github action --- .github/workflows/test-action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-action.yml b/.github/workflows/test-action.yml index 5cdd455..a8b5107 100644 --- a/.github/workflows/test-action.yml +++ b/.github/workflows/test-action.yml @@ -14,7 +14,7 @@ env: jobs: test-action: - environment: ${{ env.BL_ENV }} + environment: ${{ vars.BL_ENV }} runs-on: ubuntu-latest steps: - name: Checkout @@ -35,7 +35,7 @@ jobs: run: bl get sandboxes test-installation-only: - environment: ${{ env.BL_ENV }} + environment: ${{ vars.BL_ENV }} runs-on: ubuntu-latest steps: - name: Checkout @@ -50,7 +50,7 @@ jobs: test-matrix: runs-on: ${{ matrix.os }} - environment: ${{ env.BL_ENV }} + environment: ${{ vars.BL_ENV }} strategy: matrix: os: [ubuntu-latest, ubuntu-20.04] From ae14f101c136576ddff2bc50c1cde05fde3ae490 Mon Sep 17 00:00:00 2001 From: cploujoux Date: Wed, 25 Jun 2025 09:14:25 -0400 Subject: [PATCH 4/7] Fix environment --- .github/workflows/test-action.yml | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test-action.yml b/.github/workflows/test-action.yml index a8b5107..13b0102 100644 --- a/.github/workflows/test-action.yml +++ b/.github/workflows/test-action.yml @@ -14,7 +14,7 @@ env: jobs: test-action: - environment: ${{ vars.BL_ENV }} + environment: ${{ github.ref == 'refs/heads/main' && 'prod' || 'dev' }} runs-on: ubuntu-latest steps: - name: Checkout @@ -34,23 +34,9 @@ jobs: - name: List sandboxes run: bl get sandboxes - test-installation-only: - environment: ${{ vars.BL_ENV }} - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Test installation without deploy - uses: ./ - with: - workspace: ${{ vars.BL_WORKSPACE }} - apikey: ${{ secrets.BL_API_KEY }} - # No deploy parameter to test that path - test-matrix: runs-on: ${{ matrix.os }} - environment: ${{ vars.BL_ENV }} + environment: ${{ github.ref == 'refs/heads/main' && 'prod' || 'dev' }} strategy: matrix: os: [ubuntu-latest, ubuntu-20.04] From 71c9ad20e697223a09fe27748f772a0ec74584f6 Mon Sep 17 00:00:00 2001 From: cploujoux Date: Wed, 25 Jun 2025 09:41:12 -0400 Subject: [PATCH 5/7] Run CI again --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 657929d..d45f743 100644 --- a/README.md +++ b/README.md @@ -56,4 +56,4 @@ Contributions are welcome! Please open an issue or submit a pull request for any ## Support -For any questions or issues, please open an issue in this repository. +For any questions or issues, please open an issue in this repository. \ No newline at end of file From 455ff34e16b6d89bf9a665f59f154cff7ba77adc Mon Sep 17 00:00:00 2001 From: cploujoux Date: Wed, 25 Jun 2025 09:50:15 -0400 Subject: [PATCH 6/7] Add checkout to blaxel-ai toolkit to be sure the download is working --- action.yml | 113 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 91 insertions(+), 22 deletions(-) diff --git a/action.yml b/action.yml index 44ecc35..3fe801a 100644 --- a/action.yml +++ b/action.yml @@ -18,42 +18,108 @@ inputs: runs: using: "composite" steps: + - name: Checkout toolkit repository + uses: actions/checkout@v4 + with: + repository: blaxel-ai/toolkit + path: .bl-toolkit + clean: false - name: Install blaxel shell: bash run: | mkdir -p $HOME/.local/bin - # Function to download with retry logic - download_with_retry() { - local url=$1 - local max_attempts=5 - local delay=2 - local attempt=1 + # Function to download with multiple fallback methods + download_with_fallbacks() { + local repo=$1 + local path=$2 + local output_file=$3 + local max_attempts=3 - while [ $attempt -le $max_attempts ]; do - if curl -fsSL --connect-timeout 30 --max-time 300 "$url" | BINDIR=$HOME/.local/bin sh; then + echo "Downloading installation script..." + + # Method 1: Use locally checked out file (most reliable) + if [ -f ".bl-toolkit/$path" ]; then + echo "Using locally checked out installation script..." + cp ".bl-toolkit/$path" "$output_file" + echo "✓ Using local checkout" + return 0 + fi + + # Method 2: GitHub API (fallback) + echo "Trying GitHub API..." + if curl -fsSL \ + --connect-timeout 30 \ + --max-time 300 \ + -H "Accept: application/vnd.github.v3.raw" \ + -H "User-Agent: bl-action" \ + "https://api.github.com/repos/$repo/contents/$path" \ + -o "$output_file" 2>/dev/null; then + echo "✓ Downloaded via GitHub API" + return 0 + fi + + # Method 3: raw.githubusercontent.com with explicit TLS + echo "Trying raw.githubusercontent.com with TLS 1.2..." + if curl -fsSL \ + --connect-timeout 30 \ + --max-time 300 \ + --tlsv1.2 \ + -H "User-Agent: bl-action" \ + "https://raw.githubusercontent.com/$repo/main/$path" \ + -o "$output_file" 2>/dev/null; then + echo "✓ Downloaded via raw.githubusercontent.com" + return 0 + fi + + # Method 4: wget with different user agent + echo "Trying wget..." + if command -v wget >/dev/null 2>&1; then + if wget --secure-protocol=TLSv1_2 \ + --timeout=30 \ + --tries=1 \ + --user-agent="bl-action" \ + -O "$output_file" \ + "https://raw.githubusercontent.com/$repo/main/$path" 2>/dev/null; then + echo "✓ Downloaded via wget" return 0 - else - local exit_code=$? + fi + fi - if [ $attempt -eq $max_attempts ]; then - return $exit_code - fi + # Method 5: GitHub tarball extraction (last resort) + echo "Trying GitHub tarball extraction..." + local temp_dir="/tmp/bl-install-$$" + mkdir -p "$temp_dir" - sleep $delay - delay=$((delay * 2)) # Exponential backoff - attempt=$((attempt + 1)) + if curl -fsSL \ + --connect-timeout 30 \ + --max-time 300 \ + -H "User-Agent: bl-action" \ + "https://api.github.com/repos/$repo/tarball/main" | \ + tar -xz -C "$temp_dir" --strip-components=1 2>/dev/null; then + + if [ -f "$temp_dir/$path" ]; then + cp "$temp_dir/$path" "$output_file" + rm -rf "$temp_dir" + echo "✓ Downloaded via tarball extraction" + return 0 fi - done + fi + + rm -rf "$temp_dir" + return 1 } - # Download the installation script with retry logic - INSTALL_URL="https://raw.githubusercontent.com/blaxel-ai/toolkit/main/install.sh" + # Download the installation script with fallback methods + INSTALL_SCRIPT="/tmp/install.sh" - if [ "$BL_ENV" = "dev" ]; then - download_with_retry "$INSTALL_URL" + if download_with_fallbacks "blaxel-ai/toolkit" "install.sh" "$INSTALL_SCRIPT"; then + chmod +x "$INSTALL_SCRIPT" + BINDIR=$HOME/.local/bin sh "$INSTALL_SCRIPT" else - download_with_retry "$INSTALL_URL" + echo "Error: Failed to download installation script with all methods" + echo "Please check your network connection and GitHub access" + exit 1 fi # Verify installation @@ -65,6 +131,9 @@ runs: # Create symlink and add to PATH cp $HOME/.local/bin/blaxel $HOME/.local/bin/bl echo "$HOME/.local/bin" >> $GITHUB_PATH + + # Clean up checkout + rm -rf .bl-toolkit - name: Login to Blaxel shell: bash env: From 2f1cc52e55965c4f049fe2f9163308644b67134f Mon Sep 17 00:00:00 2001 From: cploujoux Date: Wed, 25 Jun 2025 09:53:50 -0400 Subject: [PATCH 7/7] Remove ubuntu 20.04 cause the job gets cancelled We want to test other distro --- .github/workflows/test-action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-action.yml b/.github/workflows/test-action.yml index 13b0102..31492b8 100644 --- a/.github/workflows/test-action.yml +++ b/.github/workflows/test-action.yml @@ -39,7 +39,7 @@ jobs: environment: ${{ github.ref == 'refs/heads/main' && 'prod' || 'dev' }} strategy: matrix: - os: [ubuntu-latest, ubuntu-20.04] + os: [ubuntu-latest] steps: - name: Checkout uses: actions/checkout@v4