Skip to content

Commit e6b923d

Browse files
committed
chore: Merge build-rs / cargo history
2 parents 91809c4 + 3cb51b8 commit e6b923d

File tree

13 files changed

+925
-0
lines changed

13 files changed

+925
-0
lines changed

build-rs/.github/renovate.json5

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": [
4+
"config:recommended",
5+
"schedule:weekly",
6+
":disableDependencyDashboard"
7+
],
8+
"platformCommit": "enabled",
9+
"customManagers": [
10+
{
11+
"customType": "regex",
12+
"description": "Update the minimal supported Rust version in Cargo.toml",
13+
"fileMatch": [
14+
"(^|/)Cargo\\.toml$"
15+
],
16+
"matchStrings": [
17+
"(^|\\[package\\])(.|\n)*?($|\n\\s*\\[)", // select package table
18+
"rust-version = \"(?<currentValue>\\d+\\.\\d+(\\.\\d+)?)\"" // select rust-version
19+
],
20+
"matchStringsStrategy": "recursive",
21+
"depNameTemplate": "rust-version",
22+
"packageNameTemplate": "rust-lang/rust",
23+
"datasourceTemplate": "github-releases",
24+
"versioningTemplate": "semver-coerced",
25+
"extractVersionTemplate": "^(?<version>\\d+\\.\\d+)" // drop patch version
26+
}
27+
],
28+
"packageRules": [
29+
{
30+
"automerge": true,
31+
"minimumReleaseAge": "27 weeks", // 6 months + a little slack
32+
"matchDepNames": [
33+
"rust-version"
34+
]
35+
}
36+
]
37+
}

build-rs/.github/workflows/ci.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: CI
2+
on:
3+
pull_request:
4+
merge_group:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
tests:
11+
name: Tests
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
toolchain: ["stable", "stable 6 months ago"]
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
- name: Install Rust toolchain
20+
uses: dtolnay/rust-toolchain@stable
21+
with:
22+
toolchain: ${{ matrix.toolchain }}
23+
- name: Build tests
24+
run: cargo test --workspace --no-run
25+
- name: Run tests
26+
run: cargo test --workspace
27+
28+
style:
29+
name: Style
30+
runs-on: ubuntu-latest
31+
env:
32+
RUSTFLAGS: -Dwarnings
33+
RUSTDOCFLAGS: -Dwarnings
34+
steps:
35+
- name: Checkout repository
36+
uses: actions/checkout@v4
37+
- name: Install Rust toolchain
38+
uses: dtolnay/rust-toolchain@nightly
39+
with:
40+
components: rustfmt, clippy
41+
- name: Install cargo-docs-rs
42+
uses: dtolnay/install@cargo-docs-rs
43+
- name: Check docs
44+
run: cargo docs-rs
45+
- name: Check lints
46+
run: cargo clippy
47+
- name: Check fmt
48+
run: cargo fmt -- --check
49+
50+
semver:
51+
name: API
52+
runs-on: ubuntu-latest
53+
steps:
54+
- name: Checkout repository
55+
uses: actions/checkout@v4
56+
- name: Semver checks
57+
uses: obi1kenobi/cargo-semver-checks-action@v2
58+
with:
59+
package: build-rs
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Publish
2+
on:
3+
push:
4+
tags:
5+
- 'v*'
6+
7+
jobs:
8+
publish:
9+
name: Publish
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
- name: Install Rust toolchain
15+
uses: dtolnay/rust-toolchain@stable
16+
- name: Publish
17+
run: cargo publish
18+
env:
19+
CARGO_REGISTRY_TOKEN: ${{secrets.CARGO_REGISTRY_TOKEN}}

build-rs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

build-rs/Cargo.lock

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build-rs/Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[package]
2+
name = "build-rs"
3+
version = "0.2.0"
4+
edition = "2021"
5+
rust-version = "1.76"
6+
publish = false
7+
8+
[features]
9+
10+
## Experimental API. This feature flag is **NOT** semver stable.
11+
unstable = []
12+
13+
[workspace]
14+
members = ["test-lib"]

build-rs/src/allow_use.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use std::sync::OnceLock;
2+
3+
fn rust_version_minor() -> u32 {
4+
static VERSION_MINOR: OnceLock<u32> = OnceLock::new();
5+
*VERSION_MINOR.get_or_init(|| {
6+
crate::input::cargo_pkg_rust_version()
7+
.split('.')
8+
.nth(1)
9+
.unwrap_or("70")
10+
.parse()
11+
.unwrap()
12+
})
13+
}
14+
15+
pub(crate) fn double_colon_directives() -> bool {
16+
rust_version_minor() >= 77
17+
}

0 commit comments

Comments
 (0)