Skip to content

Commit 1db5530

Browse files
committed
ii
0 parents  commit 1db5530

File tree

17 files changed

+5619
-0
lines changed

17 files changed

+5619
-0
lines changed

.github/workflows/ci.yml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
test:
14+
name: Test
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
os: [ubuntu-latest, macos-latest, windows-latest]
19+
rust: [stable]
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Install Rust
24+
uses: dtolnay/rust-toolchain@master
25+
with:
26+
toolchain: ${{ matrix.rust }}
27+
components: rustfmt, clippy
28+
29+
- name: Cache cargo registry
30+
uses: actions/cache@v4
31+
with:
32+
path: |
33+
~/.cargo/bin/
34+
~/.cargo/registry/index/
35+
~/.cargo/registry/cache/
36+
~/.cargo/git/db/
37+
target/
38+
key: ${{ runner.os }}-cargo-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
39+
restore-keys: |
40+
${{ runner.os }}-cargo-${{ matrix.rust }}-
41+
42+
- name: Run clippy
43+
run: cargo clippy --all-targets --all-features -- -D warnings -A dead_code
44+
45+
- name: Build
46+
run: cargo build --verbose --all-targets
47+
48+
- name: Run tests
49+
run: cargo test --verbose
50+
51+
- name: Install Chrome
52+
if: matrix.os != 'windows-latest'
53+
uses: browser-actions/setup-chrome@v1
54+
55+
- name: Install Firefox
56+
if: matrix.os == 'ubuntu-latest'
57+
uses: browser-actions/setup-firefox@v1
58+
59+
- name: Navigate Chrome to create history
60+
if: matrix.os != 'windows-latest'
61+
shell: bash
62+
run: |
63+
if [ "${{ matrix.os }}" == "macos-latest" ]; then
64+
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --headless --disable-gpu --no-sandbox --virtual-time-budget=3000 --dump-dom https://example.com > /dev/null 2>&1 || true
65+
sleep 2
66+
else
67+
google-chrome --headless --disable-gpu --no-sandbox --virtual-time-budget=3000 --dump-dom https://example.com > /dev/null 2>&1 || true
68+
sleep 2
69+
fi
70+
71+
- name: Navigate Firefox to create history
72+
if: matrix.os == 'ubuntu-latest'
73+
shell: bash
74+
run: |
75+
firefox --new-instance https://example.com &
76+
sleep 3
77+
pkill firefox || true
78+
79+
- name: Navigate Edge to create history
80+
if: matrix.os == 'windows-latest'
81+
shell: pwsh
82+
run: |
83+
Start-Process msedge.exe -ArgumentList "https://example.com" -PassThru
84+
Start-Sleep -Seconds 3
85+
Stop-Process -Name msedge -Force -ErrorAction SilentlyContinue
86+
87+
- name: Navigate Safari to create history (macOS)
88+
if: matrix.os == 'macos-latest'
89+
shell: bash
90+
run: |
91+
open -a Safari https://example.com
92+
sleep 3
93+
osascript -e 'quit app "Safari"' || true
94+
95+
- name: Wait for history to be written
96+
if: matrix.os == 'windows-latest'
97+
run: Start-Sleep -Seconds 5
98+
shell: pwsh
99+
100+
- name: Wait for history to be written
101+
if: matrix.os != 'windows-latest'
102+
run: sleep 5
103+
shell: bash
104+
105+
- name: Build release
106+
run: cargo build --release --verbose
107+
108+
- name: Run e2e test
109+
if: matrix.os == 'windows-latest'
110+
env:
111+
RUST_LOG: debug
112+
run: |
113+
$output = ./target/release/bhgrep.exe --query "example" --limit 5 --format plain --mode db 2>&1
114+
Write-Host "Command output:"
115+
Write-Host $output
116+
if ([string]::IsNullOrWhiteSpace($output)) {
117+
Write-Host "No output from command - this may indicate no history was found"
118+
}
119+
shell: pwsh
120+
121+
- name: Run e2e test
122+
if: matrix.os != 'windows-latest'
123+
env:
124+
RUST_LOG: debug
125+
run: |
126+
output=$(./target/release/bhgrep --query "example" --limit 5 --format plain --mode db 2>&1)
127+
echo "Command output:"
128+
echo "$output"
129+
if [ -z "$output" ]; then
130+
echo "No output from command - this may indicate no history was found"
131+
fi
132+
shell: bash

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

0 commit comments

Comments
 (0)