Skip to content

Commit d47202b

Browse files
committed
use template for test and release
1 parent e511986 commit d47202b

File tree

4 files changed

+336
-376
lines changed

4 files changed

+336
-376
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Build and Release
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
# Use the reusable workflow for building binaries
9+
build:
10+
uses: ./.github/workflows/build-template.yaml
11+
with:
12+
python-version: "3.11"
13+
python-versions-matrix: '["3.11"]'
14+
# We build on an older Ubuntu as pyinstaller binaries are forward-compatible not backwards-compatible
15+
# 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.
16+
# TODO: for similar reasons, we may want to build on older Windows/MacOS versions as well
17+
os-matrix: '["ubuntu-22.04", "windows-latest", "macos-latest"]'
18+
run-tests: false
19+
is-release: true
20+
secrets: inherit
21+
22+
# Latest release check job
23+
check-latest:
24+
name: Check if Latest Release
25+
needs: build
26+
runs-on: ubuntu-22.04
27+
outputs:
28+
IS_LATEST: ${{ steps.check-latest.outputs.release == github.ref_name }}
29+
steps:
30+
- id: check-latest
31+
uses: pozetroninc/[email protected]
32+
with:
33+
token: ${{ secrets.GITHUB_TOKEN }}
34+
repository: ${{ github.repository }}
35+
excludes: prerelease, draft
36+
37+
# macOS hash calculation job
38+
mac-hash:
39+
name: Calculate macOS Hash
40+
needs: check-latest
41+
runs-on: ubuntu-latest
42+
if: needs.check-latest.outputs.IS_LATEST
43+
outputs:
44+
MAC_BUILD_HASH: ${{ steps.calc-hash.outputs.MAC_BUILD_HASH }}
45+
steps:
46+
- name: Checkout Repository
47+
uses: actions/checkout@v2
48+
- name: Download MacOS artifact
49+
uses: actions/download-artifact@v4
50+
with:
51+
name: holmes-macos-latest-${{ github.ref_name }}
52+
- name: Calculate hash
53+
id: calc-hash
54+
run: echo "::set-output name=MAC_BUILD_HASH::$(sha256sum holmes-macos-latest-${{ github.ref_name }}.zip | awk '{print $1}')"
55+
56+
# Linux hash calculation job
57+
linux-hash:
58+
name: Calculate Linux Hash
59+
needs: check-latest
60+
runs-on: ubuntu-latest
61+
if: needs.check-latest.outputs.IS_LATEST
62+
outputs:
63+
LINUX_BUILD_HASH: ${{ steps.calc-hash.outputs.LINUX_BUILD_HASH }}
64+
steps:
65+
- name: Checkout Repository
66+
uses: actions/checkout@v2
67+
- name: Download Linux artifact
68+
uses: actions/download-artifact@v4
69+
with:
70+
name: holmes-ubuntu-22.04-${{ github.ref_name }}
71+
- name: Calculate hash
72+
id: calc-hash
73+
run: echo "::set-output name=LINUX_BUILD_HASH::$(sha256sum holmes-ubuntu-22.04-${{ github.ref_name }}.zip | awk '{print $1}')"
74+
75+
# Homebrew formula update job
76+
update-formula:
77+
name: Update Homebrew Formula
78+
needs: [mac-hash, linux-hash]
79+
runs-on: ubuntu-latest
80+
if: ${{ !github.event.release.prerelease }}
81+
steps:
82+
- name: Checkout homebrew-holmesgpt repository
83+
uses: actions/checkout@v2
84+
with:
85+
repository: robusta-dev/homebrew-holmesgpt
86+
token: ${{ secrets.MULTIREPO_GITHUB_TOKEN }}
87+
- name: Update holmesgpt.rb formula
88+
run: |
89+
MAC_BUILD_HASH=${{ needs.mac-hash.outputs.MAC_BUILD_HASH }}
90+
LINUX_BUILD_HASH=${{ needs.linux-hash.outputs.LINUX_BUILD_HASH }}
91+
TAG_NAME=${{ github.ref_name }}
92+
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
93+
awk 'NR==7{$0=" sha256 \"'$MAC_BUILD_HASH'\""}1' ./Formula/holmesgpt.rb > temp && mv temp ./Formula/holmesgpt.rb
94+
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
95+
awk 'NR==10{$0=" sha256 \"'$LINUX_BUILD_HASH'\""}1' ./Formula/holmesgpt.rb > temp && mv temp ./Formula/holmesgpt.rb
96+
- name: Commit and push changes
97+
run: |
98+
git config --local user.email "[email protected]"
99+
git config --local user.name "GitHub Action"
100+
git commit -am "Update formula for release ${TAG_NAME}"
101+
git push

