Skip to content

Commit 2cc30aa

Browse files
committed
Configure brew test-bot
1 parent 40f8194 commit 2cc30aa

File tree

3 files changed

+102
-0
lines changed

3 files changed

+102
-0
lines changed

.github/scripts/check-update.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import json
1111
import os
12+
import re
1213
import subprocess
1314
from enum import Enum
1415

@@ -89,7 +90,31 @@ def return_package_name_from_formula(formula):
8990
return Package.SQLITE
9091

9192

93+
# When defining a Homebrew formula, if the version value is included in the URL,
94+
# the command 'brew audit --strict [formula]' fails. Therefore, the version metadata
95+
# is commented out in the formula and is only temporarily uncommented during livecheck.
96+
def uncomment_version_in_formulae():
97+
formulae = ["sqlb-openssl@3", "sqlb-qt@5", "sqlb-sqlcipher"]
98+
formulae_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..", "Formula")
99+
100+
for formula in formulae:
101+
try:
102+
formula_path = os.path.join(formulae_path, formula + ".rb")
103+
with open(formula_path, "r", encoding="utf-8") as f:
104+
lines = f.readlines()
105+
106+
uncommented_lines = [re.sub(r'^\s+# (version\s*.*)', r' \1', line) for line in lines]
107+
108+
with open(formula_path, "w", encoding="utf-8") as f:
109+
f.writelines(uncommented_lines)
110+
except FileNotFoundError:
111+
print(f"File {formula} not found")
112+
except Exception as e:
113+
print(f"Error while uncommenting version in {formula}: {e}")
114+
115+
92116
if __name__ == "__main__":
117+
uncomment_version_in_formulae()
93118
data = json.loads(
94119
subprocess.run(
95120
"brew livecheck sqlb-openssl sqlb-qt sqlb-sqlcipher sqlb-sqlite --json",

.github/workflows/publish.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: brew pr-pull
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- labeled
7+
8+
jobs:
9+
pr-pull:
10+
if: contains(github.event.pull_request.labels.*.name, 'pr-pull')
11+
runs-on: ubuntu-22.04
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
steps:
16+
- name: Set up Homebrew
17+
uses: Homebrew/actions/setup-homebrew@master
18+
19+
- name: Set up git
20+
uses: Homebrew/actions/git-user-config@master
21+
22+
- name: Pull bottles
23+
env:
24+
HOMEBREW_GITHUB_API_TOKEN: ${{ github.token }}
25+
PULL_REQUEST: ${{ github.event.pull_request.number }}
26+
run: brew pr-pull --debug --tap="$GITHUB_REPOSITORY" "$PULL_REQUEST"
27+
28+
- name: Push commits
29+
uses: Homebrew/actions/git-try-push@master
30+
with:
31+
token: ${{ github.token }}
32+
branch: main
33+
34+
- name: Delete branch
35+
if: github.event.pull_request.head.repo.fork == false
36+
env:
37+
BRANCH: ${{ github.event.pull_request.head.ref }}
38+
run: git push --delete origin "$BRANCH"

.github/workflows/tests.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: brew test-bot
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
test-bot:
11+
strategy:
12+
matrix:
13+
os: [macos-14]
14+
runs-on: ${{ matrix.os }}
15+
steps:
16+
- name: Set up Homebrew
17+
id: set-up-homebrew
18+
uses: Homebrew/actions/setup-homebrew@master
19+
20+
- name: Cache Homebrew Bundler RubyGems
21+
uses: actions/cache@v4
22+
with:
23+
path: ${{ steps.set-up-homebrew.outputs.gems-path }}
24+
key: ${{ matrix.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }}
25+
restore-keys: ${{ matrix.os }}-rubygems-
26+
27+
- run: brew test-bot --only-cleanup-before
28+
29+
- run: brew test-bot --only-setup
30+
31+
- run: brew test-bot --only-formulae
32+
if: github.event_name == 'pull_request'
33+
34+
- name: Upload bottles as artifact
35+
if: always() && github.event_name == 'pull_request'
36+
uses: actions/upload-artifact@v4
37+
with:
38+
name: bottles_${{ matrix.os }}
39+
path: '*.bottle.*'

0 commit comments

Comments
 (0)