Skip to content
Merged
Show file tree
Hide file tree
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
100 changes: 25 additions & 75 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ on:
push:
branches:
- master
- release/**

- "release/**"
pull_request:

env:
Expand All @@ -16,99 +15,50 @@ jobs:
name: Lints
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install rust stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
components: rustfmt, clippy
override: true

- name: Cache rust cargo artifacts
uses: swatinem/rust-cache@v1

- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

- name: Run clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-features --workspace --tests --examples
- uses: actions/checkout@v3

- run: rustup toolchain install stable --profile minimal --component rustfmt --component clippy --no-self-update

- uses: Swatinem/rust-cache@v2

- run: cargo fmt --all -- --check

- run: cargo clippy --all-features --workspace --tests --examples -- -D clippy::all

unit-test:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install rust stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- run: rustup toolchain install stable --profile minimal --no-self-update

- name: Cache rust cargo artifacts
uses: swatinem/rust-cache@v1
- uses: Swatinem/rust-cache@v2

- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --workspace
- run: cargo test --workspace

unit-test-all-features:
name: "Unit Tests - all features"
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install rust stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- run: rustup toolchain install stable --profile minimal --no-self-update

- name: Cache rust cargo artifacts
uses: swatinem/rust-cache@v1
- uses: Swatinem/rust-cache@v2

- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --workspace --all-features
- run: cargo test --workspace --all-features --all-targets

doc-comments:
name: Rust doc comments
runs-on: ubuntu-latest
env:
RUSTDOCFLAGS: -Dwarnings
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install rust stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
components: rust-docs
override: true

- name: Cache rust cargo artifacts
uses: swatinem/rust-cache@v1

- uses: actions-rs/cargo@v1
with:
command: doc
args: --workspace --all-features --no-deps
- uses: actions/checkout@v3

- run: rustup toolchain install stable --profile minimal --component rust-docs --no-self-update

- uses: Swatinem/rust-cache@v2

- run: cargo doc --workspace --all-features --document-private-items --no-deps
37 changes: 0 additions & 37 deletions .github/workflows/periodic.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
name: "Release a new version"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
token: ${{ secrets.GH_RELEASE_PAT }}
fetch-depth: 0
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/weekly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Weekly CI

on:
schedule:
- cron: "0 0 * * 1" # every monday at 00:00
workflow_dispatch:

env:
RUSTFLAGS: -Dwarnings

jobs:
weekly-ci:
strategy:
fail-fast: false
matrix:
rust: [nightly, beta]

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- run: |
rustup toolchain install ${{ matrix.rust }} --profile minimal --component clippy --no-self-update
rustup default ${{ matrix.rust }}

- run: cargo clippy --all-features --workspace --tests --examples -- -D clippy::all

- run: cargo test --workspace --all-features
2 changes: 1 addition & 1 deletion examples/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ fn main() {
};

let token = sm.lookup_token(line, column).unwrap(); // line-number and column
println!("token: {}", token);
println!("token: {token}");
}
2 changes: 1 addition & 1 deletion examples/rewrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn test(sm: &SourceMap) {
continue;
}
if Some(contents.as_str()) != sm.get_source_contents(src_id as u32) {
println!(" !!! {}", source);
println!(" !!! {source}");
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions examples/split_ram_bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Both indexed and file RAM bundles are supported.
fn main() -> Result<(), Box<dyn std::error::Error>> {
let args: Vec<_> = env::args().collect();
if args.len() < 4 {
println!("{}", USAGE);
println!("{USAGE}");
std::process::exit(1);
}

Expand Down Expand Up @@ -47,11 +47,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let ram_bundle_iter = split_ram_bundle(&ram_bundle, &ism).unwrap();
for result in ram_bundle_iter {
let (name, sv, sm) = result.unwrap();
println!("Writing down source: {}", name);
println!("Writing down source: {name}");
fs::write(output_directory.join(name.clone()), sv.source())?;

let sourcemap_name = format!("{}.map", name);
println!("Writing down sourcemap: {}", sourcemap_name);
let sourcemap_name = format!("{name}.map");
println!("Writing down sourcemap: {sourcemap_name}");
let out_sm = File::create(output_directory.join(sourcemap_name))?;
sm.to_writer(out_sm)?;
}
Expand Down
2 changes: 1 addition & 1 deletion src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ pub fn decode_regular(rsm: RawSourceMap) -> Result<SourceMap> {
if is_valid {
x
} else {
format!("{}/{}", source_root, x)
format!("{source_root}/{x}")
}
})
.collect()
Expand Down
16 changes: 8 additions & 8 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,21 @@ impl error::Error for Error {
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
Error::Io(ref msg) => write!(f, "{}", msg),
Error::Utf8(ref msg) => write!(f, "{}", msg),
Error::BadJson(ref err) => write!(f, "bad json: {}", err),
Error::Io(ref msg) => write!(f, "{msg}"),
Error::Utf8(ref msg) => write!(f, "{msg}"),
Error::BadJson(ref err) => write!(f, "bad json: {err}"),
#[cfg(feature = "ram_bundle")]
Error::Scroll(ref err) => write!(f, "parse error: {}", err),
Error::Scroll(ref err) => write!(f, "parse error: {err}"),
Error::VlqLeftover => write!(f, "leftover cur/shift in vlq decode"),
Error::VlqNoValues => write!(f, "vlq decode did not produce any values"),
Error::VlqOverflow => write!(f, "vlq decode caused an overflow"),
Error::BadSegmentSize(size) => write!(f, "got {} segments, expected 4 or 5", size),
Error::BadSourceReference(id) => write!(f, "bad reference to source #{}", id),
Error::BadNameReference(id) => write!(f, "bad reference to name #{}", id),
Error::BadSegmentSize(size) => write!(f, "got {size} segments, expected 4 or 5"),
Error::BadSourceReference(id) => write!(f, "bad reference to source #{id}"),
Error::BadNameReference(id) => write!(f, "bad reference to name #{id}"),
Error::IncompatibleSourceMap => write!(f, "encountered incompatible sourcemap format"),
Error::InvalidDataUrl => write!(f, "the provided data URL is invalid"),
Error::CannotFlatten(ref msg) => {
write!(f, "cannot flatten the indexed sourcemap: {}", msg)
write!(f, "cannot flatten the indexed sourcemap: {msg}")
}
Error::InvalidRamBundleMagic => write!(f, "invalid magic number for ram bundle"),
Error::InvalidRamBundleIndex => write!(f, "invalid module index in ram bundle"),
Expand Down
4 changes: 2 additions & 2 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ impl<'a> Iterator for IndexIter<'a> {

impl<'a> fmt::Debug for Token<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "<Token {:#}>", self)
write!(f, "<Token {self:#}>")
}
}

Expand All @@ -403,7 +403,7 @@ impl<'a> fmt::Display for Token<'a> {
self.get_src_line(),
self.get_src_col(),
self.get_name()
.map(|x| format!(" name={}", x))
.map(|x| format!(" name={x}"))
.unwrap_or_default()
)?;
if f.alternate() {
Expand Down