Skip to content

Commit f7b7426

Browse files
authored
Merge pull request #1 from serpapi/agentic-serpapi-cli
Initial version of SerpApi CLI
2 parents 3e22a22 + 35774af commit f7b7426

File tree

22 files changed

+2568
-791
lines changed

22 files changed

+2568
-791
lines changed

.github/workflows/ci.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
tags: ["v*"]
7+
pull_request:
8+
branches: [main]
9+
10+
env:
11+
CARGO_TERM_COLOR: always
12+
13+
jobs:
14+
lint-and-test:
15+
name: Lint + Unit Test
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Install Rust stable
22+
uses: actions-rust-lang/setup-rust-toolchain@v1
23+
with:
24+
toolchain: stable
25+
components: rustfmt, clippy
26+
27+
- name: Cache cargo registry
28+
uses: actions/cache@v4
29+
with:
30+
path: |
31+
~/.cargo/registry
32+
~/.cargo/git
33+
target
34+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
35+
restore-keys: |
36+
${{ runner.os }}-cargo-
37+
38+
- name: Check formatting
39+
run: cargo fmt -- --check
40+
41+
- name: Run clippy
42+
run: cargo clippy -- -D warnings
43+
44+
- name: Run unit tests
45+
run: cargo test --all-targets
46+
47+
e2e-test:
48+
name: E2E Test
49+
runs-on: ubuntu-latest
50+
needs: lint-and-test
51+
52+
steps:
53+
- uses: actions/checkout@v4
54+
55+
- name: Install Rust stable
56+
uses: actions-rust-lang/setup-rust-toolchain@v1
57+
with:
58+
toolchain: stable
59+
60+
- name: Cache cargo registry
61+
uses: actions/cache@v4
62+
with:
63+
path: |
64+
~/.cargo/registry
65+
~/.cargo/git
66+
target
67+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
68+
restore-keys: |
69+
${{ runner.os }}-cargo-
70+
71+
- name: Run E2E tests
72+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
73+
env:
74+
SERPAPI_KEY: ${{ secrets.SERPAPI_KEY }}
75+
run: cargo test -- --ignored
76+
77+
- name: Skip E2E tests (fork PR)
78+
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository
79+
run: echo "Skipping E2E tests - SERPAPI_KEY unavailable in fork PRs"
80+

.github/workflows/release.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
create-release:
13+
name: Create release
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Verify tag matches Cargo.toml version
18+
run: |
19+
TAG="${GITHUB_REF_NAME#v}"
20+
CARGO_VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/')
21+
if [ "$TAG" != "$CARGO_VERSION" ]; then
22+
echo "::error::Tag $GITHUB_REF_NAME does not match Cargo.toml version $CARGO_VERSION"
23+
exit 1
24+
fi
25+
- name: Create draft release
26+
env:
27+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
run: |
29+
gh release create "$GITHUB_REF_NAME" \
30+
--draft \
31+
--title "$GITHUB_REF_NAME" \
32+
--generate-notes
33+
34+
build-release:
35+
name: Build (${{ matrix.target }})
36+
needs: create-release
37+
runs-on: ${{ matrix.os }}
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
include:
42+
- target: aarch64-apple-darwin
43+
os: macos-latest
44+
- target: x86_64-apple-darwin
45+
os: macos-13
46+
- target: aarch64-unknown-linux-gnu
47+
os: ubuntu-latest
48+
use_cross: true
49+
- target: x86_64-unknown-linux-gnu
50+
os: ubuntu-latest
51+
- target: x86_64-unknown-linux-musl
52+
os: ubuntu-latest
53+
use_cross: true
54+
- target: x86_64-pc-windows-msvc
55+
os: windows-latest
56+
steps:
57+
- uses: actions/checkout@v4
58+
59+
- name: Install Rust toolchain
60+
run: rustup target add ${{ matrix.target }}
61+
62+
- name: Install cross
63+
if: matrix.use_cross
64+
uses: taiki-e/install-action@v2
65+
with:
66+
tool: cross
67+
68+
- name: Build
69+
shell: bash
70+
run: |
71+
if [ "${{ matrix.use_cross }}" = "true" ]; then
72+
cross build --release --target ${{ matrix.target }}
73+
else
74+
cargo build --release --target ${{ matrix.target }}
75+
fi
76+
77+
- name: Package and checksum
78+
id: package
79+
shell: bash
80+
run: |
81+
BIN="serpapi"
82+
TARGET="${{ matrix.target }}"
83+
VERSION="${GITHUB_REF_NAME#v}"
84+
PKG="${BIN}-${VERSION}-${TARGET}"
85+
86+
mkdir "$PKG"
87+
cp README.md LICENSE "$PKG/"
88+
89+
if [[ "$TARGET" == *"windows"* ]]; then
90+
cp "target/${TARGET}/release/${BIN}.exe" "$PKG/"
91+
7z a "${PKG}.zip" "$PKG"
92+
ARCHIVE="${PKG}.zip"
93+
else
94+
cp "target/${TARGET}/release/${BIN}" "$PKG/"
95+
tar czf "${PKG}.tar.gz" "$PKG"
96+
ARCHIVE="${PKG}.tar.gz"
97+
fi
98+
99+
sha256sum "$ARCHIVE" > "${ARCHIVE}.sha256"
100+
echo "archive=$ARCHIVE" >> "$GITHUB_OUTPUT"
101+
echo "sha256=${ARCHIVE}.sha256" >> "$GITHUB_OUTPUT"
102+
103+
- name: Upload to release
104+
env:
105+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
106+
run: |
107+
gh release upload "$GITHUB_REF_NAME" \
108+
"${{ steps.package.outputs.archive }}" \
109+
"${{ steps.package.outputs.sha256 }}"

0 commit comments

Comments
 (0)