Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions .github/workflows/build-and-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Build and Release

on:
release:
types: [ created ]

jobs:
# Use the reusable workflow for building binaries
build:
uses: ./.github/workflows/build-template.yaml
with:
python-version: "3.11"
python-versions-matrix: '["3.11"]'
# We build on an older Ubuntu as pyinstaller binaries are forward-compatible not backwards-compatible
# See https://pyinstaller.org/en/stable/usage.html?highlight=glibc#making-gnu-linux-apps-forward-compatible:~:text=The%20solution%20is%20to%20always%20build%20your%20app%20on%20the%20oldest%20version%20of%20GNU/Linux%20you%20mean%20to%20support.%20It%20should%20continue%20to%20work%20with%20the%20libc%20found%20on%20newer%20versions.
# TODO: for similar reasons, we may want to build on older Windows/MacOS versions as well
os-matrix: '["ubuntu-22.04", "windows-latest", "macos-latest"]'
is-release: true
secrets: inherit

# Latest release check job
check-latest:
name: Check if Latest Release
needs: build
runs-on: ubuntu-22.04
outputs:
IS_LATEST: ${{ steps.check-latest.outputs.release == github.ref_name }}
steps:
- id: check-latest
uses: pozetroninc/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
excludes: prerelease, draft

# macOS hash calculation job
mac-hash:
name: Calculate macOS Hash
needs: check-latest
runs-on: ubuntu-latest
if: needs.check-latest.outputs.IS_LATEST
outputs:
MAC_BUILD_HASH: ${{ steps.calc-hash.outputs.MAC_BUILD_HASH }}
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Download MacOS artifact
uses: actions/download-artifact@v4
with:
name: holmes-macos-latest-${{ github.ref_name }}
- name: Calculate hash
id: calc-hash
run: echo "::set-output name=MAC_BUILD_HASH::$(sha256sum holmes-macos-latest-${{ github.ref_name }}.zip | awk '{print $1}')"

# Linux hash calculation job
linux-hash:
name: Calculate Linux Hash
needs: check-latest
runs-on: ubuntu-latest
if: needs.check-latest.outputs.IS_LATEST
outputs:
LINUX_BUILD_HASH: ${{ steps.calc-hash.outputs.LINUX_BUILD_HASH }}
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Download Linux artifact
uses: actions/download-artifact@v4
with:
name: holmes-ubuntu-22.04-${{ github.ref_name }}
- name: Calculate hash
id: calc-hash
run: echo "::set-output name=LINUX_BUILD_HASH::$(sha256sum holmes-ubuntu-22.04-${{ github.ref_name }}.zip | awk '{print $1}')"

# Homebrew formula update job
update-formula:
name: Update Homebrew Formula
needs: [ mac-hash, linux-hash ]
runs-on: ubuntu-latest
if: ${{ !github.event.release.prerelease }}
steps:
- name: Checkout homebrew-holmesgpt repository
uses: actions/checkout@v2
with:
repository: robusta-dev/homebrew-holmesgpt
token: ${{ secrets.MULTIREPO_GITHUB_TOKEN }}
- name: Update holmesgpt.rb formula
run: |
MAC_BUILD_HASH=${{ needs.mac-hash.outputs.MAC_BUILD_HASH }}
LINUX_BUILD_HASH=${{ needs.linux-hash.outputs.LINUX_BUILD_HASH }}
TAG_NAME=${{ github.ref_name }}
awk 'NR==6{$0=" url \"https://github.com/robusta-dev/holmesgpt/releases/download/'"$TAG_NAME"'/holmes-macos-latest-'"$TAG_NAME"'.zip\""}1' ./Formula/holmesgpt.rb > temp && mv temp ./Formula/holmesgpt.rb
awk 'NR==7{$0=" sha256 \"'$MAC_BUILD_HASH'\""}1' ./Formula/holmesgpt.rb > temp && mv temp ./Formula/holmesgpt.rb
awk 'NR==9{$0=" url \"https://github.com/robusta-dev/holmesgpt/releases/download/'"$TAG_NAME"'/holmes-ubuntu-22.04-'"$TAG_NAME"'.zip\""}1' ./Formula/holmesgpt.rb > temp && mv temp ./Formula/holmesgpt.rb
awk 'NR==10{$0=" sha256 \"'$LINUX_BUILD_HASH'\""}1' ./Formula/holmesgpt.rb > temp && mv temp ./Formula/holmesgpt.rb
- name: Commit and push changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git commit -am "Update formula for release ${TAG_NAME}"
git push
92 changes: 25 additions & 67 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,81 +2,39 @@
# we test this on each commit/PR to catch build problems early
name: Build and test HolmesGPT

on: [push, pull_request, workflow_dispatch]
on: [ push, pull_request, workflow_dispatch ]

jobs:
# Pre-commit checks job
check:
name: Pre-commit checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
virtualenvs-path: .venv
installer-parallel: true
- name: Install dependencies
run: poetry install --no-interaction --no-root
- uses: pre-commit/[email protected]
build:
needs: check
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]

runs-on: ubuntu-latest
- uses: actions/checkout@v4

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
virtualenvs-path: .venv
installer-parallel: true

- name: Install Python dependencies and build
# if you change something here, you must also change it in .github/workflows/build-binaries-and-brew.yaml
run: |
python -m pip install --upgrade pip setuptools pyinstaller
- name: Install dependencies
run: poetry install --no-interaction --no-root

curl -sSL https://install.python-poetry.org | python3 - --version 1.4.0
poetry config virtualenvs.create false
poetry install --no-root
- uses: pre-commit/[email protected]

sudo apt-get install -y binutils
pyinstaller holmes_cli.py \
--name holmes \
--add-data 'holmes/plugins/runbooks/*:holmes/plugins/runbooks' \
--add-data 'holmes/plugins/prompts/*:holmes/plugins/prompts' \
--add-data 'holmes/plugins/toolsets/*:holmes/plugins/toolsets' \
--add-data 'holmes/plugins/toolsets/coralogix*:holmes/plugins/toolsets/coralogix' \
--add-data 'holmes/plugins/toolsets/grafana*:holmes/plugins/toolsets/grafana' \
--add-data 'holmes/plugins/toolsets/internet*:holmes/plugins/toolsets/internet' \
--add-data 'holmes/plugins/toolsets/opensearch*:holmes/plugins/toolsets/opensearch' \
--add-data 'holmes/plugins/toolsets/prometheus*:holmes/plugins/toolsets/prometheus' \
--hidden-import=tiktoken_ext.openai_public \
--hidden-import=tiktoken_ext \
--hiddenimport litellm.llms.tokenizers \
--hiddenimport litellm.litellm_core_utils.tokenizers \
--collect-data litellm
ls dist

- name: Run tests
shell: bash
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
poetry run pytest -m "not llm"

- name: Test the binary
shell: bash
run: |
dist/holmes/holmes version
if [ $? -ne 0 ]; then
echo "Binary test failed"
exit 1
fi
echo "Binary test passed"
build-and-test:
needs: check
if: always() && (needs.check.result == 'success' || needs.check.result == 'skipped')
uses: ./.github/workflows/build-template.yaml
with:
python-versions-matrix: '["3.10", "3.11", "3.12"]'
os-matrix: '["ubuntu-latest", "windows-latest", "macos-latest"]'
is-release: false
secrets: inherit
Loading
Loading