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
126 changes: 76 additions & 50 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,32 @@
name: ci

on:
push: { 'branches': [master] }
pull_request: { 'branches': ["*"] }
push: { branches: [master] }
pull_request: { branches: ["**"] }

jobs:
check:
name: Check ${{ matrix.rust }}
name: Check (${{ matrix.rust }})

runs-on: ubuntu-latest

strategy:
matrix:
rust: ["stable", "nightly"] # "1.67.0",
matrix: { rust: ["stable", "nightly"] } # "1.67.0",

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}

# TODO features here
with: { toolchain: "${{ matrix.rust }}" }

- name: Run cargo check for codespan
run: cargo check --manifest-path "codespan/Cargo.toml" --features "serialization"
run: cargo check

- name: Run cargo check for codespan-reporting
run: cargo check --manifest-path "codespan-reporting/Cargo.toml" --features "serialization"
run: cargo check -p codespan-reporting

- name: Run cargo check for codespan-lsp
run: cargo check --manifest-path "codespan-lsp/Cargo.toml"

check-no-std:
needs: check

name: Check no_std ${{ matrix.rust }} / ${{ matrix.target }}

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
rust: ["stable", "nightly"]
target: ["x86_64-unknown-none", "wasm32v1-none", "thumbv6m-none-eabi"]

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with: { toolchain: '${{ matrix.rust }}', targets: '${{ matrix.target }}' }
run: cargo check -p codespan-lsp

- name: Run cargo check for codespan-reporting
run: cargo check --manifest-path "codespan-reporting/Cargo.toml" --no-default-features --features "serialization" --target ${{ matrix.target }}

- name: Run cargo check for codespan
run: cargo check --manifest-path "codespan/Cargo.toml" --no-default-features --features "serialization" --target ${{ matrix.target }}

test:
needs: check

Expand All @@ -62,33 +36,34 @@ jobs:

strategy:
fail-fast: false
matrix:
rust: ["stable", "nightly"]
matrix: { rust: ["stable", "nightly"] }

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with: { toolchain: '${{ matrix.rust }}' }

# Test each crate individually to work around rust-lang/cargo#4942
- name: Run cargo test for codespan
run: cargo test -p codespan --features "serialization"
run: cargo test -p codespan

- name: Run cargo test for codespan-reporting
run: cargo test -p codespan-reporting --features "serialization"
- name: Run cargo test for codespan-reporting (no features)
run: cargo test -p codespan-reporting --no-default-features

- name: Run cargo test for codespan-reporting (only std feature)
run: cargo test -p codespan-reporting --no-default-features --features std

- name: Run cargo test for codespan-reporting (all default features)
run: cargo test -p codespan-reporting

- name: Run cargo test for codespan-lsp
run: cargo test -p codespan-lsp

fmt:
name: rustfmt

format:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
rust: ["stable"]
matrix: { rust: ["stable"] }

steps:
- uses: actions/checkout@v4
Expand All @@ -113,19 +88,70 @@ jobs:

strategy:
fail-fast: false
matrix:
rust: ["stable"]
matrix: { rust: ["stable"] }

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with: { toolchain: '${{ matrix.rust }}', components: 'clippy' }
with: { toolchain: "${{ matrix.rust }}", components: 'clippy' }

- name: Run cargo clippy
run: cargo clippy --all

dependants:
runs-on: ubuntu-latest

if: contains(github.event.pull_request.labels.*.name, 'api')

# Just a warning for now
continue-on-error: true

timeout-minutes: 5

strategy:
matrix:
# Test dependenents of the codespan project that
repository:
- dtolnay/cxx
- gfx-rs/wgpu
- bevyengine/bevy
- EmbarkStudios/toml-span
- bevyengine/naga_oil
include:
- repository: gfx-rs/wgpu
path: naga
- repository: bevyengine/bevy
path: crates/bevy_render
- repository: EmbarkStudios/toml-span
path: toml-span
fail-fast: false

steps:
- uses: dtolnay/rust-toolchain@stable

- name: Checkout repository
uses: actions/checkout@v4
with: { repository: "${{ matrix.repository }}" }

- name: Run check that it works
run: cargo locate-project
working-directory: ${{ matrix.path }}

