#!/usr/bin/env bash

set -euo pipefail

repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
cd "${repo_root}"

# Bazel wildcard builds skip manual targets, which misses the internal
# `*-unit-tests-bin` rust_test targets generated by `codex_rust_crate()`.
# Add only those manual rust_test targets explicitly so inline `#[cfg(test)]`
# call sites are linted without pulling in unrelated manual release targets.
manual_rust_test_targets="$(
  ./.github/scripts/run-bazel-query-ci.sh \
    --output=label \
    -- 'kind("rust_test rule", attr(tags, "manual", //codex-rs/...))'
)"
if [[ "${RUNNER_OS:-}" != "Windows" ]]; then
  manual_rust_test_targets="$(printf '%s\n' "${manual_rust_test_targets}" | grep -v -- '-windows-cross-bin$' || true)"
fi

# The lint configuration does not register the transitioned Windows toolchain.
printf '%s\n' \
  "//codex-rs/..." \
  "-//codex-rs/core/tests/remote_env_windows:smoke-test"
printf '%s\n' "${manual_rust_test_targets}"
