name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_call:
inputs:
ref:
type: string
required: false
env:
CARGO_TERM_COLOR: always
permissions: {}
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
ref: ${{ inputs.ref || '' }}
- uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@42dc69e1aa15d09112580998cf2ef0119e2e91ae - run: cargo update -p native-tls
- run: cargo fmt --all -- --check
- run: cargo clippy --all-features -- -D warnings
- name: Run Tempo Lints
uses: tempoxyz/lints@8af5001866a36967523ece2b8cdc33ba719aad84 with:
language: rust
path: "."
post-comment: false
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install ast-grep
uses: jaxxstorm/action-install-gh-release@cd6b2b78ad38bdd294341cda064ec0692b06215b with:
repo: ast-grep/ast-grep
tag: "0.37.0"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run ast-grep lint
run: sg scan -c sgconfig.yml src/
- name: Run ast-grep tests
run: sg test -c sgconfig.yml
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
ref: ${{ inputs.ref || '' }}
- uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 - uses: Swatinem/rust-cache@42dc69e1aa15d09112580998cf2ef0119e2e91ae - run: cargo update -p native-tls
- uses: taiki-e/install-action@dffee21ba64c128096855f01c56682d6f8a2bd29 - name: Tests
run: cargo test --features tempo,stripe,server,client,axum,middleware,tower,utils,integration-stripe
env:
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
- run: cargo hack check --each-feature --no-dev-deps --skip integration
- name: Check examples
run: find examples -name Cargo.toml -exec cargo check --manifest-path {} \;
ci-gate:
name: CI Gate
if: always()
needs: [lint, test]
runs-on: ubuntu-latest
steps:
- run: |
if [[ "${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
echo "One or more required jobs failed or were cancelled"
exit 1
fi