Skip to content

Commit

Permalink
[num-format] Add CI
Browse files Browse the repository at this point in the history
  • Loading branch information
bcmyers committed Oct 10, 2022
1 parent b4e8067 commit 91c783b
Show file tree
Hide file tree
Showing 6 changed files with 202 additions and 7 deletions.
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2
updates:
- package-ecosystem: cargo
directory: /
schedule:
interval: daily
ignore:
- dependency-name: "*"
# patch and minor updates don't matter for libraries
# remove this ignore rule if your package has binaries
update-types:
- "version-update:semver-patch"
- "version-update:semver-minor"
75 changes: 75 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
on:
push:
branches: [master]
pull_request:
name: check
jobs:
clippy:
runs-on: ${{ matrix.os }}
name: clippy / ${{ matrix.os }} / stable
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install stable
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
default: true
components: clippy
- name: cargo clippy --all-features --all-targets --tests --workspace -- -D warnings
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-features --all-targets --tests --workspace -- -D warnings
doc:
runs-on: ${{ matrix.os }}
name: doc / ${{ matrix.os }} / stable
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install stable
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
default: true
- name: cargo doc --all-features --no-deps
uses: actions-rs/cargo@v1
with:
command: doc
args: --all-features --no-deps
env:
RUSTDOCFLAGS: --cfg docsrs
fmt:
runs-on: ${{ matrix.os }}
name: fmt / ${{ matrix.os }} / stable
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install stable
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: rustfmt
- name: cargo fmt --all --check
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all --check
108 changes: 108 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
on:
push:
branches: [master]
pull_request:
name: test
jobs:
test:
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} / stable
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install stable
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- name: cargo install cargo-hack
uses: taiki-e/install-action@cargo-hack
- name: cargo generate-lockfile --manifest-path num-format/Cargo.toml
if: hashFiles('Cargo.lock') == ''
uses: actions-rs/cargo@v1
with:
command: generate-lockfile
- name: cargo hack --package num-format --feature-powerset test --locked
uses: actions-rs/cargo@v1
with:
command: hack
args: --package num-format --feature-powerset test --locked
- name: cargo hack --package num-format-benches --feature-powerset test --locked
uses: actions-rs/cargo@v1
with:
command: hack
args: --package num-format-benches --feature-powerset test --locked
- name: cargo hack --package num-format-dev --feature-powerset test --locked
uses: actions-rs/cargo@v1
with:
command: hack
args: --package num-format-dev --feature-powerset test --locked
test-msrv:
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} / ${{ matrix.msrv }}
# we use a matrix here just because env can't be used in job names
# https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
strategy:
fail-fast: false
matrix:
msrv: [1.58.0]
os: [macos-latest, ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install ${{ matrix.msrv }}
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.msrv }}
default: true
- name: cargo install cargo-hack
uses: taiki-e/install-action@cargo-hack
- name: cargo generate-lockfile --manifest-path num-format/Cargo.toml
if: hashFiles('Cargo.lock') == ''
uses: actions-rs/cargo@v1
with:
command: generate-lockfile
args: --manifest-path num-format/Cargo.toml
- name: cargo hack --package num-format --feature-powerset test --locked
uses: actions-rs/cargo@v1
with:
command: hack
args: --package num-format --feature-powerset test --locked
test-msrv-no-default-features:
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} / ${{ matrix.msrv }}
# we use a matrix here just because env can't be used in job names
# https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
strategy:
fail-fast: false
matrix:
msrv: [1.56.0]
os: [macos-latest, ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install ${{ matrix.msrv }}
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.msrv }}
default: true
- name: cargo generate-lockfile --manifest-path num-format/Cargo.toml
if: hashFiles('Cargo.lock') == ''
uses: actions-rs/cargo@v1
with:
command: generate-lockfile
args: --manifest-path num-format/Cargo.toml
- name: cargo test --package num-format --no-default-features --locked
uses: actions-rs/cargo@v1
with:
command: test
args: --package num-format --no-default-features --locked
6 changes: 2 additions & 4 deletions num-format/src/impls/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ where

let mut bytes_written = 0;
let mut digits_remaining = s.len();
let mut iter = s.as_bytes().iter();
while let Some(digit) = iter.next() {
for digit in s.as_bytes().iter() {
if bytes_written == sep_next {
w.write_all(sep_bytes)?;
bytes_written += sep_len;
Expand Down Expand Up @@ -188,8 +187,7 @@ where
let mut bytes_written = 0;
let mut chars_written = 0;
let mut digits_remaining = s.len();
let mut iter = s.chars();
while let Some(c) = iter.next() {
for c in s.chars() {
if chars_written == sep_next {
w.write_str(separator)?;
bytes_written += sep_len;
Expand Down
4 changes: 2 additions & 2 deletions num-format/src/system_locale/nix/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ lazy_static! {
}

// See https://docs.rs/encoding_rs/0.8.16/encoding_rs/
static LATIN_1: &'static encoding_rs::Encoding = encoding_rs::WINDOWS_1252;
static LATIN_1: &encoding_rs::Encoding = encoding_rs::WINDOWS_1252;

#[derive(Copy, Clone, Debug)]
pub(crate) struct Encoding(&'static encoding_rs::Encoding);

impl Encoding {
pub(crate) fn decode<'a>(&self, bytes: &'a [u8]) -> Result<String, Error> {
pub(crate) fn decode(&self, bytes: &[u8]) -> Result<String, Error> {
let (cow, _encoding, is_err) = self.0.decode(bytes);
if is_err {
return Err(Error::system_invalid_return(
Expand Down
3 changes: 2 additions & 1 deletion num-format/src/system_locale/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ fn enum_system_locales_ex() -> Result<HashSet<String>, Error> {
Err(_) => return CONTINUE,
};

if &s == "" {
if s.is_empty() {
return CONTINUE;
}

Expand Down Expand Up @@ -300,6 +300,7 @@ fn get_locale_info_ex(locale_name: &str, request: Request) -> Result<String, Err
size: c_int,
) -> Result<c_int, Error> {
let size = unsafe { winnls::GetLocaleInfoEx(lpLocaleName, LCType, buf_ptr, size) };
#[allow(clippy::comparison_chain)]
if size == 0 {
let err = unsafe { GetLastError() };
if err == 87 {
Expand Down

0 comments on commit 91c783b

Please sign in to comment.