f1_data 0.0.2

Provides consolidated access to various sources of Formula 1 information and data.
Documentation
# This workflow will install Rust toolchain dependencies, build the workspace, run tests (including
# ignored tests), build docs, run clippy, run rustfmt, run benchmarks, and generate code coverage
# reports and upload them to Codecov. It runs on push and pull_requests, and on a nightly schedule.
#
# Some jobs and/or steps, e.g. ignored tests, benchmarks, and code coverage, are time consuming
# and/or depend on network and jolpica-f1 API availability. This can cause several issues if run
# on every CI job, including spurious failures, excessive API usage, and consuming a lot of the
# available GitHub Actions minutes. As such, these jobs and/or steps are skipped on push and PRs,
# and only run on schedules and locally via act. It is highly recommended that the full CI workflow
# be run locally before pushing changes, to catch any issues that the reduced workflow may miss.
#
# Many of the documentation tests are marked with ```no_run since they make requests to the jolpica
# API, and so have the same issues mentioned above, but we still want to check that they compile -
# doc tests marked with #[ignore] are not compile, unlike regular tests. Since Rust doesn't have a
# built-in way to run these tests, as it does with --ignored tests, the script `test_no_run_docs.sh`
# is provided as a workaround.
#
# Some jobs and/or steps are skipped when running locally with `act` - controlled via env.ACT and
# vars.ACT, because they may take too long or may undesirably upload codecov or performance reports.
# To force running these steps/jobs when running locally with `act`, several options are supported,
# which can be configured via `--var <OPTION_NAME>=true`. The supported options are:
#   - `FORCE_CODECOV=true` will run the code coverage job, which uploads a report to Codecov.
#   - `FORCE_RUN_BENCH=true` will run the benchmarks, which may upload perf reports to GitHub.
#
# Example local runs:
#   `act --reuse`
#   `act --reuse --var FORCE_CODECOV=true --artifact-server-path ./artifacts --secret-file .secrets`
name: CI

on:
  push:
    branches: ["main"]
  pull_request:
    branches: ["main"]
  schedule:
    # Weekly, at 00:00 on Sundays
    - cron: "0 0 * * 0"

env:
  CARGO_TERM_COLOR: always

  RUSTFLAGS: -D warnings
  RUSTDOCFLAGS: -D warnings

jobs:
  build_and_test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: stable
      - name: Build
        run: cargo build --workspace --all-features
      - name: Test (non-ignored)
        run: cargo test --workspace --all-features
      - name: Test (ignored)
        if: github.event_name == 'schedule' || vars.ACT == 'true'
        run: cargo test --workspace --all-features -- --ignored --test-threads 1
      - name: Test (doc no_run)
        if: github.event_name == 'schedule' || vars.ACT == 'true'
        run: ./scripts/test_no_run_docs.sh

  build_docs:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: stable
      - run: cargo doc --workspace --all-features --no-deps --document-private-items
      - run: cargo doc --examples --no-deps

  clippy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: stable
          components: clippy
      - run: cargo clippy --workspace --all-features --no-deps

  rustfmt:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: stable
          components: rustfmt
      - run: cargo fmt --all -- --check

  code_coverage:
    runs-on: ubuntu-latest
    if: github.event_name == 'schedule' || vars.FORCE_CODECOV == 'true'
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: stable
      - name: Install cargo-llvm-cov
        run: cargo install cargo-llvm-cov
      - name: Run cargo-llvm-cov
        run: "cargo llvm-cov --codecov test --workspace --all-features -- \
          --include-ignored --test-threads 1 > codecove_code_coverage.json"
      - name: Archive codecove_code_coverage.json
        uses: actions/upload-artifact@v4
        with:
          path: codecove_code_coverage.json
      - name: Upload code coverage report to Codecov
        uses: codecov/codecov-action@v5
        with:
          token: ${{ secrets.CODECOV_TOKEN }}

  bench:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: stable
      - name: Build benchmarks
        run: cargo bench --workspace --all-features --no-run
      - name: Run benchmarks
        if: github.event_name == 'schedule' || vars.FORCE_RUN_BENCH == 'true'
        run: cargo bench --workspace --all-features