teloxide/.github/workflows/ci.yml

211 lines
4.9 KiB
YAML
Raw Normal View History

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
2023-02-13 08:55:16 +01:00
merge_group:
2019-11-27 15:30:33 +01:00
name: Continuous integration
env:
RUSTFLAGS: "--cfg CI_REDIS CI_POSTGRES -Dwarnings"
RUSTDOCFLAGS: -Dwarnings
RUST_BACKTRACE: short
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
# When updating this, also update:
# - crates/teloxide-core/src/codegen.rs
# - rust-toolchain.toml
rust_nightly: nightly-2023-09-27
# When updating this, also update:
# - **/README.md
# - **/src/lib.rs
# - down below in a matrix
2023-10-04 18:01:46 +02:00
# - `Cargo.toml`
# - **/CHANGELOG.md
rust_msrv: 1.68.0
CI: 1
2019-11-27 15:30:33 +01:00
jobs:
# Depends on all action that are required for a "successful" CI run.
ci-pass:
name: CI succeeded
2019-11-27 15:30:33 +01:00
runs-on: ubuntu-latest
if: always()
needs:
- fmt
- test
- check-examples
- clippy
- doc
steps:
- name: Check whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
fmt:
name: fmt
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust ${{ env.rust_nightly }}
uses: dtolnay/rust-toolchain@master
2019-11-27 15:30:33 +01:00
with:
toolchain: ${{ env.rust_nightly }}
components: rustfmt
- name: Cache Dependencies
uses: Swatinem/rust-cache@v2
- name: Check formatting
run: |
cargo fmt --all -- --check
test:
name: Test
2020-07-02 14:48:37 +02:00
runs-on: ubuntu-latest
services:
# Setup Postgres for testing PostgresStorage
postgres:
image: postgres
volumes:
- ./postgres/init.sql:/docker-entrypoint-initdb.d/init.sql
env:
POSTGRES_USER: teloxide
POSTGRES_PASSWORD: rewrite_it_in_rust
ports:
- 5432:5432
strategy:
matrix:
rust:
- stable
- beta
2022-03-25 10:19:57 +01:00
- nightly
2022-04-20 21:33:44 +02:00
- msrv
include:
- rust: stable
2022-03-25 10:19:57 +01:00
toolchain: stable
features: "--features full"
- rust: beta
2022-03-25 10:19:57 +01:00
toolchain: beta
features: "--features full"
2022-03-25 10:19:57 +01:00
- rust: nightly
toolchain: nightly-2023-09-27
2023-02-13 08:49:56 +01:00
features: "--features full nightly"
2022-04-20 21:33:44 +02:00
- rust: msrv
2023-10-04 18:01:46 +02:00
toolchain: 1.68.0
2022-04-21 10:52:01 +02:00
features: "--features full"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust ${{ matrix.toolchain }}
uses: dtolnay/rust-toolchain@master
2019-11-27 15:30:33 +01:00
with:
2022-03-25 10:19:57 +01:00
toolchain: ${{ matrix.toolchain }}
- name: Cache Dependencies
uses: Swatinem/rust-cache@v2
# NB. Don't test (build) examples so we can use non-msrv features in them (--tests/--doc)
- name: Compile
run: |
cargo +${{ matrix.toolchain }} test --tests --no-run --verbose ${{ matrix.features }}
- name: Setup redis
run: |
sudo apt install redis-server
redis-server --port 7777 > /dev/null &
redis-server --port 7778 > /dev/null &
redis-server --port 7779 > /dev/null &
- name: Test unit & integration tests
run: |
cargo +${{ matrix.toolchain }} test --tests --verbose ${{ matrix.features }}
- name: Test documentation tests
if: ${{ matrix.rust != 'msrv' }}
run: |
cargo +${{ matrix.toolchain }} test --doc --verbose ${{ matrix.features }}
check-examples:
2020-07-02 14:48:37 +02:00
runs-on: ubuntu-latest
2020-07-02 14:52:42 +02:00
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust stable
uses: dtolnay/rust-toolchain@master
2020-03-27 13:54:06 +01:00
with:
2020-07-03 14:50:28 +02:00
toolchain: stable
- name: Cache Dependencies
uses: Swatinem/rust-cache@v2
- name: Check examples
run: |
2023-06-01 12:24:43 +02:00
cargo +stable check --examples --features full
2022-11-25 11:38:34 +01:00
# TODO: prolly move it to a separate step?
- name: Check with no default features
run: |
2023-06-01 12:24:43 +02:00
cargo +stable check --no-default-features
2022-11-25 11:38:34 +01:00
clippy:
name: Run linter
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust ${{ env.rust_nightly }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.rust_nightly }}
components: clippy
- name: Cache Dependencies
uses: Swatinem/rust-cache@v2
- name: clippy
run: |
cargo clippy --all-targets --features "full nightly"
doc:
name: check docs
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust ${{ env.rust_nightly }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.rust_nightly }}
- name: Cache Dependencies
uses: Swatinem/rust-cache@v2
- name: rustdoc
run: |
cargo docs # from .cargo/config.toml