Skip to content

Commit 9e2717b

Browse files
authored
fix(action): check and download dependencies if required (#74)
1 parent 0f15e75 commit 9e2717b

2 files changed

Lines changed: 94 additions & 0 deletions

File tree

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: 'Install and verify dependencies for the Benchmarkoor GitHub Action'
2+
description: 'Install required dependencies for Benchmarkoor (zip/unzip, GitHub CLI)'
3+
author: 'ethpandaops'
4+
5+
runs:
6+
using: 'composite'
7+
steps:
8+
- name: Install zip/unzip if not present
9+
shell: bash
10+
run: |
11+
# Check if zip and unzip are available
12+
ZIP_MISSING=false
13+
UNZIP_MISSING=false
14+
15+
if ! command -v zip &> /dev/null; then
16+
echo "zip command not found"
17+
ZIP_MISSING=true
18+
fi
19+
20+
if ! command -v unzip &> /dev/null; then
21+
echo "unzip command not found"
22+
UNZIP_MISSING=true
23+
fi
24+
25+
if [ "$ZIP_MISSING" = true ] || [ "$UNZIP_MISSING" = true ]; then
26+
echo "Installing zip/unzip utilities..."
27+
28+
# Detect OS
29+
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
30+
# Linux - assume Ubuntu/Debian
31+
sudo apt update
32+
sudo apt install -y zip unzip
33+
elif [[ "$OSTYPE" == "darwin"* ]]; then
34+
# macOS - zip/unzip should be pre-installed, but check with brew if needed
35+
if command -v brew &> /dev/null; then
36+
if [ "$ZIP_MISSING" = true ]; then
37+
brew install zip
38+
fi
39+
# unzip is typically pre-installed on macOS
40+
else
41+
echo "zip/unzip utilities appear to be missing and Homebrew not found"
42+
echo "Please install zip/unzip manually"
43+
exit 1
44+
fi
45+
else
46+
echo "Unsupported OS. Please install zip/unzip manually"
47+
exit 1
48+
fi
49+
50+
echo "zip/unzip utilities installed successfully"
51+
else
52+
echo "zip and unzip are already available"
53+
zip --version || true
54+
unzip -v || true
55+
fi
56+
57+
- name: Install GitHub CLI if not present
58+
shell: bash
59+
run: |
60+
if ! command -v gh &> /dev/null; then
61+
echo "GitHub CLI not found, installing..."
62+
63+
# Detect OS
64+
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
65+
# Linux - assume Ubuntu/Debian
66+
(type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) \
67+
&& mkdir -p -m 755 /etc/apt/keyrings \
68+
&& out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
69+
&& cat $out | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
70+
&& chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
71+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null
72+
sudo apt update
73+
sudo apt install -y gh
74+
elif [[ "$OSTYPE" == "darwin"* ]]; then
75+
# macOS
76+
if command -v brew &> /dev/null; then
77+
brew install gh
78+
else
79+
echo "Homebrew not found. Please install GitHub CLI manually: https://cli.github.com/"
80+
exit 1
81+
fi
82+
else
83+
echo "Unsupported OS. Please install GitHub CLI manually: https://cli.github.com/"
84+
exit 1
85+
fi
86+
87+
echo "GitHub CLI installed successfully"
88+
else
89+
echo "GitHub CLI already installed"
90+
gh --version
91+
fi

action.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ inputs:
4343
runs:
4444
using: 'composite'
4545
steps:
46+
- name: Verify and install dependencies
47+
uses: ethpandaops/benchmarkoor/.github/actions/dependencies@fix-gh-action-deps
48+
4649
- name: Build Docker image locally
4750
if: inputs.image == ''
4851
shell: bash

0 commit comments

Comments
 (0)