.github/workflows/build-and-test.yaml

Lines changed: 16 additions & 179 deletions
Original file line numberDiff line numberDiff line change
@@ -5,200 +5,37 @@ name: Build and test HolmesGPT
55
on: [push, pull_request, workflow_dispatch]
66

77
jobs:
8+
# Pre-commit checks job
89
check:
910
name: Pre-commit checks
1011
runs-on: ubuntu-latest
1112
steps:
1213
- uses: actions/checkout@v4
14+
1315
- uses: actions/setup-python@v5
16+
with:
17+
python-version: '3.11'
18+
1419
- name: Install Poetry
1520
uses: snok/install-poetry@v1
1621
with:
1722
virtualenvs-create: true
1823
virtualenvs-in-project: true
1924
virtualenvs-path: .venv
2025
installer-parallel: true
26+
2127
- name: Install dependencies
2228
run: poetry install --no-interaction --no-root
29+
2330
- uses: pre-commit/[email protected]
24-
build:
25-
needs: check
26-
strategy:
27-
matrix:
28-
python-version: ["3.10", "3.11", "3.12"]
29-
30-
runs-on: ubuntu-latest
31-
32-
steps:
33-
- uses: actions/checkout@v2
34-
35-
- name: Set up Python ${{ matrix.python-version }}
36-
uses: actions/setup-python@v2
37-
with:
38-
python-version: ${{ matrix.python-version }}
39-
40-
- name: Install Python dependencies and build
41-
# if you change something here, you must also change it in .github/workflows/build-binaries-and-brew.yaml
42-
run: |
43-
python -m pip install --upgrade pip setuptools pyinstaller
44-
45-
curl -sSL https://install.python-poetry.org | python3 - --version 1.4.0
46-
poetry config virtualenvs.create false
47-
poetry install --no-root
4831

