Generate latest changes from OpenApi spec #1143
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
format: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@v1 | |
with: | |
toolchain: nightly | |
components: rustfmt | |
- uses: davidB/rust-cargo-make@v1 | |
- name: regenerate openapi | |
uses: clechasseur/rs-cargo@v2 | |
with: | |
command: make | |
args: check | |
verify-codegen: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@v1 | |
with: | |
toolchain: nightly | |
components: rustfmt | |
- uses: davidB/rust-cargo-make@v1 | |
- name: regenerate openapi | |
uses: clechasseur/rs-cargo@v2 | |
with: | |
command: make | |
args: openapi-install | |
- name: ensure generated files unchanged | |
uses: tj-actions/verify-changed-files@v19 | |
id: verify-changed-files | |
with: | |
files: | | |
**/*.rs | |
- name: report changed files | |
if: steps.verify-changed-files.outputs.files_changed == 'true' | |
env: | |
CHANGED_FILES: ${{ steps.verify-changed-files.outputs.changed_files }} | |
run: | | |
echo "Some files changed after code generation: $CHANGED_FILES" | |
exit 1 | |
clippy-codegen: | |
runs-on: ubuntu-20.04 | |
env: | |
RUSTFLAGS: -D warnings | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@v1 | |
with: | |
toolchain: stable | |
components: clippy | |
- run: cargo clippy -p stripe-openapi-codegen --tests | |
clippy: | |
runs-on: ubuntu-20.04 | |
env: | |
RUSTFLAGS: -D warnings | |
strategy: | |
matrix: | |
runtime: | |
[ | |
async-std-surf, | |
tokio-hyper, | |
tokio-hyper-rustls, | |
tokio-hyper-rustls-webpki, | |
blocking, | |
blocking-rustls, | |
blocking-rustls-webpki, | |
] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@v1 | |
with: | |
toolchain: stable | |
components: clippy | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-clippy-${{ matrix.runtime }}-${{ hashFiles('**/Cargo.lock') }} | |
- uses: clechasseur/rs-cargo@v2 | |
with: | |
command: clippy | |
args: > | |
--no-default-features | |
--features runtime-${{ matrix.runtime }} | |
test: | |
runs-on: ubuntu-20.04 | |
env: | |
RUSTFLAGS: -D warnings | |
strategy: | |
matrix: | |
runtime: | |
[ | |
async-std-surf, | |
tokio-hyper, | |
tokio-hyper-rustls, | |
tokio-hyper-rustls-webpki, | |
blocking, | |
blocking-rustls, | |
blocking-rustls-webpki, | |
] | |
services: | |
stripe-mock: | |
image: stripe/stripe-mock | |
ports: | |
- 12111:12111 | |
- 12112:12112 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@v1 | |
with: | |
toolchain: "1.78.0" | |
- uses: actions/cache@v4 | |
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/codecov-action@v2.1.0 | |
# 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 | |
generate-public-api: | |
continue-on-error: true | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@v1 | |
with: | |
toolchain: nightly | |
- uses: dtolnay/rust-toolchain@v1 | |
with: | |
toolchain: stable | |
- name: Install cargo-public-api | |
uses: baptiste0928/cargo-install@v3 | |
with: | |
crate: cargo-public-api | |
- name: Save PR number | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const fs = require('fs'); | |
const util = require('util'); | |
fs.mkdirSync("./public-api", { recursive: true }); | |
const payload = context.payload; | |
const number = (payload.issue || payload.pull_request || payload).number; | |
const text = number === undefined ? "" : String(number); | |
core.info("Pr number is " + number + ", writing \"" + text + "\""); | |
fs.writeFileSync("./public-api/pr_number", text); | |
- name: Compare with latest version published on crates.io | |
run: cargo public-api diff latest --features runtime-tokio-hyper >> "public-api/diff" | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: public-api | |
path: public-api/ |