mirror of
https://github.com/j178/prek.git
synced 2026-06-19 17:17:53 +02:00
Centralize CI workflow planning (#2030)
This commit is contained in:
@@ -0,0 +1,135 @@
|
||||
name: "Build dev binaries"
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
save-rust-cache:
|
||||
required: false
|
||||
type: string
|
||||
default: "true"
|
||||
|
||||
permissions: {}
|
||||
|
||||
env:
|
||||
CARGO_INCREMENTAL: 0
|
||||
CARGO_NET_RETRY: 10
|
||||
CARGO_TERM_COLOR: always
|
||||
RUSTUP_MAX_RETRIES: 10
|
||||
|
||||
jobs:
|
||||
build-binary-msrv:
|
||||
name: "build binary | msrv"
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: "Read MSRV from Cargo.toml"
|
||||
id: msrv
|
||||
run: |
|
||||
MSRV=$(grep -m1 'rust-version' Cargo.toml | sed 's/.*"\([^"]*\)".*/\1/')
|
||||
echo "value=$MSRV" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: "Install Rust toolchain"
|
||||
run: rustup default "${MSRV}"
|
||||
env:
|
||||
MSRV: ${{ steps.msrv.outputs.value }}
|
||||
|
||||
- name: "Install mold"
|
||||
uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1
|
||||
|
||||
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
|
||||
with:
|
||||
save-if: ${{ inputs.save-rust-cache == 'true' }}
|
||||
|
||||
- run: cargo +"${MSRV}" build --profile no-debug --bin prek
|
||||
env:
|
||||
MSRV: ${{ steps.msrv.outputs.value }}
|
||||
|
||||
- run: ./target/no-debug/prek --version
|
||||
|
||||
build-binary-linux-libc:
|
||||
name: "build binary | linux libc"
|
||||
timeout-minutes: 10
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1
|
||||
|
||||
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
|
||||
with:
|
||||
save-if: ${{ inputs.save-rust-cache == 'true' }}
|
||||
|
||||
- name: "Build"
|
||||
run: cargo build --profile no-debug --bin prek
|
||||
|
||||
- name: "Upload binary"
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: prek-linux-libc-${{ github.sha }}
|
||||
path: |
|
||||
./target/no-debug/prek
|
||||
retention-days: 1
|
||||
|
||||
build-binary-macos-aarch64:
|
||||
name: "build binary | macos aarch64"
|
||||
timeout-minutes: 10
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
|
||||
with:
|
||||
save-if: ${{ inputs.save-rust-cache == 'true' }}
|
||||
|
||||
- name: "Build"
|
||||
run: cargo build --profile no-debug --bin prek
|
||||
|
||||
- name: "Upload binary"
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: prek-macos-aarch64-${{ github.sha }}
|
||||
path: |
|
||||
./target/no-debug/prek
|
||||
retention-days: 1
|
||||
|
||||
build-binary-windows-x86_64:
|
||||
name: "build binary | windows x86_64"
|
||||
timeout-minutes: 10
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Setup Dev Drive
|
||||
run: ${{ github.workspace }}/.github/workflows/setup-dev-drive.ps1
|
||||
|
||||
# actions/checkout does not let us clone into anywhere outside ${{ github.workspace }}, so we have to copy the clone...
|
||||
- name: Copy Git Repo to Dev Drive
|
||||
run: |
|
||||
Copy-Item -Path "${{ github.workspace }}" -Destination "$Env:PREK_WORKSPACE" -Recurse
|
||||
|
||||
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
|
||||
with:
|
||||
workspaces: ${{ env.PREK_WORKSPACE }}
|
||||
save-if: ${{ inputs.save-rust-cache == 'true' }}
|
||||
|
||||
- name: "Build"
|
||||
working-directory: ${{ env.PREK_WORKSPACE }}
|
||||
run: cargo build --profile no-debug --bin prek
|
||||
|
||||
- name: "Upload binary"
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: prek-windows-x86_64-${{ github.sha }}
|
||||
path: |
|
||||
${{ env.PREK_WORKSPACE }}/target/no-debug/prek.exe
|
||||
retention-days: 1
|
||||
@@ -12,9 +12,6 @@ on:
|
||||
plan:
|
||||
required: true
|
||||
type: string
|
||||
pull_request:
|
||||
paths:
|
||||
- .github/workflows/build-docker.yml
|
||||
|
||||
env:
|
||||
PREK_BASE_IMG: ghcr.io/${{ github.repository_owner }}/prek
|
||||
@@ -24,8 +21,29 @@ permissions:
|
||||
packages: write # zizmor: ignore[excessive-permissions]
|
||||
|
||||
jobs:
|
||||
plan:
|
||||
runs-on: ubuntu-slim
|
||||
outputs:
|
||||
publish: ${{ steps.plan.outputs.publish }}
|
||||
steps:
|
||||
- name: Plan
|
||||
id: plan
|
||||
shell: bash
|
||||
env:
|
||||
HAS_PLAN: ${{ inputs.plan != '' }}
|
||||
HAS_IMPLICIT_TAG: ${{ inputs.plan != '' && fromJson(inputs.plan).announcement_tag_is_implicit }}
|
||||
run: |
|
||||
[[ "$HAS_PLAN" == "true" && "$HAS_IMPLICIT_TAG" != "true" ]] && publish=1
|
||||
|
||||
if [[ "$publish" ]]; then
|
||||
echo "publish=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "publish=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
docker-build:
|
||||
name: Build Docker image ghcr.io/j178/prek for ${{ matrix.platform }}
|
||||
needs: plan
|
||||
runs-on: ubuntu-latest
|
||||
environment:
|
||||
name: release
|
||||
@@ -43,13 +61,14 @@ jobs:
|
||||
- uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
||||
|
||||
- uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
|
||||
if: ${{ needs.plan.outputs.publish == 'true' }}
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Check tag consistency
|
||||
if: ${{ inputs.plan != '' && !fromJson(inputs.plan).announcement_tag_is_implicit }}
|
||||
if: ${{ needs.plan.outputs.publish == 'true' }}
|
||||
env:
|
||||
TAG: ${{ inputs.plan != '' && fromJson(inputs.plan).announcement_tag || 'dry-run' }}
|
||||
run: |
|
||||
@@ -72,8 +91,8 @@ jobs:
|
||||
images: ${{ env.PREK_BASE_IMG }}
|
||||
# Defining this makes sure the org.opencontainers.image.version OCI label becomes the actual release version and not the branch name
|
||||
tags: |
|
||||
type=raw,value=dry-run,enable=${{ inputs.plan == '' || fromJson(inputs.plan).announcement_tag_is_implicit }}
|
||||
type=semver,pattern={{ raw }},value=${{ inputs.plan != '' && fromJson(inputs.plan).announcement_tag || 'dry-run' }},enable=${{ inputs.plan != '' && !fromJson(inputs.plan).announcement_tag_is_implicit }}
|
||||
type=raw,value=dry-run,enable=${{ needs.plan.outputs.publish != 'true' }}
|
||||
type=semver,pattern={{ raw }},value=${{ inputs.plan != '' && fromJson(inputs.plan).announcement_tag || 'dry-run' }},enable=${{ needs.plan.outputs.publish == 'true' }}
|
||||
|
||||
- name: Normalize Platform Pair (replace / with -)
|
||||
run: |
|
||||
@@ -90,7 +109,7 @@ jobs:
|
||||
cache-from: type=gha,scope=prek-${{ env.PLATFORM_TUPLE }}
|
||||
cache-to: type=gha,mode=min,scope=prek-${{ env.PLATFORM_TUPLE }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
outputs: type=image,name=${{ env.PREK_BASE_IMG }},push-by-digest=true,name-canonical=true,push=${{ inputs.plan != '' && !fromJson(inputs.plan).announcement_tag_is_implicit }}
|
||||
outputs: type=image,name=${{ env.PREK_BASE_IMG }},push-by-digest=true,name-canonical=true,push=${{ needs.plan.outputs.publish == 'true' }}
|
||||
|
||||
- name: Export digests
|
||||
env:
|
||||
@@ -113,13 +132,14 @@ jobs:
|
||||
environment:
|
||||
name: release
|
||||
needs:
|
||||
- plan
|
||||
- docker-build
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
id-token: write
|
||||
attestations: write
|
||||
if: ${{ inputs.plan != '' && !fromJson(inputs.plan).announcement_tag_is_implicit }}
|
||||
if: ${{ needs.plan.outputs.publish == 'true' }}
|
||||
steps:
|
||||
- name: Download digests
|
||||
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
|
||||
+3
-11
@@ -4,9 +4,9 @@
|
||||
# Assumed to run as a subworkflow of .github/workflows/release.yml; specifically, as a local
|
||||
# artifacts job within `cargo-dist`.
|
||||
#
|
||||
# Adapted from https://github.com/astral-sh/uv/blob/main/.github/workflows/build-binaries.yml
|
||||
# Adapted from https://github.com/astral-sh/uv/blob/main/.github/workflows/build-release-binaries.yml
|
||||
|
||||
name: "Build binaries"
|
||||
name: "Build release binaries"
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
@@ -14,15 +14,8 @@ on:
|
||||
plan:
|
||||
required: true
|
||||
type: string
|
||||
pull_request:
|
||||
paths:
|
||||
# When we change pyproject.toml, we want to ensure that the maturin builds still work.
|
||||
- pyproject.toml
|
||||
# And when we change this workflow itself...
|
||||
- .github/workflows/build-binaries.yml
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
permissions: {}
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
@@ -150,7 +143,6 @@ jobs:
|
||||
*.tar.gz
|
||||
*.sha256
|
||||
|
||||
|
||||
linux:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
+116
-163
@@ -38,71 +38,81 @@ env:
|
||||
|
||||
jobs:
|
||||
plan:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-slim
|
||||
outputs:
|
||||
test-code: ${{ !contains(github.event.pull_request.labels.*.name, 'test:skip') && (steps.changed.outputs.any_code_changed == 'true' || github.ref == 'refs/heads/master') }}
|
||||
save-rust-cache: ${{ github.ref == 'refs/heads/master' || steps.changed.outputs.cache_changed == 'true' }}
|
||||
test-code: ${{ steps.plan.outputs.test_code }}
|
||||
save-rust-cache: ${{ steps.plan.outputs.save_rust_cache }}
|
||||
language-test-matrix: ${{ steps.nextest.outputs.language-test-matrix }}
|
||||
ci-core-filter: ${{ steps.nextest.outputs.ci-core-filter }}
|
||||
# Run benchmarks if Rust code or benchmark-related files changed
|
||||
run-bench: ${{ !contains(github.event.pull_request.labels.*.name, 'test:skip') && (steps.changed.outputs.rust_code_changed == 'true' || steps.changed.outputs.bench_related_changed == 'true' || github.ref == 'refs/heads/master') }}
|
||||
run-bench: ${{ steps.plan.outputs.run_bench }}
|
||||
run-zizmor: ${{ steps.plan.outputs.run_zizmor }}
|
||||
build-release-binaries: ${{ steps.plan.outputs.build_release_binaries }}
|
||||
build-docker: ${{ steps.plan.outputs.build_docker }}
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
- name: "Determine changed files"
|
||||
id: changed
|
||||
- name: "Plan"
|
||||
id: plan
|
||||
shell: bash
|
||||
env:
|
||||
GH_REF: ${{ github.ref }}
|
||||
HAS_SKIP_LABEL: ${{ contains(github.event.pull_request.labels.*.name, 'test:skip') }}
|
||||
HAS_BUILD_SKIP_LABEL: ${{ contains(github.event.pull_request.labels.*.name, 'build:skip') }}
|
||||
HAS_BUILD_SKIP_DOCKER_LABEL: ${{ contains(github.event.pull_request.labels.*.name, 'build:skip-docker') }}
|
||||
HAS_BUILD_SKIP_RELEASE_LABEL: ${{ contains(github.event.pull_request.labels.*.name, 'build:skip-release') }}
|
||||
HAS_BUILD_RELEASE_LABEL: ${{ contains(github.event.pull_request.labels.*.name, 'build:release') }}
|
||||
BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||
run: |
|
||||
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha || 'origin/master' }}...HEAD)
|
||||
|
||||
ANY_CODE_CHANGED=false
|
||||
CACHE_CHANGED=false
|
||||
RUST_CODE_CHANGED=false
|
||||
BENCH_RELATED_CHANGED=false
|
||||
[[ "$GH_REF" == "refs/heads/master" ]] && on_master_branch=1
|
||||
[[ "$HAS_SKIP_LABEL" == "true" ]] && has_skip_label=1
|
||||
[[ "$HAS_BUILD_SKIP_LABEL" == "true" ]] && has_build_skip_label=1
|
||||
[[ "$HAS_BUILD_SKIP_DOCKER_LABEL" == "true" ]] && has_build_skip_docker_label=1
|
||||
[[ "$HAS_BUILD_SKIP_RELEASE_LABEL" == "true" ]] && has_build_skip_release_label=1
|
||||
[[ "$HAS_BUILD_RELEASE_LABEL" == "true" ]] && has_build_release_label=1
|
||||
|
||||
while IFS= read -r file; do
|
||||
# Check if cache-relevant files changed (Cargo files, toolchain, workflows)
|
||||
if [[ "${file}" == "Cargo.lock" || "${file}" == "Cargo.toml" || "${file}" == "rust-toolchain.toml" || "${file}" == ".cargo/config.toml" || "${file}" =~ ^crates/.*/Cargo\.toml$ || "${file}" =~ ^\.github/workflows/.*\.yml$ ]]; then
|
||||
echo "Detected cache-relevant change: ${file}"
|
||||
CACHE_CHANGED=true
|
||||
fi
|
||||
[[ -z "$file" ]] && continue
|
||||
[[ "$file" =~ \.rs$ ]] && rust_code_changed=1
|
||||
[[ "$file" == "Cargo.toml" || "$file" == "Cargo.lock" || "$file" =~ ^crates/.*/Cargo\.toml$ ]] && rust_deps_changed=1
|
||||
[[ "$file" == "rust-toolchain.toml" || "$file" =~ ^\.cargo/ ]] && rust_config_changed=1
|
||||
[[ "$file" == "pyproject.toml" || "$file" =~ ^python/ ]] && python_config_changed=1
|
||||
[[ "$file" =~ ^\.github/workflows/.*\.ya?ml$ ]] && workflow_changed=1
|
||||
[[ "$file" == ".github/workflows/ci.yml" ]] && ci_workflow_changed=1
|
||||
[[ "$file" == ".github/workflows/build-release-binaries.yml" || "$file" == ".github/workflows/release.yml" ]] && release_workflow_changed=1
|
||||
[[ "$file" == "dist-workspace.toml" ]] && release_config_changed=1
|
||||
[[ "$file" == ".github/zizmor.yml" ]] && zizmor_config_changed=1
|
||||
[[ "$file" == "Dockerfile" ]] && dockerfile_changed=1
|
||||
[[ "$file" == ".github/workflows/build-docker.yml" ]] && docker_workflow_changed=1
|
||||
[[ "$file" == ".github/workflows/performance.yml" ]] && bench_workflow_changed=1
|
||||
[[ "$file" =~ ^scripts/hyperfine-.*\.sh$ ]] && bench_scripts_changed=1
|
||||
[[ "$file" =~ ^docs/ || "$file" =~ ^mkdocs.*\.yml$ || "$file" =~ \.md$ ]] && continue
|
||||
any_code_changed=1
|
||||
done <<< "$(git diff --name-only "${BASE_SHA:-origin/master}...HEAD")"
|
||||
|
||||
# Check if Rust code changed (for benchmarks)
|
||||
if [[ "${file}" =~ \.rs$ ]] || [[ "${file}" =~ Cargo\.toml$ ]] || [[ "${file}" == "Cargo.lock" ]] || [[ "${file}" == "rust-toolchain.toml" ]] || [[ "${file}" =~ ^\.cargo/ ]]; then
|
||||
echo "Detected Rust code change: ${file}"
|
||||
RUST_CODE_CHANGED=true
|
||||
fi
|
||||
[[ $rust_code_changed || $rust_deps_changed || $rust_config_changed ]] && any_rust_changed=1
|
||||
[[ $rust_deps_changed || $rust_config_changed || $workflow_changed ]] && cache_relevant_changed=1
|
||||
[[ $bench_workflow_changed || $bench_scripts_changed ]] && bench_related_changed=1
|
||||
[[ $python_config_changed || $rust_deps_changed || $rust_config_changed || $release_workflow_changed || $release_config_changed || $ci_workflow_changed ]] && release_build_changed=1
|
||||
[[ $python_config_changed || $rust_deps_changed || $rust_config_changed || $release_config_changed || $dockerfile_changed || $docker_workflow_changed || $ci_workflow_changed ]] && docker_build_changed=1
|
||||
|
||||
if [[ "${file}" == ".github/workflows/performance.yml" ]] || [[ "${file}" =~ ^scripts/hyperfine-.*\.sh$ ]]; then
|
||||
echo "Detected benchmark-related change: ${file}"
|
||||
BENCH_RELATED_CHANGED=true
|
||||
fi
|
||||
[[ ! $has_skip_label && ($any_code_changed || $on_master_branch) ]] && test_code=1
|
||||
[[ $on_master_branch || $cache_relevant_changed ]] && save_rust_cache=1
|
||||
[[ ! $has_skip_label && ($any_rust_changed || $bench_related_changed || $on_master_branch) ]] && run_bench=1
|
||||
[[ ! $has_skip_label && ($workflow_changed || $zizmor_config_changed || $on_master_branch) ]] && run_zizmor=1
|
||||
[[ ! $has_skip_label && ! $has_build_skip_label && ! $has_build_skip_release_label && ($release_build_changed || $has_build_release_label) ]] && build_release_binaries=1
|
||||
[[ ! $has_skip_label && ! $has_build_skip_label && ! $has_build_skip_docker_label && $docker_build_changed ]] && build_docker=1
|
||||
|
||||
if [[ "${file}" =~ ^docs/ ]]; then
|
||||
echo "Skipping ${file} (matches docs/ pattern)"
|
||||
continue
|
||||
fi
|
||||
if [[ "${file}" =~ ^mkdocs.*\.yml$ ]]; then
|
||||
echo "Skipping ${file} (matches mkdocs*.yml pattern)"
|
||||
continue
|
||||
fi
|
||||
if [[ "${file}" =~ \.md$ ]]; then
|
||||
echo "Skipping ${file} (matches *.md pattern)"
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "Detected code change in: ${file}"
|
||||
ANY_CODE_CHANGED=true
|
||||
|
||||
done <<< "${CHANGED_FILES}"
|
||||
out() { [[ "$2" ]] && echo "$1=true" || echo "$1=false"; }
|
||||
{
|
||||
echo "any_code_changed=${ANY_CODE_CHANGED}"
|
||||
echo "cache_changed=${CACHE_CHANGED}"
|
||||
echo "rust_code_changed=${RUST_CODE_CHANGED}"
|
||||
echo "bench_related_changed=${BENCH_RELATED_CHANGED}"
|
||||
out test_code "$test_code"
|
||||
out save_rust_cache "$save_rust_cache"
|
||||
out run_bench "$run_bench"
|
||||
out run_zizmor "$run_zizmor"
|
||||
out build_release_binaries "$build_release_binaries"
|
||||
out build_docker "$build_docker"
|
||||
} >> "${GITHUB_OUTPUT}"
|
||||
|
||||
- name: "Generate nextest filters"
|
||||
@@ -112,7 +122,6 @@ jobs:
|
||||
python3 scripts/generate_ci_matrix.py --group-size 4 --github-output >> "${GITHUB_OUTPUT}"
|
||||
|
||||
lint:
|
||||
name: "lint"
|
||||
timeout-minutes: 10
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
@@ -129,7 +138,6 @@ jobs:
|
||||
PREK_SKIP: cargo-fmt,cargo-clippy
|
||||
|
||||
check-release:
|
||||
name: "check release"
|
||||
needs: plan
|
||||
timeout-minutes: 10
|
||||
runs-on: ubuntu-latest
|
||||
@@ -150,6 +158,35 @@ jobs:
|
||||
echo "dist plan completed successfully"
|
||||
cat plan-dist-manifest.json
|
||||
|
||||
check-zizmor:
|
||||
needs: plan
|
||||
if: ${{ needs.plan.outputs.run-zizmor == 'true' }}
|
||||
uses: ./.github/workflows/zizmor.yml
|
||||
permissions:
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
build-release-binaries:
|
||||
needs: plan
|
||||
if: ${{ needs.plan.outputs.build-release-binaries == 'true' }}
|
||||
uses: ./.github/workflows/build-release-binaries.yml
|
||||
with:
|
||||
# CI has no cargo-dist manifest; release.yml passes the real plan when publishing.
|
||||
plan: ""
|
||||
|
||||
build-docker:
|
||||
needs: plan
|
||||
if: ${{ needs.plan.outputs.build-docker == 'true' }}
|
||||
uses: ./.github/workflows/build-docker.yml
|
||||
with:
|
||||
# CI has no cargo-dist manifest; an empty plan keeps Docker builds in dry-run mode.
|
||||
plan: ""
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
packages: write
|
||||
attestations: write
|
||||
|
||||
cargo-clippy-linux:
|
||||
name: "cargo clippy | ubuntu"
|
||||
needs: plan
|
||||
@@ -612,121 +649,37 @@ jobs:
|
||||
working-directory: cpython
|
||||
run: cargo run -p prek -- --all-files
|
||||
|
||||
build-binary-msrv:
|
||||
build-dev-binaries:
|
||||
needs: plan
|
||||
if: ${{ needs.plan.outputs.test-code == 'true' }}
|
||||
name: "build binary | msrv"
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
uses: ./.github/workflows/build-dev-binaries.yml
|
||||
with:
|
||||
save-rust-cache: ${{ needs.plan.outputs.save-rust-cache }}
|
||||
|
||||
required-checks-passed:
|
||||
name: "all required jobs passed"
|
||||
if: always()
|
||||
needs:
|
||||
- lint
|
||||
- check-release
|
||||
- check-zizmor
|
||||
- cargo-clippy-linux
|
||||
- cargo-clippy-windows
|
||||
- cargo-shear
|
||||
- cargo-test-without-uv
|
||||
- cargo-test
|
||||
- cargo-test-windows
|
||||
- language-tests
|
||||
- ecosystem-cpython
|
||||
- build-dev-binaries
|
||||
runs-on: ubuntu-slim
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: "Read MSRV from Cargo.toml"
|
||||
id: msrv
|
||||
- name: "Check required jobs passed"
|
||||
run: |
|
||||
MSRV=$(grep -m1 'rust-version' Cargo.toml | sed 's/.*"\([^"]*\)".*/\1/')
|
||||
echo "value=$MSRV" >> "$GITHUB_OUTPUT"
|
||||
- name: "Install Rust toolchain"
|
||||
run: rustup default "${MSRV}"
|
||||
failing=$(echo "$NEEDS_JSON" | jq -r 'to_entries[] | select(.value.result != "success" and .value.result != "skipped") | "\(.key): \(.value.result)"')
|
||||
if [ -n "$failing" ]; then
|
||||
echo "$failing"
|
||||
exit 1
|
||||
fi
|
||||
env:
|
||||
MSRV: ${{ steps.msrv.outputs.value }}
|
||||
- name: "Install mold"
|
||||
uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1
|
||||
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
|
||||
with:
|
||||
save-if: ${{ needs.plan.outputs.save-rust-cache == 'true' }}
|
||||
- run: cargo +"${MSRV}" build --profile no-debug --bin prek
|
||||
env:
|
||||
MSRV: ${{ steps.msrv.outputs.value }}
|
||||
- run: ./target/no-debug/prek --version
|
||||
|
||||
build-binary-linux-libc:
|
||||
needs: plan
|
||||
if: ${{ needs.plan.outputs.test-code == 'true' }}
|
||||
timeout-minutes: 10
|
||||
runs-on: ubuntu-latest
|
||||
name: "build binary | linux libc"
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1
|
||||
|
||||
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
|
||||
with:
|
||||
save-if: ${{ needs.plan.outputs.save-rust-cache == 'true' }}
|
||||
|
||||
- name: "Build"
|
||||
run: cargo build --profile no-debug --bin prek
|
||||
|
||||
- name: "Upload binary"
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: prek-linux-libc-${{ github.sha }}
|
||||
path: |
|
||||
./target/no-debug/prek
|
||||
retention-days: 1
|
||||
|
||||
build-binary-macos-aarch64:
|
||||
needs: plan
|
||||
if: ${{ needs.plan.outputs.test-code == 'true' }}
|
||||
timeout-minutes: 10
|
||||
runs-on: macos-latest
|
||||
name: "build binary | macos aarch64"
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
|
||||
with:
|
||||
save-if: ${{ needs.plan.outputs.save-rust-cache == 'true' }}
|
||||
|
||||
- name: "Build"
|
||||
run: cargo build --profile no-debug --bin prek
|
||||
|
||||
- name: "Upload binary"
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: prek-macos-aarch64-${{ github.sha }}
|
||||
path: |
|
||||
./target/no-debug/prek
|
||||
retention-days: 1
|
||||
|
||||
build-binary-windows-x86_64:
|
||||
needs: plan
|
||||
if: ${{ needs.plan.outputs.test-code == 'true' }}
|
||||
timeout-minutes: 10
|
||||
runs-on: windows-latest
|
||||
name: "build binary | windows x86_64"
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Setup Dev Drive
|
||||
run: ${{ github.workspace }}/.github/workflows/setup-dev-drive.ps1
|
||||
|
||||
# actions/checkout does not let us clone into anywhere outside ${{ github.workspace }}, so we have to copy the clone...
|
||||
- name: Copy Git Repo to Dev Drive
|
||||
run: |
|
||||
Copy-Item -Path "${{ github.workspace }}" -Destination "$Env:PREK_WORKSPACE" -Recurse
|
||||
|
||||
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
|
||||
with:
|
||||
workspaces: ${{ env.PREK_WORKSPACE }}
|
||||
save-if: ${{ needs.plan.outputs.save-rust-cache == 'true' }}
|
||||
|
||||
- name: "Build"
|
||||
working-directory: ${{ env.PREK_WORKSPACE }}
|
||||
run: cargo build --profile no-debug --bin prek
|
||||
|
||||
- name: "Upload binary"
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: prek-windows-x86_64-${{ github.sha }}
|
||||
path: |
|
||||
${{ env.PREK_WORKSPACE }}/target/no-debug/prek.exe
|
||||
retention-days: 1
|
||||
NEEDS_JSON: ${{ toJSON(needs) }}
|
||||
|
||||
@@ -90,11 +90,11 @@ jobs:
|
||||
name: artifacts-plan-dist-manifest
|
||||
path: plan-dist-manifest.json
|
||||
|
||||
custom-build-binaries:
|
||||
custom-build-release-binaries:
|
||||
needs:
|
||||
- plan
|
||||
if: ${{ needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload' || inputs.tag == 'dry-run' }}
|
||||
uses: ./.github/workflows/build-binaries.yml
|
||||
uses: ./.github/workflows/build-release-binaries.yml
|
||||
with:
|
||||
plan: ${{ needs.plan.outputs.val }}
|
||||
secrets: inherit
|
||||
@@ -117,7 +117,7 @@ jobs:
|
||||
build-global-artifacts:
|
||||
needs:
|
||||
- plan
|
||||
- custom-build-binaries
|
||||
- custom-build-release-binaries
|
||||
- custom-build-docker
|
||||
runs-on: "ubuntu-latest"
|
||||
env:
|
||||
@@ -164,11 +164,11 @@ jobs:
|
||||
host:
|
||||
needs:
|
||||
- plan
|
||||
- custom-build-binaries
|
||||
- custom-build-release-binaries
|
||||
- custom-build-docker
|
||||
- build-global-artifacts
|
||||
# Only run if we're "publishing", and only if plan, local and global didn't fail (skipped is fine)
|
||||
if: ${{ always() && needs.plan.result == 'success' && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.custom-build-binaries.result == 'skipped' || needs.custom-build-binaries.result == 'success') && (needs.custom-build-docker.result == 'skipped' || needs.custom-build-docker.result == 'success') }}
|
||||
if: ${{ always() && needs.plan.result == 'success' && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.custom-build-release-binaries.result == 'skipped' || needs.custom-build-release-binaries.result == 'success') && (needs.custom-build-docker.result == 'skipped' || needs.custom-build-docker.result == 'success') }}
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
runs-on: "ubuntu-latest"
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
name: Run zizmor
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["master"]
|
||||
pull_request:
|
||||
branches: ["**"]
|
||||
workflow_call:
|
||||
|
||||
permissions: {}
|
||||
|
||||
@@ -13,6 +10,7 @@ jobs:
|
||||
name: Run zizmor
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
security-events: write
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ targets = [
|
||||
"i686-pc-windows-msvc",
|
||||
]
|
||||
# Local artifacts jobs to run in CI
|
||||
local-artifacts-jobs = ["./build-binaries", "./build-docker"]
|
||||
local-artifacts-jobs = ["./build-release-binaries", "./build-docker"]
|
||||
# Publish jobs to run in CI
|
||||
publish-jobs = ["./publish-crates", "./publish-pypi", "./publish-npm"]
|
||||
# Post-announce jobs to run in CI
|
||||
|
||||
Reference in New Issue
Block a user