Eine aufbereitete Darstellung der Quelle

 
     
 
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung


Quelle  action.yml  Sprache: unbekannt

 
Spracherkennung für: .yml vermutete Sprache: SQL {SQL[70] VDM[50] Apollo[47]} [Methode: maximale Elemente, drei Dimensionen]

# Shared runner setup for the self-hosted `build` and `test_lint` jobs in
# build_template.yml. Both run on the same self-hosted pool and need the same
# preparation before they diverge (build → build + stage, test_lint →
# fetch + test + lint): the cache-trust and get-tools wiring, the PR-branch
# checkout, the elan toolchain and LEAN_SRC_PATH environment, and the
# dependency download. The runner image provides jq, landrun and the `gh` CLI.
#
# The caller runs `Checkout local actions` (sparse `.github/actions` →
# `workflow-actions/`) before invoking this action: that checkout puts both this
# action and the sibling actions it calls (`cache-trust-dispatch`, `get-tools`)
# on disk under `workflow-actions/`, so the `uses: ./workflow-actions/...` paths
# below resolve relative to the workspace root, as in the calling workflow.
#
# Each `run:` step sets its own `shell:`, since composite steps do not inherit the
# job's landrun `defaults.run.shell`.
name: Set up build environment
description: Shared self-hosted runner setup for the build and test_lint jobs.

inputs:
  pr_branch_ref:
    description: Git ref of the PR branch to check out and build.
    required: true
  tools_branch_ref:
    description: Git ref to build the CI tools from when not using the prebuilt artifact.
    required: false
    default: '
'

runs:
  using: composite
  steps:
    # Compute the trust-classified container target and read fallback for this
    # job. Sets MATHLIB_CACHE_FROM / MATHLIB_CACHE_PRIMARY in env so every
    # subsequent `cache get` inherits them without per-call flag plumbing. Loaded
    # from the trust-rooted `workflow-actions/` checkout, not the PR branch.
    - name: Compute cache trust dispatch
      uses: ./workflow-actions/.github/actions/cache-trust-dispatch
      with:
        repo: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
        branch: ${{ github.head_ref || github.ref_name }}
        head-sha: ${{ github.event.pull_request.head.sha || github.sha }}

    # Checkout the PR branch into a subdirectory. HEAD only (fetch-depth: 1) is
    # enough: the cache is fetched HEAD-scoped and warmed from the master snapshot,
    # so no parent-commit history is needed. This is untrusted (potentially fork)
    # code we build, so don'
