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

Initial release #1

Merged
merged 4 commits into from
Jul 20, 2023
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
17 changes: 17 additions & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Templated by `cargo-generate` using https://github.com/danielhenrymantilla/proc-macro-template
[alias]
docs-rs = [
"doc", "--no-deps", "--open",
"--features", "docs-rs",
]

[build]
rustdocflags = [
"--html-before-content", "fix-docsrs-li-details-summary.html",
]

[doc.extern-map.registries]
crates-io = "https://docs.rs/"

[profile.rust-analyzer]
inherits = "dev"
110 changes: 110 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: CI

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
push:
branches:
- master
pull_request:

jobs:
# == CHECK == #
check:
name: "Check beta stable and MSRV=1.65.0"
runs-on: ubuntu-latest
strategy:
matrix:
rust-toolchain:
- 1.65.0
- stable
# Try to guard against a near-future regression.
- beta
cargo-locked: ['', '--locked']
feature-nightly-dropck_eyepatch: ['', '--features nightly-dropck_eyepatch']
exclude:
# MSRV guarantee only stands for `.lock`-tested dependencies.
- rust-toolchain: 1.65.0
cargo-locked: ''
steps:
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust-toolchain }}
override: true

- name: Clone repo
uses: actions/checkout@v2

- name: Update `Cargo.lock`
if: matrix.cargo-locked != '--locked'
run: cargo update -v

- name: Cargo check
uses: actions-rs/cargo@v1
env:
RUSTC_BOOTSTRAP: 1
with:
command: check
args: ${{ matrix.cargo-locked }} ${{ matrix.feature-nightly-dropck_eyepatch }}

# == BUILD & TEST == #
build-and-test:
name: Build and test
runs-on: ${{ matrix.os }}
needs: []
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
rust-toolchain:
- 1.65.0
- stable
steps:
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: default
override: true
toolchain: ${{ matrix.rust-toolchain }}

- name: Clone repo
uses: actions/checkout@v2

- name: cargo test --lib --tests
uses: actions-rs/cargo@v1
with:
command: test
args: --lib --tests

- name: cargo test --doc
if: matrix.rust-toolchain == 'stable'
uses: actions-rs/cargo@v1
env:
RUSTC_BOOTSTRAP: 1
with:
command: test
args: --features better-docs --doc

required-jobs:
name: 'All the required jobs'
needs:
- check
- build-and-test
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
- name: 'Check success of the required jobs'
run: |
RESULT=$(echo "${{ join(needs.*.result, '') }}" | sed -e "s/success//g")
if [ -n "$RESULT" ]; then
echo "❌"
false
fi
echo "✅"
57 changes: 57 additions & 0 deletions .github/workflows/future-proof.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Templated by `cargo-generate` using https://github.com/danielhenrymantilla/proc-macro-template
name: Cron CI

on:
push:
branches:
- master
schedule:
- cron: '0 8 * * 1,5'

jobs:
# == TEST == #
test-no-ui:
name: (Check & Build &) Test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
rust-toolchain:
# Future-proof against compiler-regressions
- beta
- nightly
cargo-locked: ['--locked']
feature-nightly-dropck_eyepatch: ['', '--features nightly-dropck_eyepatch']
include:
# Also future-proof against semver breakage from dependencies.
- rust-toolchain: stable
cargo-locked: ''
steps:
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: default
override: true
toolchain: ${{ matrix.rust-toolchain }}

- name: Clone repo
uses: actions/checkout@v2

- name: Update `Cargo.lock`
if: matrix.cargo-locked != '--locked'
run: cargo update -v

- name: Cargo test
uses: actions-rs/cargo@v1
env:
RUSTC_BOOTSTRAP: 1
with:
command: test
args: |
--features better-docs
${{ matrix.cargo-locked }}
${{ matrix.feature-nightly-dropck_eyepatch }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Templated by `cargo-generate` using https://github.com/danielhenrymantilla/proc-macro-template
/target
7 changes: 7 additions & 0 deletions Cargo.lock
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why Cargo.lock is in source control? I always thought libraries don't do that

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for sharing the link, the PR is quite informative. I got curious about why the lockfile was included while trying to understand why CI is testing against the locked and latest versions of the (hypothetical) dependencies. This conservative approach to CI testing both deterministically and non-deterministically makes sense to me after reading the PR. Never really thought about dependencies breaking pipelines.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Templated by `cargo-generate` using https://github.com/danielhenrymantilla/proc-macro-template
[package]
name = "maybe-dangling"
authors = [
"Daniel Henry-Mantilla <[email protected]>",
]
version = "0.1.0" # Keep in sync
edition = "2021"
rust-version = "1.65.0"

license = "Zlib OR MIT OR Apache-2.0"
repository = "https://github.com/danielhenrymantilla/maybe-dangling.rs"
documentation = "https://docs.rs/maybe-dangling"
readme = "README.md"

description = "`ManuallyDrop<T>` and `MaybeDangling<T>` semantics in stable Rust as per https://github.com/rust-lang/rfcs/pull/3336"
keywords = ["unsafe", "dangling", "aliasing", "dereferenceable", "manuallydrop"]

[features]
default = [
]

# Enable and use `#![feature(dropck_eyepatch)]` for `MaybeDangling`.
nightly-dropck_eyepatch = []

# unstable! Will probably use nightly to improve doc quality
better-docs = []

ui-tests = [
"better-docs",
]

# `docs-rs` is very similar to `better-docs`, but for it being allowed to enable
# other features as well, often to make sure optional/non-`default` features
# make it to the rendered docs (using `--all-features` instead is not that great).
docs-rs = [
"better-docs",
]
Comment on lines +33 to +38
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it not make more sense for this to be a --cfg flag?

Copy link
Owner Author

@danielhenrymantilla danielhenrymantilla Jul 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen this pattern quite a bit, true, but I somehow find the feature to be more convenient, provided that it is properly document as unstable (I'm not that fond of fiddling with env vars / rustflags unless strictly necessary). But I have no strong opinions on this either way 🙂

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm used to cargo build --all-features working on Tokio with a stable compiler, which is why we use a --cfg. But I guess you also have other unstable features here.

Copy link
Owner Author

@danielhenrymantilla danielhenrymantilla Jul 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, currently the default-features plays the role of the --all-features of finer-featured crates such as tokio; I wouldn't expect us going that far with this crate, but if we did, I suspect we'd end up with an all-stable-features Cargo feature for this (which is partially orthogonal to the specific case of docs.rs tweaks, since these are not expected to be used by users, so a --cfg can make a lot of sense there).

If you feel like making the change for these docs.rs knobs anyways feel free to do so or suggested it over #2

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't seem like better-docs or docs-rs are used at all? Maybe I'm missing something.

Copy link
Owner Author

@danielhenrymantilla danielhenrymantilla Jul 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah true 😄 This is from a template I use, which lets me opt into extra facilities. For instance, it has recently occurred to me that we could consider feature-gating the MaybeDangling wrapper (since I expect to be rarely needed to have something with inherent drop glue and yet allowed to dangle), and in that case the idea would be to use better-docs to enable doc(cfg()) to illustrate that


[dependencies]

[dev-dependencies]

[workspace]

[package.metadata.docs.rs]
features = [
"docs-rs",
]
rustdoc-args = [
# Use (with or without `open`):
# ```md
# <details open class="custom"><summary><span class="summary-box"><span>Click to hide</span></span></summary>
# …
# </details>
# ```
# to get nice drop-down menus (and avoid the css bug with rustdoc).
"--html-before-content", "fix-docsrs-li-details-summary.html",
]
Loading