Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre-commit, formatting, renovate and other minor fixes #5

Merged
merged 6 commits into from
Oct 21, 2024
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
10 changes: 10 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"commitMessageExtra": "from `{{#if isPinDigest}}{{{currentDigestShort}}}{{else}}{{#if currentValue}}{{{currentValue}}}{{else}}{{{currentDigestShort}}}{{/if}}{{#if isSingleVersion}} (v{{{currentVersion}}}){{/if}}{{/if}}` to `{{#if isPinDigest}}{{{newDigestShort}}}{{else}}{{#if newValue}}{{{newValue}}}{{else}}{{{newDigestShort}}}{{/if}}{{#if isSingleVersion}} ({{{prettyNewVersion}}}){{/if}}{{/if}}{{#if isMajor}} (major {{{prettyNewMajor}}}){{/if}}`",
"extends": [
"config:base"
],
"separateMajorMinor": true,
"separateMinorPatch": true,
"separateMultipleMajor": true
}
1 change: 1 addition & 0 deletions .github/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pre-commit==4.0.1
33 changes: 33 additions & 0 deletions .github/workflows/quality-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
name: Verify Quality Checks

on:
pull_request:
types: [assigned, opened, synchronize, reopened]

concurrency:
# Documentation suggests ${{ github.head_ref }}, but that's only available on pull_request/pull_request_target triggers, so using ${{ github.ref }}.
# On master, we want all builds to complete even if merging happens faster to make it easier to discover at which point something broke.
group: ${{ github.ref == 'refs/heads/main' && format('quality-ci-main-{0}', github.sha) || format('quality-ci-{0}', github.ref) }}
cancel-in-progress: true

jobs:
pre-commit:
name: Pre-commit checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: pip
- name: Install dependencies
run: |
pip install -U pip setuptools wheel
pip install -r .github/requirements.txt
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit/
key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Run pre-commit hooks
run: pre-commit run --all-files --show-diff-on-failure
25 changes: 25 additions & 0 deletions .github/workflows/quality-renovate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Verify Quality Checks

on:

pull_request:
types: [assigned, opened, synchronize, reopened]
paths:
- .github/renovate.json
- .github/workflows/renovate-verify.yml

concurrency:
# Documentation suggests ${{ github.head_ref }}, but that's only available on pull_request/pull_request_target triggers, so using ${{ github.ref }}.
# On master, we want all builds to complete even if merging happens faster to make it easier to discover at which point something broke.
group: ${{ github.ref == 'refs/heads/main' && format('quality-renovate-main-{0}', github.sha) || format('quality-renovate-{0}', github.ref) }}
cancel-in-progress: true

jobs:
verify-renovate:
name: Renovate official check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npx --package renovate -c 'renovate-config-validator'
19 changes: 19 additions & 0 deletions .github/workflows/wait-all-checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: Wait all checks

on:
pull_request:
types: [assigned, opened, synchronize, reopened]
workflow_call:

jobs:
wait-all-checks:
runs-on: ubuntu-latest
permissions:
checks: read
steps:
- name: Wait all GitHub checks
uses: poseidon/wait-for-status-checks@v0.5.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
ignore: wait-all-checks / wait-all-checks
28 changes: 28 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-case-conflict
- id: check-merge-conflict
- id: check-json
- id: check-symlinks
- id: end-of-file-fixer
- id: pretty-format-json
args: [--autofix]
- id: trailing-whitespace
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
- id: forbid-crlf
- id: forbid-tabs
- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
rev: 0.2.3
hooks:
- id: yamlfmt
args: [--mapping, '2', --sequence, '2', --offset, '0', --width, '150']
- repo: https://github.com/eirnym/language-formatters-pre-commit-hooks
rev: 2.14.2
hooks:
- id: pretty-format-rust
args: [--autofix]
80 changes: 0 additions & 80 deletions .travis.yml

This file was deleted.

16 changes: 7 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
[package]
name = "locale_config"
version = "0.3.1-alpha.0"
edition = "2021"
description = """
Maintains locale preferences for process and thread and initialises them by
inspecting the system for user preference.
"""
authors = [
"Jan Hudec <bulb@ucw.cz>",
"Eir Nym <eirnym@gmail.com>"
]
license = "MIT"

documentation = "https://docs.rs/locale_config/"
repository = "https://github.com/rust-locale/locale_config/"
repository = "https://github.com/eirtools/locale_config/"
readme = "README.md"
keywords = ["i18n"]
categories = ["os"]
Expand All @@ -20,17 +22,13 @@ exclude = ["/ci/*", "/.travis.yml", "/appveyor.yml"]
[package.metadata.release]
upload-doc = true

[badges]
travis-ci = { repository = "rust-locale/locale_config" }
appveyor = { repository = "rust-locale/locale_config" }

[dependencies]
lazy_static = "1"
lazy_static = "1.5.0"
regex-lite = "0.1.6"

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["winnls"] }
winapi = { version = "0.3.9", features = ["winnls"] }

[target.'cfg(target_os = "macos")'.dependencies]
objc2 = "0.5.1"
objc2-foundation = { version = "0.2", features = ["NSLocale", "NSString"] }
objc2 = "0.5.2"
objc2-foundation = { version = "0.2.2", features = ["NSLocale", "NSString"] }
58 changes: 0 additions & 58 deletions appveyor.yml

This file was deleted.

2 changes: 1 addition & 1 deletion src/cgi.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Inspect CGI environment variables for locale configuration

use super::Locale;
use std::env;
use super::{Locale};

pub fn system_locale() -> Option<Locale> {
if let Ok(al) = env::var("HTTP_ACCEPT_LANGUAGE") {
Expand Down
6 changes: 4 additions & 2 deletions src/emscripten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ pub fn system_locale() -> Option<Locale> {
return 0;\0";
unsafe {
let cptr = emscripten_asm_const_int(&JS[0] as *const _ as *const c_char);
return CStr::from_ptr(cptr as *const c_char).to_str().ok()
return CStr::from_ptr(cptr as *const c_char)
.to_str()
.ok()
.and_then(|s| Locale::new(s).ok());
}
}
}
Loading