[codex-rs] CI performance for rust (#639)
* Refactors the rust-ci into a matrix build * Adds directory caching for the build artifacts * Adds workflow dispatch for manual testing
This commit is contained in:
102
.github/workflows/rust-ci.yml
vendored
102
.github/workflows/rust-ci.yml
vendored
@@ -9,79 +9,77 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
# For CI, we build in debug (`--profile dev`) rather than release mode so we
|
# For CI, we build in debug (`--profile dev`) rather than release mode so we
|
||||||
# get signal faster.
|
# get signal faster.
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
macos:
|
# CI that don't need specific targets
|
||||||
runs-on: macos-14
|
general:
|
||||||
timeout-minutes: 30
|
name: Format / etc
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
working-directory: codex-rs
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: dtolnay/rust-toolchain@stable
|
|
||||||
with:
|
|
||||||
targets: aarch64-apple-darwin,x86_64-apple-darwin
|
|
||||||
|
|
||||||
- name: Initialize failure flag
|
|
||||||
run: echo "FAILED=" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: cargo fmt
|
|
||||||
run: cargo fmt -- --config imports_granularity=Item --check || echo "FAILED=${FAILED:+$FAILED, }cargo fmt" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: cargo test
|
|
||||||
run: RUST_BACKTRACE=full cargo test || echo "FAILED=${FAILED:+$FAILED, }cargo test" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: cargo clippy
|
|
||||||
run: cargo clippy --all-features -- -D warnings || echo "FAILED=${FAILED:+$FAILED, }cargo clippy" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: arm64 build
|
|
||||||
run: cargo build --target aarch64-apple-darwin || echo "FAILED=${FAILED:+$FAILED, }arm64 build" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: x86_64 build
|
|
||||||
run: cargo build --target x86_64-apple-darwin || echo "FAILED=${FAILED:+$FAILED, }x86_64 build" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Fail if any step failed
|
|
||||||
run: |
|
|
||||||
if [ -n "$FAILED" ]; then
|
|
||||||
echo -e "See logs above, as the following steps failed:\n$FAILED"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
env:
|
|
||||||
FAILED: ${{ env.FAILED }}
|
|
||||||
|
|
||||||
linux-musl-x86_64:
|
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: codex-rs
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
|
- name: cargo fmt
|
||||||
|
run: cargo fmt -- --config imports_granularity=Item --check
|
||||||
|
|
||||||
|
# CI to validate on different os/targets
|
||||||
|
lint_build_test:
|
||||||
|
name: ${{ matrix.runner }} - ${{ matrix.target }}
|
||||||
|
runs-on: ${{ matrix.runner }}
|
||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
working-directory: codex-rs
|
working-directory: codex-rs
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- runner: macos-14
|
||||||
|
target: aarch64-apple-darwin
|
||||||
|
- runner: macos-14
|
||||||
|
target: x86_64-apple-darwin
|
||||||
|
- runner: ubuntu-24.04
|
||||||
|
target: x86_64-unknown-linux-musl
|
||||||
|
- runner: ubuntu-24.04
|
||||||
|
target: x86_64-unknown-linux-gnu
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: dtolnay/rust-toolchain@stable
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
with:
|
with:
|
||||||
targets: x86_64-unknown-linux-musl
|
targets: ${{ matrix.target }}
|
||||||
- name: Install musl build tools
|
|
||||||
|
- uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cargo/bin/
|
||||||
|
~/.cargo/registry/index/
|
||||||
|
~/.cargo/registry/cache/
|
||||||
|
~/.cargo/git/db/
|
||||||
|
${{ github.workspace }}/codex-rs/target/
|
||||||
|
key: cargo-${{ matrix.runner }}-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
|
||||||
|
|
||||||
|
- if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }}
|
||||||
|
name: Install musl build tools
|
||||||
run: |
|
run: |
|
||||||
sudo apt update
|
|
||||||
sudo apt install -y musl-tools pkg-config
|
sudo apt install -y musl-tools pkg-config
|
||||||
|
|
||||||
- name: Initialize failure flag
|
- name: Initialize failure flag
|
||||||
run: echo "FAILED=" >> $GITHUB_ENV
|
run: echo "FAILED=" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: cargo fmt
|
- name: cargo clippy
|
||||||
run: cargo fmt -- --config imports_granularity=Item --check || echo "FAILED=${FAILED:+$FAILED, }cargo fmt" >> $GITHUB_ENV
|
run: cargo clippy --target ${{ matrix.target }} --all-features -- -D warnings || echo "FAILED=${FAILED:+$FAILED, }cargo clippy" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: cargo test
|
- name: cargo test
|
||||||
run: RUST_BACKTRACE=full cargo test || echo "FAILED=${FAILED:+$FAILED, }cargo test" >> $GITHUB_ENV
|
run: cargo test --target ${{ matrix.target }} || echo "FAILED=${FAILED:+$FAILED, }cargo test" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: cargo clippy
|
|
||||||
run: cargo clippy --all-features -- -D warnings || echo "FAILED=${FAILED:+$FAILED, }cargo clippy" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: x86_64 musl build
|
|
||||||
run: cargo build --target x86_64-unknown-linux-musl || echo "FAILED=${FAILED:+$FAILED, }x86_64 musl build" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Fail if any step failed
|
- name: Fail if any step failed
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
Reference in New Issue
Block a user