- name: Update dependency to ${{ github.repository }} on ${{ github.head_ref }}
run: cargo add codespan-reporting --git https://github.com/${{ github.repository }} --branch ${{ github.head_ref }}
working-directory: ${{ matrix.path }}

- name: Run cargo tree
run: cargo tree
working-directory: ${{ matrix.path }}

- name: Run check
run: cargo check; cargo check --examples
working-directory: ${{ matrix.path }}

publish-ability:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
Expand Down
12 changes: 2 additions & 10 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,7 @@ on:
version:
description: "major/minor/patch or semver"
required: false
default: "patch"
lsp-version:
description: "major/minor/patch or semver for codespan-lsp crate (or none if not releasing derive crate)"
required: false
default: "none"
reporting-version:
description: "major/minor/patch or semver for codespan-reporting crate (or none if not releasing derive crate)"
required: false
default: "none"
default: patch

jobs:
publish:
Expand All @@ -34,7 +26,7 @@ jobs:
uses: kaleidawave/crates-release-gh-action@improvements
id: release
with:
version: codespan=${{ github.event.inputs.version }},codespan-reporting=${{ github.event.inputs.lsp-version }},codespan-lsp=${{ github.event.inputs.reporting-version }}
version: codespan=${{ github.event.inputs.version }},codespan-reporting=${{ github.event.inputs.version }},codespan-lsp=${{ github.event.inputs.version }}
crates-token: ${{ steps.auth.outputs.token }}

- name: Push updated Cargo.toml
Expand Down
15 changes: 11 additions & 4 deletions codespan-reporting/examples/custom_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@
//! ```

use codespan_reporting::diagnostic::{Diagnostic, Label};
use codespan_reporting::term::termcolor::{ColorChoice, StandardStream};
use codespan_reporting::term::{self};
use codespan_reporting::term::{self, Config};
use core::ops::Range;

#[cfg(not(feature = "termcolor"))]
fn main() {
panic!("this example requires termcolor feature");
}

#[cfg(feature = "termcolor")]
fn main() -> anyhow::Result<()> {
use codespan_reporting::term::termcolor::{ColorChoice, StandardStream};

let mut files = files::Files::new();

let file_id0 = files.add("0.greeting", "hello world!").unwrap();
Expand All @@ -30,9 +37,9 @@ fn main() -> anyhow::Result<()> {
];

let writer = StandardStream::stderr(ColorChoice::Always);
let config = term::Config::default();
let config = Config::default();
for message in &messages {
term::emit(
term::emit_to_write_style(
&mut writer.lock(),
&config,
&files,
Expand Down
20 changes: 13 additions & 7 deletions codespan-reporting/examples/peg_calculator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

use codespan_reporting::diagnostic::{Diagnostic, Label};
use codespan_reporting::files::SimpleFile;
use codespan_reporting::term::termcolor::{ColorChoice, StandardStream};
use codespan_reporting::term::{self};
use codespan_reporting::term::{self, Config};

use rustyline::error::ReadlineError;
use rustyline::Editor;

Expand All @@ -36,9 +36,17 @@ peg::parser! {
}
}

#[cfg(not(feature = "termcolor"))]
fn main() {
panic!("this example requires termcolor feature");
}

#[cfg(feature = "termcolor")]
fn main() -> anyhow::Result<()> {
use codespan_reporting::term::termcolor::{ColorChoice, StandardStream};

let writer = StandardStream::stderr(ColorChoice::Always);
let config = codespan_reporting::term::Config::default();
let config = Config::default();
let mut editor = Editor::<()>::new();

loop {
Expand All @@ -56,12 +64,10 @@ fn main() -> anyhow::Result<()> {
let start = error.location.offset;
let diagnostic = Diagnostic::error()
.with_message("parse error")
.with_labels(vec![
Label::primary((), start..start).with_message("parse error")
])
.with_label(Label::primary((), start..start).with_message("parse error"))
.with_notes(vec![format!("expected: {}", error.expected)]);

term::emit(&mut writer.lock(), &config, &file, &diagnostic)?;
term::emit_to_write_style(&mut writer.lock(), &config, &file, &diagnostic)?;
}
}
}
Expand Down
Loading
Loading