1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Rust integration tests
# Language-specific workflow: only runs for the Rust client. Triggers on PRs to master
# that touch Rust client or test code, and can be dispatched manually from any branch.
on:
pull_request:
branches:
paths:
- 'src/**'
- 'tests/**'
- 'examples/**'
- 'Cargo.toml'
- 'Cargo.lock'
- '.github/workflows/rust-integration-tests.yml'
workflow_dispatch:
# Avoid concurrent runs of the same ref racing on the shared test account.
concurrency:
group: rust-integration-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache cargo registry and build
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
- name: Check formatting
run: cargo fmt --all -- --check
- name: Clippy (deny warnings)
run: cargo clippy --all-targets -- -D warnings
- name: Build
run: cargo build --verbose
# Fail fast if the integration-test secret is missing or empty. Without this guard the
# integration tests silently "pass" (they early-return when APIFY_TOKEN is unset), so a
# green run would not prove the API logic actually executed.
- name: Require APIFY_TOKEN secret
env:
APIFY_TOKEN: ${{ secrets.APIFY_TOKEN }}
run: |
if [ -z "${APIFY_TOKEN}" ]; then
echo "::error::APIFY_TOKEN secret is empty or missing; integration tests would not run against the API."
exit 1
fi
- name: Run integration tests
env:
# The integration-test token is stored as a repository secret.
APIFY_TOKEN: ${{ secrets.APIFY_TOKEN }}
# Limit parallelism to be gentle on the shared test account. The documentation example
# programs in `tests/examples.rs` (test names prefixed `example_`) are exercised by the
# standalone `Test examples` step below, so they are skipped here to keep the two
# concerns separate.
run: cargo test --lib --tests --verbose -- --skip example_ --test-threads=4
# Standalone CI step that verifies the documentation examples actually work. It runs the
# example programs from `examples/` end-to-end against the live API (via the `example_*`
# smoke tests in `tests/examples.rs`, each of which executes `cargo run --example <name>`)
# and runs the in-documentation code snippets as doctests (`cargo test --doc`, which
# compiles every fenced `rust` block in the README and the `docs/` pages and runs the
# runnable ones). Both are required by the documentation requirements: each documentation
# example has a CI test that actually runs the code.
- name: Test examples
env:
APIFY_TOKEN: ${{ secrets.APIFY_TOKEN }}
# Match the integration-test thread cap so the example programs and any doctests that hit
# the live API stay gentle on the shared account.
run: |
cargo test --test examples --verbose -- --test-threads=4
cargo test --doc --verbose -- --test-threads=4