Skip to content

Commit

Permalink
Add integration test workflow
Browse files Browse the repository at this point in the history
Implements an integration test workflow to validate any changes against
the API.

Drive-bys:
- Regenerates the latest documentation.
- Fixes Hurl tests.
- Pins actions with SHA.
- Adds a workflow ensuring the bnaclient is up to date.

Signed-off-by: Rémy Greinhofer <[email protected]>
  • Loading branch information
rgreinho committed Jan 16, 2025
1 parent 977df69 commit af2857c
Show file tree
Hide file tree
Showing 20 changed files with 1,923 additions and 360 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/bnaclient.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: bnaclient

defaults:
run:
working-directory: bnaclient

on:
pull_request:
types:
- opened
- synchronize
- reopened

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: extractions/setup-just@dd310ad5a97d8e7b41793f8ef055398d51ad4de6 # v2
- name: Install cargo progenitor
run: cargo install cargo-progenitor
- name: Regenerate the specifications and the bnaclient
run: just regenerate-all-no-cargo
- name: Ensure there are no changes
run: test -z "$(git status --porcelain)" || (git status; git diff; false)

build:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
8 changes: 4 additions & 4 deletions .github/workflows/ci-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: extractions/setup-just@v2
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: extractions/setup-just@dd310ad5a97d8e7b41793f8ef055398d51ad4de6 # v2
- name: Lint markdown files
run: just lint-md

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

build:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
4 changes: 2 additions & 2 deletions .github/workflows/deployment-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
- name: Install cargo lambda
run: pip install cargo-lambda

Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/effortless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2
- uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
- run: cargo fmt --check
- run: cargo clippy -- -D warnings
- run: cargo check

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
- run: cargo test

build:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
- run: cargo build
102 changes: 102 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: integration

on:
pull_request:
types:
- opened
- synchronize
- reopened

jobs:
test:
runs-on: ubuntu-latest

env:
DATABASE_URL: "postgresql://postgres:postgres@localhost:5432/postgres"

services:
postgres:
image: ghcr.io/peopleforbikes/docker-postgis-bna:17-3.4-1
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
- name: Install HURL
run: |
HURL_VERSION=6.0.0
curl --location --remote-name https://github.com/Orange-OpenSource/hurl/releases/download/$HURL_VERSION/hurl_${HURL_VERSION}_amd64.deb
sudo apt install ./hurl_${HURL_VERSION}_amd64.deb
- name: Seed the database
run: psql $DATABASE_URL < lambdas/tests/database-with-test-data.sql
- name: Build the API server
run: cargo build --release -p lambdas --bin axumed
- name: Start the standalone API server
run: >
BNA_API_LOG_LEVEL=debug
BNA_API_STANDALONE=1
cargo run --release -p lambdas --bin axumed &
- run: sleep 5
- name: Run the public smoke-tests
run: >
hurl
--test
--variables-file lambdas/tests/localhost.vars
lambdas/tests/smoke/public.hurl
- name: Run the scenarios tests
run: >
hurl
--test
--variables-file lambdas/tests/localhost.vars
lambdas/tests/scenario/pagination.hurl
- name: Run the endpoint tests
run: >
hurl
--test
--variables-file lambdas/tests/localhost.vars
lambdas/tests/endpoints/cities.hurl
lambdas/tests/endpoints/pricing.hurl
lambdas/tests/endpoints/ratings.hurl
# - uses: astral-sh/setup-uv@887a942a15af3a7626099df99e897a18d9e5ab3a #v5.1.0
# with:
# enable-cache: true
# - name: Set up Python
# run: uv python install
#
# Schemathesis causes the server to crash somehow.
# ```
# Network Error
#
# Connection failed
#
# Connection aborted. Remote end closed connection without response
# ```
# This will require more investigation to be run in the CI.
# - name: Run Schemathesis
# run: >
# cd lambdas/tests &&
# RUST_BACKTRACE=1
# uv run st run
# --base-url http://localhost:3000/
# --cassette-path cassette.yaml
# -vvv
# -x
# --show-trace
# --generation-allow-x00 false
# --exclude-method 'POST'
# --exclude-method 'PATCH'
# ../../openapi-3.0.yaml
12 changes: 6 additions & 6 deletions .github/workflows/lambdas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2
- uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
- run: cargo fmt --check
- run: cargo clippy -- -D warnings
- run: cargo check
Expand All @@ -32,18 +32,18 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
- run: cargo test

build:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
- name: Install cargo lambda
run: pip install cargo-lambda
- run: cargo lambda build
12 changes: 6 additions & 6 deletions .github/workflows/migration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2
- uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
- run: cargo fmt --check
- run: cargo clippy -- -D warnings
- run: cargo check

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
- run: cargo test

build:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
- run: cargo build
Loading

0 comments on commit af2857c

Please sign in to comment.