Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: only run linux in PR by default, and run the rest on labels #2184

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 63 additions & 63 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,45 @@
on:
push:
tags:
- "v*.*.*"
- v*.*.*
branches:
- main
paths-ignore:
- "docs/**"
- "mkdocs.yml"
- docs/**
- mkdocs.yml
- "*.md"
workflow_dispatch:
workflow_dispatch: null
pull_request:
paths-ignore:
- "docs/**"
- "mkdocs.yml"
- docs/**
- mkdocs.yml
- "*.md"

name: Rust

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
RUST_LOG: info
RUST_BACKTRACE: 1
RUSTFLAGS: "-D warnings"
RUSTFLAGS: -D warnings
CARGO_TERM_COLOR: always
CICD_INTERMEDIATES_DIR: "_cicd-intermediates"
CICD_INTERMEDIATES_DIR: _cicd-intermediates
XDG_CACHE_HOME: ${{ github.workspace }}/.cache

jobs:
check-rustdoc-links:
name: Check intra-doc links
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: Swatinem/rust-cache@v2
with:
save-if: false
# - name: Run sccache-cache
# uses: mozilla-actions/sccache-action@v0.0.5

- uses: actions-rust-lang/setup-rust-toolchain@v1
- run: |
for package in $(cargo metadata --no-deps --format-version=1 | jq -r '.packages[] | .name'); do
- run: >
for package in $(cargo metadata --no-deps --format-version=1 | jq -r
'.packages[] | .name'); do
cargo rustdoc -p "$package" --all-features -- -D warnings -W unreachable-pub
done

format:
name: Cargo Format
runs-on: ubuntu-latest
Expand All @@ -60,7 +52,6 @@ jobs:
components: rustfmt
- name: Run rustfmt
uses: actions-rust-lang/rustfmt@v1

lint:
name: Cargo Lint
runs-on: ubuntu-latest
Expand All @@ -76,26 +67,27 @@ jobs:
save-if: false
- name: Run clippy
run: cargo clippy --all-targets --workspace

crate_metadata:
name: Extract crate metadata
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Extract crate information
id: crate_metadata
run: |
cargo metadata --no-deps --format-version 1 | jq -r '"name=" + (.packages[] | select(.name == "pixi") | .name)' | tee -a $GITHUB_OUTPUT
run: >
cargo metadata --no-deps --format-version 1 | jq -r '"name=" + (.packages[]
| select(.name == "pixi") | .name)' | tee -a $GITHUB_OUTPUT

cargo metadata --no-deps --format-version 1 | jq -r '"version=" + (.packages[] | select(.name == "pixi") | .version)' | tee -a $GITHUB_OUTPUT

cargo metadata --no-deps --format-version 1 | jq -r '"maintainer=" + (.packages[] | select(.name == "pixi") | .authors[0])' | tee -a $GITHUB_OUTPUT

cargo metadata --no-deps --format-version 1 | jq -r '"homepage=" + (.packages[] | select(.name == "pixi") | .homepage)' | tee -a $GITHUB_OUTPUT
outputs:
name: ${{ steps.crate_metadata.outputs.name }}
version: ${{ steps.crate_metadata.outputs.version }}
maintainer: ${{ steps.crate_metadata.outputs.maintainer }}
homepage: ${{ steps.crate_metadata.outputs.homepage }}

# Checks for dependencies that are not used in the codebase
cargo-machete:
name: Cargo Machete
runs-on: ubuntu-latest
Expand All @@ -104,27 +96,32 @@ jobs:
uses: actions/checkout@v3
- name: Machete
uses: bnjbvr/cargo-machete@main

cargo-test:
name: Cargo Test | ${{ matrix.name }}
runs-on: ${{ matrix.os }}
timeout-minutes: 60
if: ${{ matrix.run_if }}
strategy:
fail-fast: false
matrix:
include:
- {
name: "Linux",
target: x86_64-unknown-linux-musl,
os: "${{ contains(github.event.pull_request.labels.*.name, 'ci:free') && 'ubuntu-latest' || '8core_ubuntu_latest_runner' }}",
}
- { name: "macOS", target: x86_64-apple-darwin, os: macos-13 }
- { name: "macOS-arm", target: aarch64-apple-darwin, os: macos-14 }
- {
name: "Windows",
target: x86_64-pc-windows-msvc,
os: "${{ contains(github.event.pull_request.labels.*.name, 'ci:free') && 'windows-latest' || '16core_windows_latest_runner' }}",
}
- name: Linux
target: x86_64-unknown-linux-musl
os: ${{ contains(github.event.pull_request.labels.*.name, 'ci:free') && 'ubuntu-latest' || '8core_ubuntu_latest_runner' }}
run_if: true
- name: macOS
target: x86_64-apple-darwin
os: macos-13
run_if: ${{ (github.event_name != 'pull_request') || contains(github.event.pull_request.labels.*.name, 'ci:macos') || contains(github.event.pull_request.labels.*.name, 'ci:all') }}
- name: "macOS-arm"
target: aarch64-apple-darwin
os: macos-14
if: ${{ (github.event_name != 'pull_request') || contains(github.event.pull_request.labels.*.name, 'ci:macos-arm') || contains(github.event.pull_request.labels.*.name, 'ci:all') }}
- name: "Windows"
target: x86_64-pc-windows-msvc
os: "${{ contains(github.event.pull_request.labels.*.name, 'ci:free') && 'windows-latest' || '16core_windows_latest_runner' }}"
run_if: ${{ (github.event_name != 'pull_request') || contains(github.event.pull_request.labels.*.name, 'ci:win') || contains(github.event.pull_request.labels.*.name, 'ci:all') }}


steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -161,35 +158,38 @@ jobs:
build:
name: Build Binary | ${{ matrix.name }}
runs-on: ${{ matrix.os }}
needs: [crate_metadata]
needs: [ crate_metadata ]
# Run full set on main branch and on tags, otherwise run linux and all labels defined in the PR
if: ${{ matrix.run_if }}
strategy:
fail-fast: false
matrix:
include:
- {
name: "Linux-x86_64",
target: x86_64-unknown-linux-musl,
os: "${{ contains(github.event.pull_request.labels.*.name, 'ci:free') && 'ubuntu-latest' || '8core_ubuntu_latest_runner' }}"
}
- {
name: "Linux-aarch64",
target: aarch64-unknown-linux-musl,
os: ubuntu-latest,
}

- { name: "macOS-x86", target: x86_64-apple-darwin, os: macos-13 }
- { name: "macOS-arm", target: aarch64-apple-darwin, os: macos-14 } # macOS-14 is the ARM chipset

- {
name: "Windows",
target: x86_64-pc-windows-msvc,
os: "${{ contains(github.event.pull_request.labels.*.name, 'ci:free') && 'windows-latest' || '16core_windows_latest_runner' }}"
}
- {
name: "Windows-arm",
target: aarch64-pc-windows-msvc,
os: windows-latest,
}
- name: Linux
target: x86_64-unknown-linux-musl
os: ${{ contains(github.event.pull_request.labels.*.name, 'ci:free') && 'ubuntu-latest' || '8core_ubuntu_latest_runner' }}
run_if: true
- name: "Linux-aarch64"
target: aarch64-unknown-linux-musl
os: ubuntu-latest
run_if: ${{ (github.event_name != 'pull_request') || contains(github.event.pull_request.labels.*.name, 'ci:all') }}
- name: macOS
target: x86_64-apple-darwin
os: macos-13
run_if: ${{ (github.event_name != 'pull_request') || contains(github.event.pull_request.labels.*.name, 'ci:macos') || contains(github.event.pull_request.labels.*.name, 'ci:all') }}
- name: "macOS-arm"
target: aarch64-apple-darwin
os: macos-14
run_if: ${{ (github.event_name != 'pull_request') || contains(github.event.pull_request.labels.*.name, 'ci:macos-arm') || contains(github.event.pull_request.labels.*.name, 'ci:all') }}
- name: "Windows"
target: x86_64-pc-windows-msvc
os: "${{ contains(github.event.pull_request.labels.*.name, 'ci:free') && 'windows-latest' || '16core_windows_latest_runner' }}"
run_if: ${{ (github.event_name != 'pull_request') || contains(github.event.pull_request.labels.*.name, 'ci:win') || contains(github.event.pull_request.labels.*.name, 'ci:all') }}
- name: "Windows-arm"
target: aarch64-pc-windows-msvc
os: windows-latest
run_if: ${{ (github.event_name != 'pull_request') || contains(github.event.pull_request.labels.*.name, 'ci:win-arm') || contains(github.event.pull_request.labels.*.name, 'ci:all') }}

env:
#
# These are some environment variables that configure the build so that the binary size is reduced.
Expand Down