Skip to content

Commit 0aeadac

Browse files
authored
Merge pull request #47 from Marcondiro/master
Improve CI, (almost) enforce MSRV
2 parents 990fa09 + 60bca93 commit 0aeadac

File tree

4 files changed

+103
-30
lines changed

4 files changed

+103
-30
lines changed

.github/workflows/ci.yml

Lines changed: 84 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,103 @@ name: CI
22

33
on:
44
push:
5+
branches: [ master ]
56
pull_request:
6-
schedule: [cron: "40 1 * * *"]
7+
branches: [ master ]
8+
9+
env:
10+
CARGO_INCREMENTAL: 0
11+
CARGO_TERM_COLOR: always
12+
RUST_BACKTRACE: 1
13+
RUSTFLAGS: -D warnings
14+
RUSTDOCFLAGS: -D warnings --cfg docsrs
715

816
jobs:
9-
test:
10-
name: Rust ${{matrix.rust}}
17+
get-package-info:
1118
runs-on: ubuntu-latest
19+
outputs:
20+
msrv: ${{ steps.msrv.outputs.metadata }}
21+
name: ${{ steps.name.outputs.metadata }}
22+
version: ${{ steps.version.outputs.metadata }}
23+
steps:
24+
- uses: actions/checkout@v5
25+
- name: Get MSRV
26+
id: msrv
27+
uses: nicolaiunrein/[email protected]
28+
with:
29+
subcommand: 'package.rust_version'
30+
- name: Get package name
31+
id: name
32+
uses: nicolaiunrein/[email protected]
33+
with:
34+
subcommand: 'package.name'
35+
- name: Get package version
36+
id: version
37+
uses: nicolaiunrein/[email protected]
38+
with:
39+
subcommand: 'package.version'
40+
41+
build_test:
42+
needs: get-package-info
43+
runs-on: ${{ matrix.os }}
1244
strategy:
13-
fail-fast: false
1445
matrix:
15-
rust: [nightly, beta, stable]
46+
os: [ ubuntu-latest, windows-latest ]
47+
rust:
48+
- ${{ needs.get-package-info.outputs.msrv }}
49+
- stable
50+
- beta
51+
- nightly
52+
exclude:
53+
# excludes MSRV on Windows due to linker issues
54+
- os: windows-latest
55+
rust: ${{ needs.get-package-info.outputs.msrv }}
1656
steps:
17-
- uses: actions/checkout@v2
18-
- uses: actions-rs/toolchain@v1
57+
- uses: actions/checkout@v5
58+
- name: Install toolchain
59+
if: matrix.rust != needs.get-package-info.outputs.msrv
60+
uses: dtolnay/rust-toolchain@master
1961
with:
20-
toolchain: ${{matrix.rust}}
21-
profile: minimal
22-
override: true
23-
- run: cargo build --features bench
62+
toolchain: ${{ matrix.rust }}
63+
components: rustfmt, clippy
64+
- name: Install MSRV toolchain
65+
if: matrix.rust == needs.get-package-info.outputs.msrv
66+
uses: dtolnay/rust-toolchain@master
67+
with:
68+
toolchain: ${{ needs.get-package-info.outputs.msrv }}
69+
- name: Remove dev-dependencies for MSRV (very dirty hack)
70+
if: matrix.rust == needs.get-package-info.outputs.msrv
71+
shell: pwsh
72+
run: |
73+
(Get-Content Cargo.toml) -replace '^\[dev-dependencies\].*?(\n\[|$)', '[placeholder]' | Set-Content Cargo.toml
74+
- name: Build
75+
run: cargo build --verbose
76+
- name: Run tests with all features
77+
run: cargo test --all-features --verbose
2478
if: matrix.rust == 'nightly'
25-
- run: cargo test --features bench
79+
- name: Run tests without features
80+
run: cargo test --no-default-features --verbose
81+
- name: Package
82+
run: cargo package --allow-dirty
83+
- name: Test package
84+
working-directory: target/package/${{ needs.get-package-info.outputs.name }}-${{ needs.get-package-info.outputs.version }}/
85+
run: cargo test --verbose
86+
- name: Test package without features
87+
working-directory: target/package/${{ needs.get-package-info.outputs.name }}-${{ needs.get-package-info.outputs.version }}/
88+
run: cargo test --no-default-features --verbose
89+
- name: Run benchmarks
90+
run: cargo bench --features bench --verbose
2691
if: matrix.rust == 'nightly'
27-
- run: cargo bench --features bench
92+
- name: Build docs
93+
run: cargo doc --all-features --verbose
2894
if: matrix.rust == 'nightly'
29-
- run: cargo build
95+
3096
tables:
3197
name: Verify tables
3298
runs-on: ubuntu-latest
3399
steps:
34-
- uses: actions/checkout@v2
100+
- uses: actions/checkout@v5
101+
- name: Regenerate tables
102+
run: ./scripts/unicode.py && rustfmt tables.rs
35103
- name: Verify regenerated files
36-
run: ./scripts/unicode.py && rustfmt tables.rs && diff tables.rs src/tables.rs
104+
run: diff tables.rs src/tables.rs

