ci/Speed up typos checks (#907)

This commit is contained in:
Luni-4 2023-11-02 19:30:07 +01:00 committed by GitHub
parent 35df31f700
commit 8c80c9b94a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 36 additions and 15 deletions

View File

@ -116,5 +116,19 @@ jobs:
- name: checkout
uses: actions/checkout@v4
- name: caching
uses: Swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-typos-${{ hashFiles('**/Cargo.toml') }}
prefix-key: "v5-rust"
- name: Install typos
env:
TYPOS_LINK: https://github.com/crate-ci/typos/releases/download
TYPOS_VERSION: v1.16.20
run: |
curl -L "$TYPOS_LINK/$TYPOS_VERSION/typos-$TYPOS_VERSION-x86_64-unknown-linux-musl.tar.gz" |
tar xz -C $HOME/.cargo/bin
- name: run spelling checks using typos
run: cargo xtask run-checks typos
run: CI_RUN=1 cargo xtask run-checks typos

View File

@ -37,7 +37,7 @@ impl Graph {
/// This is a owned method, so the current graph will be freed. However, the steps can
/// be shared with other graphs, therefore they are going to be cleared.
///
/// This is usefull, since the graph is supposed to be consumed only once for backprop, and
/// This is useful, since the graph is supposed to be consumed only once for backprop, and
/// keeping all the tensors alive for multiple backward call is a heavy waste of resources.
pub fn steps(self) -> NodeSteps {
let mut map_drain = HashMap::new();

View File

@ -4,7 +4,7 @@ use crate::graph::NodeRef;
///
/// # Notes
///
/// This is usefull since you don't have to keep N cloned references alive event if just 1 node
/// This is useful since you don't have to keep N cloned references alive event if just 1 node
/// will be updated.
///
/// If the object is a tensor and if one reference exists, it can be updated inplace.

View File

@ -1,5 +1,5 @@
mod base;
pub use base::*;
// Not needed for now, usefull for different tensor memory layout
// Not needed for now, useful for different tensor memory layout
// pub mod conversion;

View File

@ -67,7 +67,7 @@ pub trait Adaptor<T> {
/// Declare a metric to be numeric.
///
/// This is usefull to plot the values of a metric during training.
/// This is useful to plot the values of a metric during training.
pub trait Numeric {
/// Returns the numeric value of the metric.
fn value(&self) -> f64;

View File

@ -1,6 +1,6 @@
use crate::metric::{format_float, MetricEntry, Numeric};
/// Usefull utility to implement numeric metrics.
/// Useful utility to implement numeric metrics.
///
/// # Notes
///

View File

@ -3,7 +3,7 @@
#
# Run `run-checks` using this command:
#
# ./scripts/run-checks environment
# ./run-checks.ps1 environment
#
# where `environment` can assume **ONLY** the following values:
#

View File

@ -8,7 +8,7 @@ set -e
#
# Run `run-checks` using this command:
#
# ./scripts/run-checks environment
# ./run-checks.sh environment
#
# where `environment` can assume **ONLY** the following values:
#

View File

@ -1,12 +1,8 @@
//! This script publishes a crate on `crates.io`.
//!
//! To build this script, run the following command:
//!
//! rustc scripts/publish.rs --crate-type bin --out-dir scripts
//!
//! To run the script:
//!
//! ./scripts/publish crate_name
//! cargo xtask publish INPUT_CRATE
use std::env;
use std::process::{Command, Stdio};

View File

@ -3,6 +3,7 @@
//! It is used to check that the code compiles and passes all tests.
//!
//! It is also used to check that the code is formatted correctly and passes clippy.
use std::env;
use std::process::{Child, Command, Stdio};
use std::str;
@ -289,8 +290,18 @@ fn std_checks() {
}
fn check_typos() {
// Install typos-cli
cargo_install(["typos-cli", "--version", "1.16.5"].into());
// This path defines where typos-cl is installed on different
// operating systems.
let typos_cli_path = std::env::var("CARGO_HOME")
.map(|v| std::path::Path::new(&v).join("bin/typos-cli"))
.unwrap();
// Do not run cargo install on CI to speed up the computation.
// Check whether the file has been installed on
if std::env::var("CI_RUN").is_err() && !typos_cli_path.exists() {
// Install typos-cli
cargo_install(["typos-cli", "--version", "1.16.5"].into());
}
println!("Running typos check \n\n");