Repository navigation
95 lines (81 loc) · 3.22 KB
/
Copy pathrust-integration-tests.yml
File metadata and controls
95 lines (81 loc) · 3.22 KB
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
89
90
91
92
93
94
95
name: Rust integration tests
# Language-specific workflow: only runs for the Rust client. Triggers on PRs to master
# that touch Rust client, test, docs or build code, and can be dispatched manually from any branch.
on:
pull_request:
branches: [master]
paths:
- 'src/**'
- 'tests/**'
- 'examples/**'
- 'docs/**'
- 'README.md'
- 'build.rs'
- '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
# APIFY_TOKEN is an environment secret of the `tests` environment.
environment: tests
steps:
- name: Checkout
uses: actions/checkout@v4.4.0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache cargo registry and build
uses: actions/cache@v4.3.0
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: Docs (deny warnings)
run: cargo doc --no-deps
env:
RUSTDOCFLAGS: -D warnings
- name: Build
run: cargo build --verbose
# The `rustls` feature swaps the TLS stack, so it needs its own lint and compile check.
- name: Clippy with rustls
run: cargo clippy --no-default-features --features rustls --all-targets -- -D warnings
# The `zstd` feature is on by default, so the build without it needs its own check.
- name: Clippy without zstd
run: cargo clippy --no-default-features --features native-tls --all-targets -- -D warnings
# 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 (tests environment) 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 secret of the `tests` environment.
APIFY_TOKEN: ${{ secrets.APIFY_TOKEN }}
# `example_*` tests run in the `Test examples` step below.
run: cargo test --lib --tests --verbose -- --skip example_ --test-threads=4
# Runs the example programs and the documentation doctests, see "Testing" in README.md.
- name: Test examples
env:
APIFY_TOKEN: ${{ secrets.APIFY_TOKEN }}
run: |
cargo test --test examples --verbose -- --test-threads=4
cargo test --doc --verbose -- --test-threads=4