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

Run tests on GitHub runners #1158

Merged
merged 7 commits into from
Nov 30, 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
2 changes: 1 addition & 1 deletion .github/workflows/build-on-pr-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
with:
repository: bloop
tag: ${{ needs.build_tag.outputs.tag }}
runner: docker
runner: ubuntu-latest
secrets:
awsRegion: ${{ secrets.AWS_REGION }}
awsAccountID: ${{ secrets.AWS_ACCOUNT_ID }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
with:
repository: bloop
tag: build-${{ github.sha }}
runner: docker
runner: ubuntu-latest
secrets:
awsRegion: ${{ secrets.AWS_REGION }}
awsAccountID: ${{ secrets.AWS_ACCOUNT_ID }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-on-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
with:
repository: bloop
tag: ${{ github.event.release.tag_name }}
runner: docker
runner: ubuntu-latest
secrets:
awsRegion: ${{ secrets.AWS_REGION }}
awsAccountID: ${{ secrets.AWS_ACCOUNT_ID }}
Expand Down
42 changes: 20 additions & 22 deletions .github/workflows/server-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,33 @@ env:

jobs:
clippy-test:
runs-on: nixos
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
lfs: true

- name: Create LFS file list
run: git lfs ls-files --long | cut -d ' ' -f1 | sort > .lfs-assets-id

- name: LFS Cache
uses: takost/cache@2001ca4114dbc44888c30c0ec3550fecf724b8d9
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
path: .git/lfs/objects
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}
restore-keys: |
${{ runner.os }}-lfs-

- name: Git LFS Pull
run: git lfs install && git lfs pull

- name: Load PATH changes
run: direnv allow && direnv exec . sh -c 'echo $PATH' > "$GITHUB_PATH"
toolchain: 1.73.0
components: rustfmt, clippy

- name: Load other environment changes
run: direnv export gha >> "$GITHUB_ENV"
# https://github.com/actions/cache/blob/main/examples.md#rust---cargo
- name: Set up cargo cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Rustfmt
run: cargo --locked fmt -p bleep -- --check
Expand All @@ -51,7 +52,4 @@ jobs:
run: cargo --locked clippy -p bleep --features=ee-pro,ee-cloud

- name: Tests
run: cargo --locked test -p bleep --release

- name: Sccache stats
run: sccache --show-stats
run: cargo --locked test -p bleep --release --features=ee-pro,ee-cloud
53 changes: 32 additions & 21 deletions .github/workflows/tauri-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,46 @@ env:

jobs:
clippy-test:
runs-on: nixos
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
lfs: true

- name: Create LFS file list
run: git lfs ls-files --long | cut -d ' ' -f1 | sort > .lfs-assets-id

- name: LFS Cache
uses: takost/cache@2001ca4114dbc44888c30c0ec3550fecf724b8d9
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
path: .git/lfs/objects
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}
restore-keys: |
${{ runner.os }}-lfs-

- name: Git LFS Pull
run: git lfs install && git lfs pull
toolchain: 1.73.0
components: rustfmt, clippy

- name: Load PATH changes
run: direnv allow && direnv exec . sh -c 'echo $PATH' > "$GITHUB_PATH"
- name: Install Tauri deps
run: |
sudo apt update && \
sudo apt install libwebkit2gtk-4.0-dev \
build-essential \
curl \
wget \
file \
libssl-dev \
libgtk-3-dev \
libayatana-appindicator3-dev \
librsvg2-dev

- name: Load other environment changes
run: direnv export gha >> "$GITHUB_ENV"
# https://github.com/actions/cache/blob/main/examples.md#rust---cargo
- name: Set up cargo cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Rustfmt
run: cargo --locked fmt -p bloop -- --check
Expand All @@ -51,7 +65,4 @@ jobs:
run: cargo --locked clippy -p bloop

- name: Tests
run: cargo --locked test -p bloop --release