Cargo.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
name = "unicode-xid"
44
version = "0.2.6"
5-
authors = ["erick.tryzelaar <[email protected]>",
6-
"kwantam <[email protected]>",
7-
"Manish Goregaokar <[email protected]>"
8-
]
5+
authors = [
6+
"erick.tryzelaar <[email protected]>",
7+
"kwantam <[email protected]>",
8+
"Manish Goregaokar <[email protected]>",
9+
]
910

1011
homepage = "https://github.com/unicode-rs/unicode-xid"
1112
repository = "https://github.com/unicode-rs/unicode-xid"

src/lib.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414
//! ```rust
1515
//! use unicode_xid::UnicodeXID;
1616
//!
17-
//! fn main() {
18-
//! assert_eq!(UnicodeXID::is_xid_start('a'), true); // 'a' is a valid start of an identifier
19-
//! assert_eq!(UnicodeXID::is_xid_start('△'), false); // '△' is a NOT valid start of an identifier
20-
//! }
17+
//! assert_eq!(UnicodeXID::is_xid_start('a'), true); // 'a' is a valid start of an identifier
18+
//! assert_eq!(UnicodeXID::is_xid_start('△'), false); // '△' is a NOT valid start of an identifier
2119
//! ```
2220
//!
2321
//! # features
@@ -33,7 +31,7 @@
3331
html_favicon_url = "https://unicode-rs.github.io/unicode-rs_sm.png"
3432
)]
3533
#![no_std]
36-
#![cfg_attr(feature = "bench", feature(test, unicode_internals))]
34+
#![cfg_attr(feature = "bench", feature(test))]
3735

3836
#[cfg(test)]
3937
#[macro_use]

tests/exhaustive_tests.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
extern crate unicode_xid;
2+
23
use unicode_xid::UnicodeXID;
34
/// A `char` in Rust is a Unicode Scalar Value
45
///
56
/// See: http://www.unicode.org/glossary/#unicode_scalar_value
6-
fn all_valid_chars() -> impl Iterator<Item = char> {
7-
(0u32..=0xD7FF).chain(0xE000u32..=0x10FFFF).map(|u| {
8-
core::convert::TryFrom::try_from(u)
9-
.expect("The selected range should be infallible if the docs match impl")
10-
})
7+
fn all_valid_chars() -> Vec<char> {
8+
(0u32..0xD7FF)
9+
.chain(Some(0xD7FF))
10+
.chain(0xE000u32..0x10FFFF)
11+
.chain(Some(0x10FFFF))
12+
.map(|u| {
13+
std::char::from_u32(u)
14+
.expect("The selected range should be infallible if the docs match impl")
15+
})
16+
.collect()
1117
}
1218

1319
#[test]

0 commit comments

Comments
 (0)