aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorChih-Hung Hsieh <chh@google.com>2020-10-26 16:54:29 -0700
committerChih-Hung Hsieh <chh@google.com>2020-10-26 16:57:40 -0700
commit127364b149c24623fd15786790a98af3b5355389 (patch)
tree55ba197683b0a0093a2767fcb1f576490157f8a1 /scripts
parentc112e35face1579eba180108bda3da10b61d9926 (diff)
downloadpin-project-127364b149c24623fd15786790a98af3b5355389.tar.gz
Upgrade rust/crates/pin-project to 1.0.1
* Add missing patches, needed by external_updater Test: make Test: tools/external_updater/updater.sh update --refresh --keep_date rust/crates/pin-project Change-Id: I3738561830ce97903036460713eb3b74700b889e
Diffstat (limited to 'scripts')
-rw-r--r--scripts/README.md3
-rwxr-xr-xscripts/check-minimal-versions.sh44
-rwxr-xr-xscripts/ci.sh37
-rwxr-xr-xscripts/expandtest.sh35
4 files changed, 119 insertions, 0 deletions
diff --git a/scripts/README.md b/scripts/README.md
new file mode 100644
index 0000000..671a9b1
--- /dev/null
+++ b/scripts/README.md
@@ -0,0 +1,3 @@
+This directory contains scripts used by the developers of this project.
+
+Some scripts in this directory are also used in CI, but scripts intended to be used only in CI and scripts not intended to be used directly by the developers are basically in the `ci` directory.
diff --git a/scripts/check-minimal-versions.sh b/scripts/check-minimal-versions.sh
new file mode 100755
index 0000000..6c7fa7b
--- /dev/null
+++ b/scripts/check-minimal-versions.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+# Check all public crates with minimal version dependencies.
+#
+# Usage:
+# bash scripts/check-minimal-versions.sh
+#
+# Note:
+# - This script modifies Cargo.toml and Cargo.lock while running
+# - This script exits with 1 if there are any unstaged changes
+# - This script requires nightly Rust and cargo-hack
+#
+# Refs: https://github.com/rust-lang/cargo/issues/5657
+
+set -euo pipefail
+
+cd "$(cd "$(dirname "${0}")" && pwd)"/..
+
+if [[ "${1:-none}" == "+"* ]]; then
+ toolchain="${1}"
+elif [[ "${CI:-false}" != "true" ]]; then
+ cargo +nightly -V >/dev/null || exit 1
+ toolchain="+nightly"
+fi
+
+if [[ "${toolchain:-+nightly}" != "+nightly"* ]] || ! cargo hack -V &>/dev/null; then
+ echo "error: check-minimal-versions.sh requires nightly Rust and cargo-hack"
+ exit 1
+fi
+
+# This script modifies Cargo.toml and Cargo.lock, so make sure there are no
+# unstaged changes.
+git diff --exit-code
+# Restore original Cargo.toml and Cargo.lock on exit.
+trap 'git checkout .' EXIT
+
+# Remove dev-dependencies from Cargo.toml to prevent the next `cargo update`
+# from determining minimal versions based on dev-dependencies.
+cargo hack --remove-dev-deps --workspace
+
+# Update Cargo.lock to minimal version dependencies.
+cargo ${toolchain:-} update -Zminimal-versions
+# Run check for all public members of the workspace.
+cargo ${toolchain:-} hack check --workspace --all-features --ignore-private -Zfeatures=all
diff --git a/scripts/ci.sh b/scripts/ci.sh
new file mode 100755
index 0000000..ec08568
--- /dev/null
+++ b/scripts/ci.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+# A script to run a simplified version of the checks done by CI.
+#
+# Usage:
+# bash scripts/ci.sh
+#
+# Note: This script requires nightly Rust, rustfmt, clippy, and cargo-expand
+
+set -euo pipefail
+
+if [[ "${1:-none}" == "+"* ]]; then
+ toolchain="${1}"
+else
+ cargo +nightly -V >/dev/null || exit 1
+ toolchain="+nightly"
+fi
+
+if [[ "${toolchain:-+nightly}" != "+nightly"* ]] || ! rustfmt -V &>/dev/null || ! cargo clippy -V &>/dev/null || ! cargo expand -V &>/dev/null; then
+ echo "error: ci.sh requires nightly Rust, rustfmt, clippy, and cargo-expand"
+ exit 1
+fi
+
+echo "Running 'cargo ${toolchain} fmt --all'"
+cargo "${toolchain}" fmt --all
+
+echo "Running 'cargo ${toolchain} clippy --all --all-targets'"
+cargo "${toolchain}" clippy --all --all-features --all-targets -Zunstable-options
+
+echo "Running 'cargo ${toolchain} test --all --exclude expandtest'"
+TRYBUILD=overwrite cargo "${toolchain}" test --all --all-features --exclude expandtest
+
+echo "Running 'bash scripts/expandtest.sh ${toolchain}'"
+"$(cd "$(dirname "${0}")" && pwd)"/expandtest.sh "${toolchain}"
+
+echo "Running 'cargo ${toolchain} doc --no-deps --all'"
+cargo "${toolchain}" doc --no-deps --all --all-features
diff --git a/scripts/expandtest.sh b/scripts/expandtest.sh
new file mode 100755
index 0000000..844ace6
--- /dev/null
+++ b/scripts/expandtest.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+# A script to run expandtest.
+#
+# Usage:
+# bash scripts/expandtest.sh
+#
+# Note: This script requires nightly Rust, rustfmt, and cargo-expand
+
+set -euo pipefail
+
+script_dir="$(cd "$(dirname "${0}")" && pwd)"
+
+if [[ "${1:-none}" == "+"* ]]; then
+ toolchain="${1}"
+elif [[ "${CI:-false}" != "true" ]]; then
+ cargo +nightly -V >/dev/null || exit 1
+ toolchain="+nightly"
+fi
+
+if [[ "${toolchain:-+nightly}" != "+nightly"* ]] || ! rustfmt -V &>/dev/null || ! cargo expand -V &>/dev/null; then
+ echo "error: expandtest.sh requires nightly Rust, rustfmt, and cargo-expand"
+ exit 1
+fi
+
+if [[ "${CI:-false}" != "true" ]]; then
+ # First, check if the compile fails for another reason.
+ cargo ${toolchain} check --tests --manifest-path "${script_dir}"/../tests/expand/Cargo.toml
+
+ # Next, remove the `*.expanded.rs` files to allow updating those files.
+ # Refs: https://docs.rs/macrotest/1/macrotest/#updating-expandedrs
+ rm -rf "${script_dir}"/../tests/expand/tests/expand/*.expanded.rs
+fi
+
+cargo ${toolchain:-} test --manifest-path "${script_dir}"/../tests/expand/Cargo.toml