*** Settings ***
Documentation    Smoke test validating that nox sessions referenced in CI exist and can be listed
Library          Process
Library          OperatingSystem

*** Test Cases ***
Nox Lists All Required Sessions
    [Documentation]    Verify that nox can list sessions and the required CI sessions are present
    [Tags]    ci    quality    slow
    ${result}=    Run Process    nox    --list
    Should Be Equal As Integers    ${result.rc}    0    msg=nox --list failed with: ${result.stderr}
    # Verify required sessions exist in nox output
    Should Contain    ${result.stdout}    lint
    Should Contain    ${result.stdout}    typecheck
    Should Contain    ${result.stdout}    unit_tests
    Should Contain    ${result.stdout}    integration_tests
    Should Contain    ${result.stdout}    coverage_report
    Should Contain    ${result.stdout}    security_scan
    Should Contain    ${result.stdout}    dead_code
    Should Contain    ${result.stdout}    complexity
    Should Contain    ${result.stdout}    build

CI Workflow File Exists
    [Documentation]    Verify the CI workflow file is present in the repository
    [Tags]    ci    quality    slow
    File Should Exist    .forgejo/workflows/ci.yml

Release Workflow File Exists
    [Documentation]    Verify the release workflow file is present in the repository
    [Tags]    ci    quality    slow
    File Should Exist    .forgejo/workflows/release.yml

Nightly Quality Workflow File Exists
    [Documentation]    Verify the nightly quality workflow file is present
    [Tags]    ci    quality    slow
    File Should Exist    .forgejo/workflows/nightly-quality.yml

Nox Lint Session Runs Successfully
    [Documentation]    Verify that nox lint session can be invoked
    [Tags]    ci    quality    slow
    ${result}=    Run Process    nox    -s    lint    timeout=120s    on_timeout=kill
    Should Be Equal As Integers    ${result.rc}    0    msg=nox -s lint failed: ${result.stderr}

Release Workflow Contains Build Wheel Job
    [Documentation]    Verify the release workflow defines a build-wheel job
    [Tags]    ci    quality
    ${content}=    Get File    .forgejo/workflows/release.yml
    Should Contain    ${content}    build-wheel:

Release Workflow Contains Build Docker Job
    [Documentation]    Verify the release workflow defines a build-docker job
    [Tags]    ci    quality
    ${content}=    Get File    .forgejo/workflows/release.yml
    Should Contain    ${content}    build-docker:

Release Workflow Contains Create Release Job
    [Documentation]    Verify the release workflow defines a create-release job
    [Tags]    ci    quality
    ${content}=    Get File    .forgejo/workflows/release.yml
    Should Contain    ${content}    create-release:

Release Workflow Triggers On Version Tags
    [Documentation]    Verify the release workflow triggers on v* tags
    [Tags]    ci    quality
    ${content}=    Get File    .forgejo/workflows/release.yml
    Should Contain    ${content}    tags:
    Should Contain    ${content}    "v*"

CI Workflow Has Status Check Job
    [Documentation]    Verify the CI workflow has a status-check consolidation job
    [Tags]    ci    quality
    ${content}=    Get File    .forgejo/workflows/ci.yml
    Should Contain    ${content}    status-check:

CI Workflow Uses Dependency Caching
    [Documentation]    Verify the CI workflow uses actions/cache for uv packages
    [Tags]    ci    quality
    ${content}=    Get File    .forgejo/workflows/ci.yml
    Should Contain    ${content}    actions/cache@v3
    Should Contain    ${content}    ~/.cache/uv

Nox Build Session Is Referenced In Release Workflow
    [Documentation]    Verify the release workflow uses nox -s build
    [Tags]    ci    quality
    ${content}=    Get File    .forgejo/workflows/release.yml
    Should Contain    ${content}    nox -s build
