-
Notifications
You must be signed in to change notification settings - Fork 0
feat: make it work #2
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c81eaf0
improve the output now i have basic GHA in place
obmarg cf6e629
iterating on this thing
obmarg 02c3a88
add support for docker & non docker platforms
obmarg 3eedbf0
tidy things up, add config support
obmarg 7be3c92
add CI
obmarg 531c5fe
more config tweaks
obmarg 0f9c658
fix ci
obmarg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Create release | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
|
||
jobs: | ||
create-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Create Release | ||
uses: taiki-e/create-gh-release-action@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
upload-artifacts: | ||
strategy: | ||
matrix: | ||
os: | ||
- ubuntu-latest | ||
- macos-latest | ||
- windows-latest | ||
|
||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Upload binaries | ||
uses: taiki-e/upload-rust-binary-action@v1 | ||
with: | ||
bin: what-rust-changed | ||
token: ${{ secrets.GITHUB_TOKEN }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
env: | ||
COLUMNS: 250 | ||
CARGO_INCREMENTAL: 0 | ||
RUSTFLAGS: "-W rust-2021-compatibility -D warnings" | ||
RUST_BACKTRACE: short | ||
NEXTEST_PROFILE: ci | ||
CI: 1 | ||
|
||
jobs: | ||
build-rust: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: dtolnay/[email protected] | ||
with: | ||
components: rustfmt | ||
|
||
- uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Check formatting | ||
shell: bash | ||
run: cargo fmt --check | ||
|
||
- name: Build | ||
shell: bash | ||
run: cargo build |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use std::fs::read_to_string; | ||
|
||
pub fn load() -> Config { | ||
do_load().unwrap_or_default() | ||
} | ||
|
||
fn do_load() -> Option<Config> { | ||
let path = std::env::var("WHAT_RUST_CHANGED_CONFIG").ok()?; | ||
|
||
eprintln!("Loading config from {path}"); | ||
|
||
let data = read_to_string(path).expect("to be able to read named config file"); | ||
|
||
toml::from_str(&data).expect("invalid config format") | ||
} | ||
|
||
#[derive(serde::Serialize, serde::Deserialize, Default)] | ||
#[serde(rename_all = "kebab-case")] | ||
pub struct Config { | ||
/// Packages that shouldn't automatically be included in test runs | ||
pub ignore_test_packages: Vec<String>, | ||
|
||
/// Packages that require docker for their tests and should be put | ||
/// into a separate section of the output | ||
pub docker_test_packages: Vec<String>, | ||
|
||
#[serde(flatten)] | ||
pub determinator_rules: determinator::rules::DeterminatorRules, | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
use guppy::graph::{BuildTarget, BuildTargetKind}; | ||
|
||
pub trait PackageMetadataExt { | ||
fn has_test_targets(&self) -> bool; | ||
fn binary_targets(&self) -> Vec<BuildTarget<'_>>; | ||
} | ||
|
||
impl PackageMetadataExt for guppy::graph::PackageMetadata<'_> { | ||
fn has_test_targets(&self) -> bool { | ||
let package_root_path = self | ||
.manifest_path() | ||
.parent() | ||
.expect("all packages to have manifests with one parent"); | ||
|
||
self.build_targets() | ||
.filter(|target| { | ||
matches!( | ||
target.kind(), | ||
BuildTargetKind::Binary | BuildTargetKind::LibraryOrExample(_) | ||
) | ||
}) | ||
.any(|target| { | ||
let relative_path = target | ||
.path() | ||
.strip_prefix(package_root_path) | ||
.expect("targets to live inside package"); | ||
|
||
let Some(root_folder) = relative_path.components().next() else { | ||
return false; | ||
}; | ||
|
||
let root_folder = root_folder.as_str(); | ||
|
||
// Unfortunately doesn't seem to be any way to tell whether something rooted in | ||
// src actually has tests or not, so best to just assume they do | ||
root_folder == "tests" || root_folder == "src" | ||
}) | ||
} | ||
|
||
fn binary_targets(&self) -> Vec<BuildTarget<'_>> { | ||
let package_root_path = self | ||
.manifest_path() | ||
.parent() | ||
.expect("all packages to have manifests with one parent"); | ||
|
||
self.build_targets() | ||
.filter(|target| matches!(target.kind(), BuildTargetKind::Binary)) | ||
.filter(|target| { | ||
let relative_path = target | ||
.path() | ||
.strip_prefix(package_root_path) | ||
.expect("targets to live inside package"); | ||
|
||
let Some(root_folder) = relative_path.components().next() else { | ||
return false; | ||
}; | ||
|
||
root_folder.as_str() == "src" && relative_path.file_name() == Some("main.rs") | ||
}) | ||
.collect() | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.