Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,91 @@ jobs:
# Run API7 E2E tests
- name: Run E2E tests
run: npx nx run backend-api7:test
api7-rust:
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'test/api7') || github.event_name == 'push'
permissions:
contents: read
packages: read
strategy:
fail-fast: false
matrix:
version: [3.5.5, 3.6.1, 3.7.8, 3.8.23, 3.9.14, 3.10.1, dev]
steps:
- name: Determine API7 image and license
run: |
if [ "${{ matrix.version }}" = "dev" ]; then
echo "BACKEND_API7_VERSION=999.999.999" >> $GITHUB_ENV
echo "API7_DASHBOARD_IMAGE=ghcr.io/api7/api7-ee-3-integrated" >> $GITHUB_ENV
echo "API7_IMAGE_TAG=dev" >> $GITHUB_ENV
{
echo "BACKEND_API7_LICENSE<<EOLICENSE"
echo "${{ secrets.BACKEND_API7_DEV_LICENSE }}"
echo "EOLICENSE"
} >> $GITHUB_ENV
else
echo "BACKEND_API7_VERSION=${{ matrix.version }}" >> $GITHUB_ENV
echo "API7_DASHBOARD_IMAGE=api7/api7-ee-3-integrated" >> $GITHUB_ENV
echo "API7_IMAGE_TAG=v${{ matrix.version }}" >> $GITHUB_ENV
{
echo "BACKEND_API7_LICENSE<<EOLICENSE"
echo "${{ secrets.BACKEND_API7_LICENSE }}"
echo "EOLICENSE"
} >> $GITHUB_ENV
fi

- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
Comment thread
coderabbitai[bot] marked this conversation as resolved.
with:
persist-credentials: false

- name: Login to GHCR
if: matrix.version == 'dev'
uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4.4.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Runs on its own dashboard instance, independent of the `api7` job's
# (rather than reusing that job's live instance after the TS suite runs)
# — the Rust e2e suite's `common::client()` performs its own admin
# login / password rotation / license activation / token minting on
# first use (see adc-backend-api7's tests/common/mod.rs), which would
# collide with the TS suite doing the same dance against a shared
# instance.
- name: Setup API7 Instance via Docker Compose
working-directory: ./libs/backend-api7/e2e/assets
run: |
if [ "${{ matrix.version }}" = "dev" ]; then docker compose pull; fi
docker compose up -d

# Run the Rust port's E2E tests
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
with:
workspaces: rust -> target
# Each test file below is its own process with no state shared
# between them, but they all talk to the one dashboard instance
# started above — so the admin login / password rotation / license
# activation / token minting dance runs here exactly once, and its
# result is shared with every other test file as `TOKEN` (see
# tests/e2e_init.rs), instead of each independently repeating it
# against a dashboard the first one to run already mutated.
- name: Bootstrap a shared API7 token
working-directory: ./rust
run: |
rustup update stable
rustup default stable
cargo test -p adc-backend-api7 --test e2e_init -- --ignored
- name: Run Rust E2E tests
working-directory: ./rust
run: |
rustup update stable
rustup default stable
cargo test -p adc-backend-api7 -- --ignored --test-threads=1
# Only useful when the step above fails: `BackendError::Api`'s
# message is empty for a 500 with no response body, which the
# dashboard's own logs can actually explain.
- name: Dump API7 dashboard logs
if: failure()
working-directory: ./libs/backend-api7/e2e/assets
run: docker compose logs --no-color
147 changes: 141 additions & 6 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = [
"crates/adc-differ",
"crates/adc-backend-core",
"crates/adc-backend-apisix",
"crates/adc-backend-api7",
"crates/adc-sync-bench",
"crates/adc-mock-server",
"crates/adc-cli",
Expand Down
31 changes: 31 additions & 0 deletions rust/crates/adc-backend-api7/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[package]
name = "adc-backend-api7"
version.workspace = true
edition.workspace = true
publish.workspace = true
rust-version.workspace = true

[features]
# Exposes `adc_backend_api7::tests`, the internal building blocks this
# crate's own `tests/*.rs` integration tests reach into — never meant to be
# enabled by a real consumer. Off by default so it doesn't leak into the
# crate's normal public API surface; the dev-dependency below turns it back
# on for the crate's own test builds.
test-utils = []

[dependencies]
adc-sdk = { path = "../adc-sdk" }
adc-backend-core = { path = "../adc-backend-core" }
async-trait = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
semver = { workspace = true }
tokio = { workspace = true, features = ["macros", "sync"] }
tracing = { workspace = true }

[dev-dependencies]
adc-backend-api7 = { path = ".", features = ["test-utils"] }
adc-differ = { path = "../adc-differ" }
tokio = { workspace = true, features = ["rt-multi-thread", "macros", "net", "time"] }
reqwest = { version = "0.12", default-features = false, features = ["rustls-tls", "json", "cookies"] }
axum = "0.8"
Loading
Loading