-
Notifications
You must be signed in to change notification settings - Fork 17
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
Update to 2021 edition, add ci + clippy fixes #64
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
name: Continuous Integration | ||
|
||
on: | ||
pull_request: | ||
paths-ignore: | ||
- "**/*.md" | ||
push: | ||
branches: | ||
- main | ||
paths-ignore: | ||
- "**/*.md" | ||
schedule: | ||
- cron: "0 0 * * 0" | ||
merge_group: | ||
types: [checks_requested] | ||
|
||
jobs: | ||
fmt: | ||
name: Rustfmt | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
- name: Install Rust toolchain | ||
uses: dtolnay/rust-toolchain@1482605bfc5719782e1267fd0c0cc350fe7646b8 # v1 | ||
with: | ||
toolchain: stable | ||
- run: rustup component add rustfmt | ||
- name: Run Cargo Fmt | ||
run: cargo fmt --all -- --check | ||
|
||
clippy: | ||
name: Clippy | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
- name: Install Rust toolchain | ||
uses: dtolnay/rust-toolchain@1482605bfc5719782e1267fd0c0cc350fe7646b8 # v1 | ||
with: | ||
toolchain: stable | ||
components: clippy | ||
- uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2 | ||
- name: Run clippy | ||
run: cargo clippy --all-targets --all-features -- -D warnings | ||
|
||
test: | ||
name: Test | ||
runs-on: ${{ matrix.job.os }} | ||
strategy: | ||
matrix: | ||
rust: [stable] | ||
job: | ||
- os: macos-latest | ||
- os: ubuntu-latest | ||
- os: windows-latest | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
if: github.event_name != 'pull_request' | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
if: github.event_name == 'pull_request' | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
fetch-depth: 0 | ||
|
||
- name: Install Rust toolchain | ||
uses: dtolnay/rust-toolchain@1482605bfc5719782e1267fd0c0cc350fe7646b8 # v1 | ||
with: | ||
toolchain: ${{ matrix.rust }} | ||
- uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2 | ||
- name: Run Cargo Test | ||
run: cargo +${{ matrix.rust }} test -r --all-targets --all-features --workspace | ||
|
||
docs: | ||
name: Build docs | ||
runs-on: ${{ matrix.job.os }} | ||
strategy: | ||
matrix: | ||
rust: [stable] | ||
job: | ||
- os: macos-latest | ||
- os: ubuntu-latest | ||
- os: windows-latest | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
if: github.event_name != 'pull_request' | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
if: github.event_name == 'pull_request' | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
fetch-depth: 0 | ||
|
||
- name: Install Rust toolchain | ||
uses: dtolnay/rust-toolchain@1482605bfc5719782e1267fd0c0cc350fe7646b8 # v1 | ||
with: | ||
toolchain: ${{ matrix.rust }} | ||
- uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2 | ||
- name: Run Cargo Doc | ||
run: cargo +${{ matrix.rust }} doc --no-deps --all-features --workspace --examples | ||
|
||
powerset: | ||
name: Check Powerset of Features | ||
runs-on: ${{ matrix.job.os }} | ||
strategy: | ||
matrix: | ||
rust: [stable, beta, nightly] | ||
job: | ||
- os: macos-latest | ||
- os: ubuntu-latest | ||
- os: windows-latest | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
if: github.event_name != 'pull_request' | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
if: github.event_name == 'pull_request' | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
fetch-depth: 0 | ||
|
||
- name: Install Rust toolchain | ||
uses: dtolnay/rust-toolchain@1482605bfc5719782e1267fd0c0cc350fe7646b8 # v1 | ||
with: | ||
toolchain: ${{ matrix.rust }} | ||
- name: install cargo-hack | ||
uses: taiki-e/install-action@2b8d4e021f3c5d9b9d4726c038ac367d3ed730b6 # v2 | ||
with: | ||
tool: cargo-hack | ||
- uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2 | ||
- name: Run Cargo Hack | ||
run: cargo +${{ matrix.rust }} hack check --feature-powerset --no-dev-deps | ||
|
||
result: | ||
name: Result (CI) | ||
runs-on: ubuntu-latest | ||
needs: | ||
- fmt | ||
- clippy | ||
- test | ||
- docs | ||
- powerset | ||
steps: | ||
- name: Mark the job as successful | ||
run: exit 0 | ||
if: success() | ||
- name: Mark the job as unsuccessful | ||
run: exit 1 | ||
if: "!success()" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
name = "native_db" | ||
version = "0.5.1" | ||
authors = ["Vincent Herlemont <[email protected]>"] | ||
edition = "2018" | ||
edition = "2021" | ||
description = "Drop-in embedded database" | ||
license = "MIT" | ||
repository = "https://github.com/vincent-herlemont/native_db" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ fn main() { | |
// Run skeptic | ||
skeptic::generate_doc_tests(&["README.md"]); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ impl<O: ToTokenStream> ToTokenStream for DatabaseKeyDefinition<O> { | |
} | ||
} | ||
|
||
#[derive(Clone)] | ||
#[derive(Clone, Default)] | ||
pub(crate) struct DatabaseSecondaryKeyOptions { | ||
pub(crate) unique: bool, | ||
pub(crate) optional: bool, | ||
|
@@ -62,15 +62,6 @@ impl ToTokenStream for () { | |
} | ||
} | ||
|
||
impl Default for DatabaseSecondaryKeyOptions { | ||
fn default() -> Self { | ||
Self { | ||
unique: false, | ||
optional: false, | ||
} | ||
} | ||
} | ||
|
||
Comment on lines
-65
to
-73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For this part, is it possible to keep the default explicit? Since these are options, it has real logical significance and implications. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can do, but do you want to keep There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, it's fine, let's leave it as it is. There isn't too much ambiguity at that level ^^ |
||
impl<O: ToTokenStream> DatabaseKeyDefinition<O> { | ||
pub(crate) fn name(&self) -> String { | ||
if let Some(field_name) = &self.field_name { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice addition of this workflow file. I see two solutions:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This workflow has the advantage, that it will work with the merge queue. In general, the actions in
build_and_test_release.yml
are outdated and need a rework, unfortunately.actions-rs
as an org is archived, meaning all the actions of them are unmaintained. Maybe we can keep theci.yml
so there are some checks in PRs for now until thebuild_and_test_release.yml
is updated?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I know it's no longer maintained, but
build_and_test_release.yml
allows testing on all platforms, manages releases, etc., whileci.yml
does not. It would be wiser to updatebuild_and_test_release.yml
and separate these changes into different MRs:build_and_test_release.yml
tests workflow.powerset
/cargo hack check
.All these modifications are good to go. I suggest closing this MR and, if you wish, opening specific ones, which I would greatly appreciate :). In any case, it's a great idea, and even if it's not essential, it will be done in the coming weeks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src.: https://github.com/rustic-rs/rustic/tree/main/.github/workflows
I would recommend separating the different workflows by
their scope
andwhen they are run
. Basic checking and testing, fmt, etc. for PRs. Releasing and running time and resource intense workflows on user request (seeprebuilt-pr
above) because some resource intense stuff you don't want to run on PRs (environmental impact, not useful, etc.).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That being said I think
build
or rathercheck
andtest
should not be in the same job:Because one is not dependent on the other, in terms of CI. You want to have output for check/build and a separate output (checkmark) for tests. The more fine-grained the results are, the more useful overall. Otherwise, if that workflow fails, you always need to check, which step of that workflow failed, whereas one job should focus on one thing. And reduce the noise as much as possible.
The current workflow:
Is kind of os specific and doesn't give a lot of information what exactly failed and where the probably lay.
While e.g. the proposed workflow gives you:
An overview of what is happening and doesn't necessarily put os-dependent problems up front, while you still can investigate them, because they are just a build matrix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simonsan Thank you for your explanations. I have started to refactor the CI on
main
. I've made separate workflows, and the next step will be to remove the deprecated jobs, and split intest
,build
etc. Please don't hesitate to give me your opinion; it is valuable.