diff --git a/.github/workflows/build-on-pr-command.yml b/.github/workflows/build-on-pr-command.yml index 4b8f405b5d..8ddd6dfc65 100644 --- a/.github/workflows/build-on-pr-command.yml +++ b/.github/workflows/build-on-pr-command.yml @@ -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 }} diff --git a/.github/workflows/build-on-pr.yml b/.github/workflows/build-on-pr.yml index 0ca475845a..199a2a1eee 100644 --- a/.github/workflows/build-on-pr.yml +++ b/.github/workflows/build-on-pr.yml @@ -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 }} diff --git a/.github/workflows/build-on-release.yml b/.github/workflows/build-on-release.yml index 7f84e0627b..6e025ee01f 100644 --- a/.github/workflows/build-on-release.yml +++ b/.github/workflows/build-on-release.yml @@ -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 }} diff --git a/.github/workflows/server-test.yml b/.github/workflows/server-test.yml index f8d1838335..e28b5530cd 100644 --- a/.github/workflows/server-test.yml +++ b/.github/workflows/server-test.yml @@ -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 @@ -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 \ No newline at end of file diff --git a/.github/workflows/tauri-test.yml b/.github/workflows/tauri-test.yml index 5dce53c462..9680564325 100644 --- a/.github/workflows/tauri-test.yml +++ b/.github/workflows/tauri-test.yml @@ -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 @@ -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 \ No newline at end of file diff --git a/apps/desktop/src-tauri/src/main.rs b/apps/desktop/src-tauri/src/main.rs index 99a3920ab5..5868358b80 100644 --- a/apps/desktop/src-tauri/src/main.rs +++ b/apps/desktop/src-tauri/src/main.rs @@ -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(); } } diff --git a/server/bleep/src/agent/tools/answer.rs b/server/bleep/src/agent/tools/answer.rs index 43bb152ac7..249228d2af 100644 --- a/server/bleep/src/agent/tools/answer.rs +++ b/server/bleep/src/agent/tools/answer.rs @@ -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::(); + 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); @@ -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 }); diff --git a/server/bleep/src/cache.rs b/server/bleep/src/cache.rs index e74529d7ba..ac6511d120 100644 --- a/server/bleep/src/cache.rs +++ b/server/bleep/src/cache.rs @@ -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()); } diff --git a/server/bleep/src/commits.rs b/server/bleep/src/commits.rs index 0b1d79c6dd..976c06ed35 100644 --- a/server/bleep/src/commits.rs +++ b/server/bleep/src/commits.rs @@ -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, @@ -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, @@ -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(); diff --git a/server/bleep/src/intelligence/scope_resolution.rs b/server/bleep/src/intelligence/scope_resolution.rs index 339122b500..7b923311a7 100644 --- a/server/bleep/src/intelligence/scope_resolution.rs +++ b/server/bleep/src/intelligence/scope_resolution.rs @@ -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)) { diff --git a/server/bleep/src/query/parser.rs b/server/bleep/src/query/parser.rs index 2d56f11a34..3d5890e156 100644 --- a/server/bleep/src/query/parser.rs +++ b/server/bleep/src/query/parser.rs @@ -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> { let lhs = self.as_plain()?; let rhs = rhs.as_plain()?; diff --git a/server/bleep/src/repo/iterator/git.rs b/server/bleep/src/repo/iterator/git.rs index fc3f0ae1ef..7ccde78f5d 100644 --- a/server/bleep/src/repo/iterator/git.rs +++ b/server/bleep/src/repo/iterator/git.rs @@ -135,7 +135,7 @@ impl GitWalker { FileType::Other }; - let branches = acc.entry((file, kind, oid)).or_insert_with(BTreeSet::new); + let branches: &mut BTreeSet = acc.entry((file, kind, oid)).or_default(); if is_head { branches.insert("HEAD".to_string()); } diff --git a/server/bleep/src/semantic/execute.rs b/server/bleep/src/semantic/execute.rs index 0b717500e9..0af9a4dd7e 100644 --- a/server/bleep/src/semantic/execute.rs +++ b/server/bleep/src/semantic/execute.rs @@ -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, diff --git a/server/bleep/src/webserver/file.rs b/server/bleep/src/webserver/file.rs index 5529c5c635..3b7c8805b8 100644 --- a/server/bleep/src/webserver/file.rs +++ b/server/bleep/src/webserver/file.rs @@ -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)