Skip to content

Commit 90d6af2

Browse files
authored
Refactor Rust github workflow for clients and servers (#21851)
* add workflow to test rust clients * update to use localhost * rename rust server workflow
1 parent d8593ef commit 90d6af2

File tree

75 files changed

+149
-87
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+149
-87
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Samples Rust Clients
2+
3+
on:
4+
push:
5+
paths:
6+
- "samples/client/others/rust/**"
7+
- "samples/client/petstore/rust-server/**"
8+
pull_request:
9+
paths:
10+
- "samples/client/others/rust/**"
11+
- "samples/client/petstore/rust/**"
12+
13+
jobs:
14+
build:
15+
name: Build Rust
16+
runs-on: ubuntu-latest
17+
services:
18+
petstore-api:
19+
image: swaggerapi/petstore
20+
ports:
21+
- 80:8080
22+
env:
23+
SWAGGER_HOST: http://petstore.swagger.io
24+
SWAGGER_BASE_PATH: /v2
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
sample:
29+
# these folders contain sub-projects of rust clients, servers
30+
- samples/client/others/rust/
31+
- samples/client/petstore/rust/
32+
steps:
33+
- uses: actions/checkout@v5
34+
- uses: actions-rs/toolchain@v1
35+
with:
36+
toolchain: stable
37+
38+
- name: Rust cache
39+
uses: Swatinem/rust-cache@v2
40+
with:
41+
cache-targets: false # Don't cache workspace target directories as they don't exist
42+
cache-directories:
43+
${{ matrix.sample }}/target
44+
workspaces: |
45+
${{ matrix.sample }}/output/*
46+
47+
- name: Build
48+
working-directory: ${{ matrix.sample }}
49+
run: cargo build --all-targets --all-features
50+
- name: Tests
51+
working-directory: ${{ matrix.sample }}
52+
run: |
53+
set -e
54+
55+
# Iterate through each example and test various features
56+
for package in $(find . -maxdepth 1 -mindepth 1 -type d)
57+
do
58+
# Not all versions have a client example
59+
if test -f examples/client/main.rs; then
60+
cargo build --example client --features="client"
61+
fi
62+
63+
# Test the CLI works if present
64+
if test -f bin/cli.rs; then
65+
cargo build --bin ${package##*/} --features cli
66+
target/debug/${package##*/} --help
67+
fi
68+
cargo fmt
69+
cargo test
70+
cargo clippy
71+
cargo doc
72+
done

.github/workflows/samples-rust.yaml renamed to .github/workflows/samples-rust-server.yaml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
name: Samples Rust
1+
name: Samples Rust Servers
22

33
on:
44
push:
55
paths:
6-
- "samples/client/others/rust/**"
76
- "samples/server/petstore/rust-server/**"
8-
- "samples/client/petstore/rust-server/**"
97
- "samples/server/petstore/rust-axum/**"
108
pull_request:
119
paths:
12-
- "samples/client/others/rust/**"
13-
- "samples/client/petstore/rust/**"
1410
- "samples/server/petstore/rust-server/**"
1511
- "samples/server/petstore/rust-axum/**"
1612

@@ -23,8 +19,6 @@ jobs:
2319
matrix:
2420
sample:
2521
# these folders contain sub-projects of rust clients, servers
26-
- samples/client/others/rust/
27-
- samples/client/petstore/rust/
2822
- samples/server/petstore/rust-server/
2923
- samples/server/petstore/rust-server-deprecated/
3024
- samples/server/petstore/rust-axum/
@@ -50,19 +44,10 @@ jobs:
5044
working-directory: ${{ matrix.sample }}
5145
run: |
5246
set -e
53-
# Skip samples/client/petstore/rust/ as its tests are failing.
54-
if [[ "${{ matrix.sample }}" == "samples/client/petstore/rust/" ]]; then
55-
echo "Skipping tests for samples/client/petstore/rust/"
56-
exit 0
57-
fi
5847
5948
# Iterate through each example and test various features
6049
for package in $(find . -maxdepth 1 -mindepth 1 -type d)
6150
do
62-
# Not all versions have a client example
63-
if test -f examples/client/main.rs; then
64-
cargo build --example client --features="client"
65-
fi
6651
# Not all versions have a server example
6752
if test -f examples/server/main.rs; then
6853
cargo build --example server --features="server"

modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
openapi: 3.0.0
22
servers:
3-
- url: 'http://petstore.swagger.io/v2'
3+
- url: 'http://localhost/v2'
44
info:
55
description: >-
66
This is a sample server Petstore server. For this sample, you can use the api key

samples/client/others/rust/hyper/oneOf/.openapi-generator-ignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@
2121
#docs/*.md
2222
# Then explicitly reverse the ignore rule for a single file:
2323
#!docs/README.md
24+
#
25+
#
26+
#

samples/client/petstore/rust/hyper/petstore/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ petstore-hyper = { path = "./petstore-hyper" }
2222

2323
## Documentation for API Endpoints
2424

25-
All URIs are relative to *http://petstore.swagger.io/v2*
25+
All URIs are relative to *http://localhost/v2*
2626

2727
Class | Method | HTTP request | Description
2828
------------ | ------------- | ------------- | -------------

samples/client/petstore/rust/hyper/petstore/docs/FakeApi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# \FakeApi
22

3-
All URIs are relative to *http://petstore.swagger.io/v2*
3+
All URIs are relative to *http://localhost/v2*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------

samples/client/petstore/rust/hyper/petstore/docs/PetApi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# \PetApi
22

3-
All URIs are relative to *http://petstore.swagger.io/v2*
3+
All URIs are relative to *http://localhost/v2*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------

samples/client/petstore/rust/hyper/petstore/docs/StoreApi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# \StoreApi
22

3-
All URIs are relative to *http://petstore.swagger.io/v2*
3+
All URIs are relative to *http://localhost/v2*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------

samples/client/petstore/rust/hyper/petstore/docs/TestingApi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# \TestingApi
22

3-
All URIs are relative to *http://petstore.swagger.io/v2*
3+
All URIs are relative to *http://localhost/v2*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------

samples/client/petstore/rust/hyper/petstore/docs/UserApi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# \UserApi
22

3-
All URIs are relative to *http://petstore.swagger.io/v2*
3+
All URIs are relative to *http://localhost/v2*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------

0 commit comments

Comments
 (0)