49-
sudo apt-get install -y binutils
50-
pyinstaller holmes_cli.py \
51-
--name holmes \
52-
--add-data 'holmes/plugins/runbooks/*:holmes/plugins/runbooks' \
53-
--add-data 'holmes/plugins/prompts/*:holmes/plugins/prompts' \
54-
--add-data 'holmes/plugins/toolsets/*:holmes/plugins/toolsets' \
55-
--add-data 'holmes/plugins/toolsets/coralogix*:holmes/plugins/toolsets/coralogix' \
56-
--add-data 'holmes/plugins/toolsets/grafana*:holmes/plugins/toolsets/grafana' \
57-
--add-data 'holmes/plugins/toolsets/internet*:holmes/plugins/toolsets/internet' \
58-
--add-data 'holmes/plugins/toolsets/opensearch*:holmes/plugins/toolsets/opensearch' \
59-
--add-data 'holmes/plugins/toolsets/prometheus*:holmes/plugins/toolsets/prometheus' \
60-
--hidden-import=tiktoken_ext.openai_public \
61-
--hidden-import=tiktoken_ext \
62-
--hiddenimport litellm.llms.tokenizers \
63-
--hiddenimport litellm.litellm_core_utils.tokenizers \
64-
--collect-data litellm
65-
ls dist
66-
67-
- name: Run tests
68-
shell: bash
69-
env:
70-
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
71-
run: |
72-
poetry run pytest -m "not llm"
73-
74-
- name: Test the binary
75-
shell: bash
76-
run: |
77-
dist/holmes/holmes version
78-
if [ $? -ne 0 ]; then
79-
echo "Binary test failed"
80-
exit 1
81-
fi
82-
echo "Binary test passed"
83-
84-
build-windows:
32+
build-and-test:
8533
needs: check
86-
strategy:
87-
matrix:
88-
python-version: ["3.10", "3.11", "3.12"]
89-
90-
runs-on: windows-latest
91-
92-
steps:
93-
- uses: actions/checkout@v4
94-
95-
- name: Set up Python ${{ matrix.python-version }}
96-
uses: actions/setup-python@v4
97-
with:
98-
python-version: ${{ matrix.python-version }}
99-
100-
- name: Install Python dependencies and build
101-
shell: pwsh
102-
run: |
103-
python -m pip install --upgrade pip setuptools pyinstaller
104-
105-
# Install Poetry using pip for consistency
106-
pip install poetry==1.4.0
107-
poetry config virtualenvs.create false
108-
poetry install --no-root
109-
110-
# Build binary with PyInstaller (PowerShell backticks and Windows ';' separators)
111-
pyinstaller holmes_cli.py `
112-
--name holmes `
113-
--add-data "holmes/plugins/runbooks/*;holmes/plugins/runbooks" `
114-
--add-data "holmes/plugins/prompts/*;holmes/plugins/prompts" `
115-
--add-data "holmes/plugins/toolsets/*;holmes/plugins/toolsets" `
116-
--add-data "holmes/plugins/toolsets/coralogix*;holmes/plugins/toolsets/coralogix" `
117-
--add-data "holmes/plugins/toolsets/grafana*;holmes/plugins/toolsets/grafana" `
118-
--add-data "holmes/plugins/toolsets/internet*;holmes/plugins/toolsets/internet" `
119-
--add-data "holmes/plugins/toolsets/opensearch*;holmes/plugins/toolsets/opensearch" `
120-
--add-data "holmes/plugins/toolsets/prometheus*;holmes/plugins/toolsets/prometheus" `
121-
--hidden-import=tiktoken_ext.openai_public `
122-
--hidden-import=tiktoken_ext `
123-
--hidden-import=litellm.llms.tokenizers `
124-
--hidden-import=litellm.litellm_core_utils.tokenizers `
125-
--collect-data litellm
126-
dir dist
127-
128-
- name: Run tests
129-
shell: powershell
130-
env:
131-
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
132-
run: |
133-
poetry run pytest -m "not llm"
134-
135-
- name: Test the binary
136-
shell: powershell
137-
run: |
138-
& "dist\holmes\holmes.exe" version
139-
if ($LASTEXITCODE -ne 0) {
140-
Write-Host "Binary test failed"
141-
exit 1
142-
}
143-
Write-Host "Binary test passed"
144-
145-
build-macos:
146-
needs: check
147-
strategy:
148-
matrix:
149-
python-version: ["3.10", "3.11", "3.12"]
150-
151-
runs-on: macos-latest
152-
153-
steps:
154-
- uses: actions/checkout@v4
155-
156-
- name: Set up Python ${{ matrix.python-version }}
157-
uses: actions/setup-python@v5
158-
with:
159-
python-version: ${{ matrix.python-version }}
160-
- name: Install Python dependencies and build
161-
run: |
162-
python -m pip install --upgrade pip setuptools pyinstaller
163-
164-
# Install Poetry using curl (consistent with Linux)
165-
curl -sSL https://install.python-poetry.org | python3 - --version 1.4.0
166-
poetry config virtualenvs.create false
167-
poetry install --no-root
168-
169-
# Install macOS system dependencies
170-
brew install unixodbc
171-
172-
pyinstaller holmes_cli.py \
173-
--name holmes \
174-
--add-data 'holmes/plugins/runbooks/*:holmes/plugins/runbooks' \
175-
--add-data 'holmes/plugins/prompts/*:holmes/plugins/prompts' \
176-
--add-data 'holmes/plugins/toolsets/*:holmes/plugins/toolsets' \
177-
--add-data 'holmes/plugins/toolsets/coralogix*:holmes/plugins/toolsets/coralogix' \
178-
--add-data 'holmes/plugins/toolsets/grafana*:holmes/plugins/toolsets/grafana' \
179-
--add-data 'holmes/plugins/toolsets/internet*:holmes/plugins/toolsets/internet' \
180-
--add-data 'holmes/plugins/toolsets/opensearch*:holmes/plugins/toolsets/opensearch' \
181-
--add-data 'holmes/plugins/toolsets/prometheus*:holmes/plugins/toolsets/prometheus' \
182-
--hidden-import=tiktoken_ext.openai_public \
183-
--hidden-import=tiktoken_ext \
184-
--hidden-import=litellm.llms.tokenizers \
185-
--hidden-import=litellm.litellm_core_utils.tokenizers \
186-
--collect-data litellm
187-
ls dist
188-
189-
- name: Run tests
190-
shell: bash
191-
env:
192-
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
193-
run: |
194-
poetry run pytest -m "not llm"
195-
196-
- name: Test the binary
197-
shell: bash
198-
run: |
199-
dist/holmes/holmes version
200-
if [ $? -ne 0 ]; then
201-
echo "Binary test failed"
202-
exit 1
203-
fi
204-
echo "Binary test passed"
34+
if: always() && (needs.check.result == 'success' || needs.check.result == 'skipped')
35+
uses: ./.github/workflows/build-template.yaml
36+
with:
37+
python-versions-matrix: '["3.10", "3.11", "3.12"]'
38+
os-matrix: '["ubuntu-latest", "windows-latest", "macos-latest"]'
39+
run-tests: true
40+
is-release: false
41+
secrets: inherit

0 commit comments

Comments
 (0)