Skip to content

Commit

Permalink
Convert cargo.sh to Rust
Browse files Browse the repository at this point in the history
  • Loading branch information
djkoloski committed Feb 16, 2024
1 parent b6f23c6 commit 4d1c22c
Show file tree
Hide file tree
Showing 7 changed files with 274 additions and 130 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ jobs:
#
# ...to:
#
# toolchain: $ {{ ./cargo.sh --version matrix.toolchain }} # hypothetical syntax
ZC_TOOLCHAIN="$(./cargo.sh --version ${{ matrix.toolchain }})"
# toolchain: $ {{ cargo run -p cargos --version matrix.toolchain }} # hypothetical syntax
ZC_TOOLCHAIN="$(cargo run -p cargos --version ${{ matrix.toolchain }})"
echo "Found that the '${{ matrix.toolchain }}' toolchain is $ZC_TOOLCHAIN" | tee -a $GITHUB_STEP_SUMMARY
echo "ZC_TOOLCHAIN=$ZC_TOOLCHAIN" >> $GITHUB_ENV
Expand Down Expand Up @@ -132,10 +132,10 @@ jobs:
key: "${{ matrix.target }}"

- name: Check
run: ./cargo.sh +${{ matrix.toolchain }} check --package ${{ matrix.crate }} --target ${{ matrix.target }} ${{ matrix.features }} --verbose
run: cargo run -p cargos +${{ matrix.toolchain }} check --package ${{ matrix.crate }} --target ${{ matrix.target }} ${{ matrix.features }} --verbose

- name: Build
run: ./cargo.sh +${{ matrix.toolchain }} build --package ${{ matrix.crate }} --target ${{ matrix.target }} ${{ matrix.features }} --verbose
run: cargo run -p cargos +${{ matrix.toolchain }} build --package ${{ matrix.crate }} --target ${{ matrix.target }} ${{ matrix.features }} --verbose

# When building tests for the i686 target, we need certain libraries which
# are not installed by default; `gcc-multilib` includes these libraries.
Expand All @@ -154,7 +154,7 @@ jobs:

- name: Run tests
run: |
./cargo.sh +${{ matrix.toolchain }} test \
cargo run -p cargos +${{ matrix.toolchain }} test \
--package ${{ matrix.crate }} \
--target ${{ matrix.target }} \
${{ matrix.features }} \
Expand All @@ -180,7 +180,7 @@ jobs:
#
# TODO(#560), TODO(#187): Once we migrate to the ui-test crate, we
# likely won't have to special-case the UI tests like this.
RUSTFLAGS="$RUSTFLAGS -Wwarnings" ./cargo.sh +${{ matrix.toolchain }} test \
RUSTFLAGS="$RUSTFLAGS -Wwarnings" cargo run -p cargos +${{ matrix.toolchain }} test \
--package ${{ matrix.crate }} \
--target ${{ matrix.target }} \
${{ matrix.features }} \
Expand Down Expand Up @@ -208,7 +208,7 @@ jobs:
# Run under both the stacked borrows model (default) and under the tree
# borrows model to ensure we're compliant with both.
for EXTRA_FLAGS in "" "-Zmiri-tree-borrows"; do
MIRIFLAGS="$MIRIFLAGS $EXTRA_FLAGS" ./cargo.sh +${{ matrix.toolchain }} \
MIRIFLAGS="$MIRIFLAGS $EXTRA_FLAGS" cargo run -p cargos +${{ matrix.toolchain }} \
miri test \
--package ${{ matrix.crate }} \
--target ${{ matrix.target }} \
Expand All @@ -222,7 +222,7 @@ jobs:
if: matrix.toolchain == 'nightly' && matrix.target != 'riscv64gc-unknown-linux-gnu' && matrix.target != 'wasm32-wasi'

- name: Clippy check
run: ./cargo.sh +${{ matrix.toolchain }} clippy --package ${{ matrix.crate }} --target ${{ matrix.target }} ${{ matrix.features }} --tests --verbose
run: cargo run -p cargos +${{ matrix.toolchain }} clippy --package ${{ matrix.crate }} --target ${{ matrix.target }} ${{ matrix.features }} --tests --verbose
# Clippy improves the accuracy of lints over time, and fixes bugs. Only
# running Clippy on nightly allows us to avoid having to write code which
# is compatible with older versions of Clippy, which sometimes requires
Expand All @@ -241,7 +241,7 @@ jobs:
METADATA_DOCS_RS_RUSTDOC_ARGS="$(cargo metadata --format-version 1 | \
jq -r ".packages[] | select(.name == \"zerocopy\").metadata.docs.rs.\"rustdoc-args\".[]" | tr '\n' ' ')"
export RUSTDOCFLAGS="${{ matrix.toolchain == 'nightly' && '-Z unstable-options --document-hidden-items' || '' }} $RUSTDOCFLAGS $METADATA_DOCS_RS_RUSTDOC_ARGS"
./cargo.sh +${{ matrix.toolchain }} doc --document-private-items --package ${{ matrix.crate }} ${{ matrix.features }}
cargo run -p cargos +${{ matrix.toolchain }} doc --document-private-items --package ${{ matrix.crate }} ${{ matrix.features }}
# Check semver compatibility with the most recently-published version on
# crates.io. We do this in the matrix rather than in its own job so that it
Expand Down
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@
[workspace]
members = [
"zerocopy-derive",
"tools/cargos",
"tools/generate-readme",
]
default-members = [
".",
"zerocopy-derive",
]

[package]
edition = "2018"
Expand Down
2 changes: 1 addition & 1 deletion INTERNAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Updating the versions pinned in CI may cause the UI tests to break. In order to
fix UI tests after a version update, run:

```
$ TRYBUILD=overwrite ./cargo.sh +all test
$ TRYBUILD=overwrite cargo run -p cargos +all test
```

## Crate versions
Expand Down
Binary file modified README.md
Binary file not shown.
120 changes: 0 additions & 120 deletions cargo.sh

This file was deleted.

17 changes: 17 additions & 0 deletions tools/cargos/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2024 The Fuchsia Authors
#
# Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
# <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
# license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
# This file may not be copied, modified, or distributed except according to
# those terms.

[package]
edition = "2021"
name = "cargos"
version = "0.0.0"
license = "BSD-2-Clause OR Apache-2.0 OR MIT"
publish = false

[dependencies]
serde_json = "1"
Loading

0 comments on commit 4d1c22c

Please sign in to comment.