Skip to content

Commit

Permalink
Merge pull request #452 from mzeitlin11/codegen_revamp
Browse files Browse the repository at this point in the history
Codegen revamp
  • Loading branch information
arlyon authored Apr 4, 2024
2 parents ee601fd + 00aa897 commit d295678
Show file tree
Hide file tree
Showing 1,717 changed files with 193,798 additions and 188,770 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Bug report
description: Create a report to help us improve
labels: ["bug"]
labels: [ "bug" ]
body:
- type: markdown
attributes:
Expand Down Expand Up @@ -51,7 +51,7 @@ body:
id: language-version
attributes:
label: Rust version
placeholder: Our MSRV is 1.68.0
placeholder: Our MSRV is 1.73.0
validations:
required: true
- type: input
Expand Down
178 changes: 107 additions & 71 deletions .github/workflows/async-stripe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,75 @@ on:
push:
branches:
- master
- next
pull_request:
branches:
- master
- next

env:
RUSTFLAGS: -Dwarnings
rust_min: 1.73

jobs:
format:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- name: Checkout sources
uses: actions/checkout@v3

- name: Install toolchain
uses: dtolnay/rust-toolchain@nightly
with:
profile: minimal
toolchain: nightly
components: rustfmt
- uses: davidB/rust-cargo-make@v1
- name: regenerate openapi
uses: actions-rs/cargo@v1
with:
command: make
args: check

verify-codegen:
runs-on: ubuntu-20.04
- name: Check formatting for workspace
run: cargo fmt --all -- --check

verify-codegen-crate:
runs-on: ubuntu-latest
defaults:
run:
working-directory: openapi

steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- name: Checkout sources
uses: actions/checkout@v3

- name: Install nightly toolchain
uses: dtolnay/rust-toolchain@nightly
with:
profile: minimal
toolchain: nightly
components: rustfmt
- uses: davidB/rust-cargo-make@v1
- name: regenerate openapi
uses: actions-rs/cargo@v1

- name: Check formatting
run: cargo +nightly fmt -- --check

- name: Install toolchain
uses: dtolnay/rust-toolchain@stable
with:
command: make
args: openapi-install
- name: ensure generated files unchanged
components: clippy

- name: Run clippy
run: cargo clippy

- name: Run codegen
run: cargo run --release -- --fetch current

- name: Ensure generated files unchanged
uses: tj-actions/[email protected]
id: verify-changed-files
with:
files: |
**/*.rs
- name: report changed files
- name: Report changed files
if: steps.verify-changed-files.outputs.files_changed == 'true'
run: |
echo "Some files changed after code generation: ${{ steps.verify-changed-files.outputs.changed_files }}"
exit 1
clippy:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
matrix:
runtime:
Expand All @@ -65,29 +85,22 @@ jobs:
blocking-rustls-webpki,
]
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- name: Checkout sources
uses: actions/checkout@v3

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: stable
toolchain: ${{ env.rust_min }}
components: clippy
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-clippy-${{ matrix.runtime }}-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/cargo@v1
with:
command: clippy
args: >
--no-default-features
--features runtime-${{ matrix.runtime }}

- uses: Swatinem/rust-cache@v2

- name: Run clippy
run: cargo clippy --features "runtime-${{ matrix.runtime }} full"

test:
runs-on: ubuntu-20.04
env:
RUSTFLAGS: -D warnings
runs-on: ubuntu-latest
strategy:
matrix:
runtime:
Expand All @@ -107,31 +120,54 @@ jobs:
- 12111:12111
- 12112:12112
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v3

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: "1.68.0"
override: true
- uses: actions/cache@v2
toolchain: ${{ env.rust_min }}

- uses: Swatinem/rust-cache@v2

- uses: taiki-e/install-action@cargo-llvm-cov
- name: Test and gather coverage
run: cargo llvm-cov --lcov --output-path lcov.info --features runtime-${{ matrix.runtime }}
- name: Upload to codecov.io
uses: codecov/[email protected]
with:
token: ${{secrets.CODECOV_TOKEN}}
files: lcov.info
- name: Archive code coverage results
uses: actions/upload-artifact@v1
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-test-${{ matrix.runtime }}-${{ hashFiles('**/Cargo.lock') }}
- name: Test
run: cargo test --features runtime-${{ matrix.runtime }}
# - uses: taiki-e/install-action@cargo-llvm-cov
# - name: Test and gather coverage
# run: cargo llvm-cov --lcov --output-path lcov.info --features runtime-${{ matrix.runtime }}
# - name: Upload to codecov.io
# uses: codecov/[email protected]
# with:
# token: ${{secrets.CODECOV_TOKEN}}
# files: lcov.info
# - name: Archive code coverage results
# uses: actions/upload-artifact@v1
# with:
# name: code-coverage-report
# path: lcov.info
name: code-coverage-report
path: lcov.info

docs:
name: Docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- uses: Swatinem/rust-cache@v2

- name: Build Documentation
run: cargo doc --lib --no-deps --features "runtime-tokio-hyper full"

# Examples tested separately so that we can use crates which don't match our MSRV
examples:
name: Check Examples
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- uses: Swatinem/rust-cache@v2

- name: Check examples
run: cargo clippy --features "runtime-tokio-hyper-rustls" --workspace
49 changes: 9 additions & 40 deletions .github/workflows/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,55 +7,24 @@ jobs:
update-openapi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install minimal nightly with rustfmt
uses: actions-rs/toolchain@v1
- uses: actions/checkout@v3

- name: Install Rust with rustfmt
uses: dtolnay/rust-toolchain@nightly
with:
profile: minimal
toolchain: nightly
components: rustfmt
- uses: davidB/rust-cargo-make@v1
- name: regenerate openapi
uses: actions-rs/cargo@v1
with:
command: make
args: openapi-install-latest
- name: verify
id: verify
# currently waiting for https://github.com/actions-rs/cargo/pull/206
# so we use this in the mean time
uses: arlyon/[email protected]
with:
command: make
args: verify
- name: duplicates
id: duplicates
# currently waiting for https://github.com/actions-rs/cargo/pull/206
# so we use this in the mean time
uses: arlyon/[email protected]
with:
command: make
args: duplicates

- name: Run Codegen
run: cargo run --release -- --fetch latest

- name: create pull request
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.REPO_SCOPED_TOKEN }}
commit-message: "feat: generate latest changes from OpenApi spec"
commit-message: Generate latest changes from OpenApi spec
title: Generate latest changes from OpenApi spec
body: |
This is an automated PR that tries to build the latest changes generated from the [Stripe OpenApi spec](https://github.com/stripe/openapi).
Here are the missing exports:
```
${{ steps.verify.outputs.stdout }}
```
Here are the duplicate exports:
```
${{ steps.duplicates.outputs.stdout }}
```
branch: openapi
branch-suffix: timestamp
reviewers: arlyon
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Cargo.lock

# Test artifacts
stripe-mock/
lcov.info

# IDE artifacts
.DS_Store
Expand Down
Loading

0 comments on commit d295678

Please sign in to comment.