Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Lean/Mathlib/.github/workflows/     Datei vom 15.10.2026 mit Größe 4 kB image not shown  

Quelle  duplicate_decls_report.yml  Sprache: unbekannt

 
Spracherkennung für: .yml vermutete Sprache: Abap {ABAP[56] Cobol[39] Python[30]} [Methode: maximale Elemente, drei Dimensionen]

name: Duplicate Declarations Report

on:
  schedule:
    - cron: '0 6 * * 1'  # Run at 06:00 UTC every Monday
  workflow_dispatch:
    inputs:
      dry_run:
        description: '
if true, just generate the report; do not post a message to Zulip'
        required: false
        default: false
        type: boolean

permissions:
  contents: read

jobs:
  run-script:
    name: Duplicate declarations report
    runs-on: ubuntu-latest
    # A full run takes roughly 10 minutes.
    timeout-minutes: 60
    if: github.repository == '
leanprover-community/mathlib4'

    steps:
    - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
      with:
        persist-credentials: false

    - name: Configure Lean
      uses: leanprover/lean-action@38fbc41a8c28c4cbaec22d7f7de508ec2e7c0dd9 # v1.5.0
      with:
        auto-config: false
        use-github-cache: false
        use-mathlib-cache: false

    # Not `use-mathlib-cache: true` above, which would also fetch `Archive`, `Counterexamples`, etc.
    - name: Retrieve the prebuilt Mathlib cache
      run: lake exe cache get Mathlib

    - name: Generate duplicate declarations report
      id: report
      env:
        RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
        EVENT_NAME: ${{ github.event_name }}
      shell: bash # implies `-o pipefail`, so a Lean failure isn'
t masked by `tee`
      run: |
        echo "::group::Running duplicate declarations report"
        lake env lean scripts/dup_decls_report.lean 2>&1 | tee dup_decls_report.txt
        echo "::endgroup::"

        # Print the duplicate count of category `$1`, read from the first `Number of duplicates`
        # line under its `=== Duplicate $1 ===` header (or nothing if that section has no count).
        # This is somewhat fragile and depends on an exact header match and the number appearing as the
        # 4th word of its line.
        count() {
          awk -v header="=== Duplicate $1 ===" '
            $0 == header { found = 1; next }
            /^=== / { found = 0 }
            found && /^Number of duplicates: / { print $4; exit }'
 dup_decls_report.txt
        }
        thm="$(count theorems)"
        inst="$(count instances)"
        def="$(count defs)"

        # Build the Zulip summary message; the full listing is uploaded as an artifact below.
        {
          echo 'summary<<SUMMARY_EOF'
          echo "**Duplicate declarations report (triggered by ${EVENT_NAME})**"
          echo ''
          echo "- Theorems: ${thm:-?} duplicate group(s)"
          echo "- Instances: ${inst:-?} duplicate group(s)"
          echo "- Defs: ${def:-?} duplicate group(s)"
          echo ''
          echo "The full report is attached as the \`dup-decls-report\` artifact on [this workflow run](${RUN_URL})."
          echo 'SUMMARY_EOF'
        } | tee -a "$GITHUB_OUTPUT"

    - name: Upload the full report
      # Also upload a partial report when the report step fails.
      if: ${{ !cancelled() }}
      uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
      with:
        name: dup-decls-report
        path: dup_decls_report.txt
        retention-days: 90

    - name: Post summary to Zulip
      if: ${{ toJson(inputs.dry_run) != 'true' }}
      uses: zulip/github-actions-zulip/send-message@f675f2b4eb2a95fae974215476dcb7ad8dfeff6b # v2.0.2
      with:
        api-key: ${{ secrets.ZULIP_API_KEY }}
        email: 'github-mathlib4-bot@leanprover.zulipchat.com'
        organization-url: 'https://leanprover.zulipchat.com'
        to: 'mathlib4'
        type: 'stream'
        topic: Duplicate declarations
        content: ${{ steps.report.outputs.summary }}

    - name: Send Zulip message (failure)
      if: ${{ toJson(inputs.dry_run) != 'true' && failure() }}
      uses: zulip/github-actions-zulip/send-message@f675f2b4eb2a95fae974215476dcb7ad8dfeff6b # v2.0.2
      with:
        api-key: ${{ secrets.ZULIP_API_KEY }}
        email: 'github-mathlib4-bot@leanprover.zulipchat.com'
        organization-url: 'https://leanprover.zulipchat.com'
        to: 'mathlib4'
        type: 'stream'
        topic: Duplicate declarations
        content: |
          [`Duplicate declarations` workflow run failed](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})

          triggered by: `${{ github.event_name }}`

[Dauer der Verarbeitung: 0.3 Sekunden, vorverarbeitet 2026-11-18]