-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (70 loc) · 3.32 KB
/
Copy pathjava-integration-tests.yml
File metadata and controls
81 lines (70 loc) · 3.32 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
name: Java integration tests
# Language-specific workflow: only runs for the Java client. Triggers on PRs to master that touch
# Java client, test, example, or documentation code, and can be dispatched manually from any branch.
on:
pull_request:
branches: [master]
paths:
- '**/*.java'
- 'pom.xml'
# The "Test examples" step validates the in-documentation snippets, so doc changes must
# re-run the workflow even though Markdown is not Java code.
- 'docs/**'
- 'README.md'
- '.github/workflows/java-integration-tests.yml'
workflow_dispatch:
# Avoid concurrent runs of the same ref racing on the shared test account.
concurrency:
group: java-integration-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'
cache: maven
# The formatter/lint gate mandated by the coding rules (google-java-format + import hygiene).
- name: Check formatting (Spotless)
run: mvn -B spotless:check
- name: Build
run: mvn -B -DskipTests test-compile
# Static-analysis linter (bug finder), the coding-rules-mandated CI lint gate.
- name: Static analysis (SpotBugs)
run: mvn -B -DskipTests compile spotbugs:check
# Offline unit tests (mock HTTP backend): prove the retry/error/signature/pagination logic
# without the API. Selected by pattern — every hermetic test in the base package runs, and the
# token-gated integration/example/doc-snippet suites are excluded — so new hermetic tests are
# covered here automatically without editing this list.
- name: Unit tests
run: mvn -B test -Dtest='!*IntegrationTest,!ExamplesTest,!DocSnippetsTest' -DfailIfNoTests=true
# Fail fast if the integration-test secret is missing or empty. Without this guard the
# integration tests silently "pass" (JUnit assumptions skip them 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: Integration tests
env:
# The integration-test token is stored as a repository secret.
APIFY_TOKEN: ${{ secrets.APIFY_TOKEN }}
# Run only the live integration suites; the hermetic tests already ran in the offline step
# above and the example/doc-snippet harnesses run in the step below.
run: mvn -B test -Dtest='*IntegrationTest' -DfailIfNoTests=true
# Standalone CI step that verifies the documentation examples actually work end-to-end against
# the live API (ExamplesTest runs each example's main), and that every in-documentation Java
# snippet is valid, runnable code (DocSnippetsTest compiles each fenced block).
- name: Test examples
env:
APIFY_TOKEN: ${{ secrets.APIFY_TOKEN }}
run: mvn -B test -Dtest='ExamplesTest,DocSnippetsTest' -DfailIfNoTests=true