t leave the GITHUB_TOKEN in pr-branch/.git/config where
    # that code could read it.
    - name: Checkout PR branch
      uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
      with:
        ref: ${{ inputs.pr_branch_ref }}
        fetch-depth: 1
        path: pr-branch
        persist-credentials: false
        # The build runs this fork PR code sandboxed (landrun) with no persisted
        # credentials, so checking it out under pull_request_target is safe.
        allow-unsafe-pr-checkout: true

    # The steps below and the landrun rules expect the checkout to contain no
    # symlinks, and nothing under `.lake/`.
    - name: check checkout contents
      shell: bash
      run: |
        set -euo pipefail
        cd pr-branch
        # Allowed entries are in `git ls-files --stage` format: mode, blob (for a
        # symlink, its target), stage, path. The two `scripts/bench/` symlinks
        # were removed when this check was added; branches based on older commits
        # still contain them. TODO: drop these entries once such branches are no
        # longer being built.
        links=$(git ls-files --stage | awk '
          BEGIN {
            allowed["120000 819298943e1a8c331413fb55e2c4bbc98d05e562 0\tscripts/bench/build/fake-root/bin/lean.py"] = 1
            allowed["120000 e5224d533ef27b001224859a9b36696846a7e7fe 0\tscripts/bench/size/run.py"] = 1
          }
          $1 == "120000" && !($0 in allowed)')
        if [ -n "${links}" ]; then
          echo "::error::The branch contains symlinks, which are not supported:"
          echo "${links}"
          exit 1
        fi
        lake=$(git ls-files -- .lake DownstreamTest/.lake)
        if [ -n "${lake}" ]; then
          echo "::error::The branch contains files under .lake/, which must not be committed:"
          echo "${lake}"
          exit 1
        fi

    # Create empty directories so landrun doesn'
t complain.
    - name: Create empty directories
      shell: bash # We need to run this outside landrun, as it is a prerequisite for landrun!
      run: |
        mkdir -p pr-branch/.lake/
        mkdir -p /home/lean/.cache/mathlib/

    # NOTE: if you copy this, consider using `leanprover/lean-action` instead.
    # We install manually, to avoid running lean outside landrun.
    - name: install elan
      shell: bash
      run: |
        set -o pipefail
        curl -o elan-init.sh -sSfL https://elan.lean-lang.org/elan-init.sh
        chmod +x elan-init.sh
        ./elan-init.sh -y --default-toolchain none
        echo "$HOME/.elan/bin" >> "${GITHUB_PATH}"

    - name: set toolchain directory
      shell: bash
      env:
        IS_FORK: ${{ github.event.pull_request.head.repo.fork == true }}
      run: |
        set -euo pipefail
        cd pr-branch
        # CI only builds against official Lean releases and nightlies; builds of
        # lean4 PRs (`lean4-pr-releases`) are only used on branches of this repository.
        origins='lean4|lean4-nightly|lean4-pr-releases'
        if [ "$IS_FORK" = true ]; then origins='lean4|lean4-nightly'; fi
        toolchain="$(cat lean-toolchain)"
        if ! [[ "$toolchain" =~ ^leanprover/($origins):[A-Za-z0-9][A-Za-z0-9.-]*$ ]]; then
          echo "::error file=lean-toolchain::lean-toolchain must name a toolchain from leanprover/${origins//|/, leanprover/}, e.g. 'leanprover/lean4:v4.24.0'"
          exit 1
        fi
        # Get the lake binary path from elan and extract toolchain directory
        LAKE_PATH=$(ELAN_TOOLCHAIN="$toolchain" elan which lake)
        echo "Lake path: $LAKE_PATH"

        # Extract the toolchain directory by removing /bin/lake from the end
        TOOLCHAIN_DIR=$(dirname "$LAKE_PATH")
        TOOLCHAIN_DIR=$(dirname "$TOOLCHAIN_DIR")
        echo "Toolchain directory: $TOOLCHAIN_DIR"

        # Set it as an environment variable for subsequent steps
        echo "TOOLCHAIN_DIR=$TOOLCHAIN_DIR" >> "$GITHUB_ENV"

    - name: set LEAN_SRC_PATH
      shell: bash
      run: |
        cd pr-branch

        # Start with the base paths
        LEAN_SRC_PATH=".:$TOOLCHAIN_DIR/src/lean/lake"

        # Extract package names from lake-manifest.json and validate them
        # Only allow A-Z, a-z, 0-9, _, and - characters
        # Build the LEAN_SRC_PATH by appending each validated package
        PACKAGE_NAMES=$(jq -r '.packages[].name' lake-manifest.json)
        for pkg in $PACKAGE_NAMES; do
          if [[ "$pkg" =~ ^[A-Za-z0-9_-]+$ ]]; then
            LEAN_SRC_PATH="$LEAN_SRC_PATH:.lake/packages/$pkg"
          else
            echo "Warning: Skipping invalid package name: $pkg"
          fi
        done

        echo "LEAN_SRC_PATH=$LEAN_SRC_PATH"

        # Set it as an environment variable for subsequent steps
        echo "LEAN_SRC_PATH=$LEAN_SRC_PATH" >> "$GITHUB_ENV"

    # Populate `tools-branch/` with the trusted CI tooling (the `cache` binary and
    # the `lake-build-*` helper scripts invoked by path). Fast path: download the
    # prebuilt `tools-bin` artifact published from master (canonical mathlib4 only,
    # and only when the branch under test doesn't change the cache tool — get-tools
    # makes that comparison against `source_dir`). Source build otherwise. See the
    # get-tools action for the full trust rationale.
    - name: Get CI tools
      uses: ./workflow-actions/.github/actions/get-tools
      with:
        use_artifact: ${{ inputs.tools_branch_ref == '
' && github.repository == 'leanprover-community/mathlib4' }}
        tools_source_ref: ${{ inputs.tools_branch_ref != '
' && inputs.tools_branch_ref || (github.event.pull_request.head.repo.fork && 'master' || inputs.pr_branch_ref) }}
        source_dir: ${{ github.event.pull_request.head.repo.fork != true && '
pr-branch' || '' }}
        github_token: ${{ github.token }}

    # Resolve the sysroot of the toolchain pinned by `tools-branch` (`master` for
    # fork PRs). The `cache` steps put its `bin/` first on PATH, so the `lean` and
    # `leantar` that `cache` invokes come from this toolchain rather than the one
    # the PR'
s `lean-toolchain` selects. Fails if the sysroot can't be resolved.
    - name: resolve trusted toolchain
      shell: bash
      run: |
        set -euo pipefail
        prefix="$(cd tools-branch && lean --print-prefix)"
        if [ -z "${prefix}" ]; then
          echo "::error::could not resolve the trusted toolchain sysroot from tools-branch"
          exit 1
        fi
        echo "Trusted toolchain sysroot: ${prefix}"
        echo "TRUSTED_LEAN_PREFIX=${prefix}" >> "$GITHUB_ENV"

    - name: download dependencies
      # We need network access to download dependencies. We run this inside
      # landrun, but restrict disk access:
      # - --rox access to `~/.elan` and `~/actions-runner/_work` (GitHub CI needs this)
      # - --unrestricted-network as we need this to download dependencies
      # - git needs read only access to `/etc`.
      shell: landrun --unrestricted-network --rox /etc --rox /usr --rw /dev --rox /home/lean/.elan --rox /home/lean/actions-runner/_work --rw pr-branch/.lake/ --env PATH --env HOME --env GITHUB_OUTPUT --env CI -- bash -euxo pipefail {0}
      run: |
        cd pr-branch
        lake env

[Dauer der Verarbeitung: 0.4 Sekunden, vorverarbeitet 2026-11-20]

                                                                                                                                                                                                                                                                                                                                                                                                     

 

Neuigkeiten

Aktuelles
Motto des Tages

Open Source Software


Gedichte
Musik
Bilder

Jenseits des Üblichen

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1,188,114
#Domains=863,579