- name: Sccache stats
run: sccache --show-stats
run: cargo --locked test -p bloop --release
13 changes: 5 additions & 8 deletions apps/desktop/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,13 @@ fn main() {

#[tauri::command]
fn show_main_window(app_handle: tauri::AppHandle) {
match app_handle.get_window("main") {
Some(window) => {
if !cfg!(target_os = "macos") {
window.unminimize().unwrap();
}
if let Some(window) = app_handle.get_window("main") {
if !cfg!(target_os = "macos") {
window.unminimize().unwrap();
window.set_focus().unwrap();
window.show().unwrap();
}
None => {}
window.unminimize().unwrap();
window.set_focus().unwrap();
window.show().unwrap();
}
}

Expand Down
19 changes: 11 additions & 8 deletions server/bleep/src/agent/tools/answer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,15 @@ impl Agent {
// Select as many recent chunks as possible
let mut recent_chunks = Vec::new();
for chunk in code_chunks.iter().rev() {
let snippet = chunk
.snippet
.lines()
.enumerate()
.map(|(i, line)| format!("{} {line}\n", i + chunk.start_line + 1))
.collect::<String>();
let snippet =
chunk
.snippet
.lines()
.enumerate()
.fold(String::new(), |mut acc, (i, line)| {
acc += &format!("{} {line}\n", i + chunk.start_line + 1, line = line);
acc
});

let formatted_snippet = format!("### {} ###\n{snippet}\n\n", chunk.path);

Expand All @@ -178,8 +181,8 @@ impl Agent {
let mut recent_chunks_by_alias: HashMap<_, _> =
recent_chunks
.into_iter()
.fold(HashMap::new(), |mut map, item| {
map.entry(item.0.alias).or_insert_with(Vec::new).push(item);
.fold(HashMap::<_, Vec<_>>::new(), |mut map, item| {
map.entry(item.0.alias).or_default().push(item);
map
});

Expand Down
2 changes: 1 addition & 1 deletion server/bleep/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ impl<'a> ChunkCache<'a> {
if existing.get().value != branches_hash {
self.update
.entry((payload.branches, branches_hash.clone()))
.or_insert_with(Vec::new)
.or_default()
.get_mut()
.push(existing.key().to_owned());
}
Expand Down
18 changes: 10 additions & 8 deletions server/bleep/src/commits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@ impl<'a> Iterator for CommitIterator<'a> {
stats.modified_file_paths.insert(location.to_string());

match &change.event {
gix::object::tree::diff::change::Event::Addition { entry_mode, id }
if matches!(entry_mode, EntryMode::Blob) =>
{
gix::object::tree::diff::change::Event::Addition {
entry_mode: EntryMode::Blob,
id,
} => {
stats.num_file_insertions += 1;
add_diff(
&location,
Expand All @@ -118,9 +119,10 @@ impl<'a> Iterator for CommitIterator<'a> {
&mut stats,
);
}
gix::object::tree::diff::change::Event::Deletion { entry_mode, id }
if matches!(entry_mode, EntryMode::Blob) =>
{
gix::object::tree::diff::change::Event::Deletion {
entry_mode: EntryMode::Blob,
id,
} => {
stats.num_file_deletions += 1;
add_diff(
&location,
Expand All @@ -133,9 +135,9 @@ impl<'a> Iterator for CommitIterator<'a> {
gix::object::tree::diff::change::Event::Rewrite {
source_id,
id,
entry_mode,
entry_mode: EntryMode::Blob,
..
} if matches!(entry_mode, EntryMode::Blob) => {
} => {
let platform = Platform::from_ids(source_id, id).unwrap();
let old = platform.old.data.as_bstr().to_str_lossy();
let new = platform.new.data.as_bstr().to_str_lossy();
Expand Down
17 changes: 9 additions & 8 deletions server/bleep/src/intelligence/scope_resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,14 +571,15 @@ fn scope_res_generic(
.unwrap();
let mut scope_graph = ScopeGraph::new(root_node.range().into(), lang_id);

let capture_map = captures.fold(HashMap::new(), |mut map, (match_, capture_idx)| {
let capture = match_.captures[capture_idx];
let range: TextRange = capture.node.range().into();
map.entry(capture.index)
.or_insert_with(Vec::new)
.push(range);
map
});
let capture_map = captures.fold(
HashMap::<_, Vec<_>>::new(),
|mut map, (match_, capture_idx)| {
let capture = match_.captures[capture_idx];
let range: TextRange = capture.node.range().into();
map.entry(capture.index).or_default().push(range);
map
},
);

// insert scopes first
if let Some(ranges) = local_scope_capture_index.and_then(|idx| capture_map.get(&idx)) {
Expand Down
1 change: 1 addition & 0 deletions server/bleep/src/query/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ impl<'a> Literal<'a> {
}

/// This drops position information, as it's not intelligible after the merge
#[allow(dead_code)]
fn join_as_plain(self, rhs: Self) -> Option<Literal<'static>> {
let lhs = self.as_plain()?;
let rhs = rhs.as_plain()?;
Expand Down
2 changes: 1 addition & 1 deletion server/bleep/src/repo/iterator/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl GitWalker {
FileType::Other
};

let branches = acc.entry((file, kind, oid)).or_insert_with(BTreeSet::new);
let branches: &mut BTreeSet<String> = acc.entry((file, kind, oid)).or_default();
if is_head {
branches.insert("HEAD".to_string());
}
Expand Down
4 changes: 2 additions & 2 deletions server/bleep/src/semantic/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ pub async fn execute(

let data = results
.into_iter()
.fold(HashMap::new(), |mut acc, payload| {
.fold(HashMap::<_, Vec<_>>::new(), |mut acc, payload| {
acc.entry((
payload.relative_path.to_string(),
payload.repo_name.to_string(),
payload.repo_ref.to_string(),
Some(payload.lang.to_string()),
))
.or_insert_with(Vec::new)
.or_default()
.push(Snippet {
data: payload.text.to_string(),
line_range: payload.start_line as usize..payload.end_line as usize,
Expand Down
2 changes: 1 addition & 1 deletion server/bleep/src/webserver/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub(super) async fn handle<'a>(

fn split_by_lines<'a>(text: &'a str, indices: &[u32], params: &Params) -> Result<&'a str, Error> {
let char_start = match params.line_start {
Some(line_start) if line_start == 1 => 0,
Some(1) => 0,
Some(line_start) if line_start > 1 => {
(indices
.get(line_start as usize - 2)
Expand Down
Loading