Skip to content
Closed
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
45 changes: 21 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,28 @@ jobs:
uses: oxidize-rb/actions/fetch-ci-data@v1
with:
stable-ruby-versions: |
# See https://github.com/bytecodealliance/wasmtime-rb/issues/286
# for details.
exclude: [head]
# See https://github.com/bytecodealliance/wasmtime-rb/issues/286
# for details.
exclude: [head]
rspec:
runs-on: ${{ matrix.os }}
needs: ci-data
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest"]
ruby: ${{ fromJSON(needs.ci-data.outputs.result).stable-ruby-versions }}
steps:
- uses: actions/checkout@v4
- uses: oxidize-rb/actions/setup-ruby-and-rust@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
cargo-cache: true
cache-version: v5

- name: Compile rust ext
run: bundle exec rake compile:release

- name: Run ruby tests
run: bundle exec rake spec
runs-on: ${{ matrix.os }}
needs: ci-data
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest"]
ruby: ${{ fromJSON(needs.ci-data.outputs.result).stable-ruby-versions }}
steps:
- uses: actions/checkout@v4
- uses: oxidize-rb/actions/setup-ruby-and-rust@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
cargo-cache: true
- name: Compile andRun ruby tests
run: bundle exec rake
- name: Compile rust ext
run: bundle exec rake compile:release
static_type_check:
name: "Type Check"
runs-on: ubuntu-latest
Expand Down
53 changes: 22 additions & 31 deletions Cargo.lock

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

18 changes: 9 additions & 9 deletions ext/code_ownership/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ crate-type = ["cdylib"]

[dependencies]
rb-sys = { version = "0.9.111", features = [
"bindgen-rbimpls",
"bindgen-deprecated-types",
"stable-api-compiled-fallback",
"bindgen-rbimpls",
"bindgen-deprecated-types",
"stable-api-compiled-fallback",
] }
magnus = { version = "0.7.1" }
serde = { version = "1.0.219", features = ["derive"] }
serde_magnus = "0.9.0"
codeowners = { git = "https://github.com/rubyatscale/codeowners-rs.git", tag = "v0.2.14" }
codeowners = { git = "https://github.com/rubyatscale/codeowners-rs.git", tag = "v0.2.17" }

[dev-dependencies]
rb-sys = { version = "0.9.117", features = [
"link-ruby",
"bindgen-rbimpls",
"bindgen-deprecated-types",
"stable-api-compiled-fallback",
"link-ruby",
"bindgen-rbimpls",
"bindgen-deprecated-types",
"stable-api-compiled-fallback",
] }

[build-dependencies]
rb-sys-env = { version = "0.2.2" }
rb-sys-env = { version = "0.2.2" }
27 changes: 26 additions & 1 deletion ext/code_ownership/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{env, path::PathBuf};
use std::{collections::HashMap, env, path::PathBuf};

use codeowners::runner::{self, RunConfig};
use magnus::{Error, Ruby, Value, function, prelude::*};
Expand All @@ -18,6 +18,30 @@ fn for_team(team_name: String) -> Result<Value, Error> {
validate_result(&team)
}

fn teams_for_files(file_paths: Vec<String>) -> Result<Value, Error> {
let run_config = build_run_config();
let path_teams = runner::teams_for_files_from_codeowners(&run_config, &file_paths);
match path_teams {
Ok(path_teams) => {
let mut teams_map: HashMap<String, Option<Team>> = HashMap::new();
for (path, team) in path_teams {
if let Some(found_team) = team {
teams_map.insert(path, Some(Team {
team_name: found_team.name.to_string(),
team_config_yml: found_team.name.to_string(),
reasons: vec![],
}));
} else {
teams_map.insert(path, None);
}
}
let serialized: Value = serialize(&teams_map)?;
Ok(serialized)
}
Err(e) => Err(Error::new(magnus::exception::runtime_error(), e.to_string())),
}
}

fn for_file(file_path: String) -> Result<Option<Value>, Error> {
let run_config = build_run_config();

Expand Down Expand Up @@ -102,6 +126,7 @@ fn init(ruby: &Ruby) -> Result<(), Error> {
module.define_singleton_method("validate", function!(validate, 0))?;
module.define_singleton_method("for_team", function!(for_team, 1))?;
module.define_singleton_method("version", function!(version, 0))?;
module.define_singleton_method("teams_for_files", function!(teams_for_files, 1))?;

Ok(())
}
Expand Down
Loading
Loading