From c34533ab7b6f9f94d1f595c3d595df04e54cb992 Mon Sep 17 00:00:00 2001 From: Gabriel Gordon-Hall Date: Thu, 30 Nov 2023 09:36:02 +0000 Subject: [PATCH 1/7] run ci on gh runner --- .github/workflows/server-test.yml | 2 +- .github/workflows/tauri-test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/server-test.yml b/.github/workflows/server-test.yml index f8d1838335..e5030e038e 100644 --- a/.github/workflows/server-test.yml +++ b/.github/workflows/server-test.yml @@ -17,7 +17,7 @@ env: jobs: clippy-test: - runs-on: nixos + runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 diff --git a/.github/workflows/tauri-test.yml b/.github/workflows/tauri-test.yml index 5dce53c462..9f47722ee2 100644 --- a/.github/workflows/tauri-test.yml +++ b/.github/workflows/tauri-test.yml @@ -17,7 +17,7 @@ env: jobs: clippy-test: - runs-on: nixos + runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 From cd4e60d5b4ca88ad5733b167e93a217fb314bfcd Mon Sep 17 00:00:00 2001 From: Gabriel Gordon-Hall Date: Thu, 30 Nov 2023 09:40:25 +0000 Subject: [PATCH 2/7] remove steps --- .github/workflows/server-test.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/server-test.yml b/.github/workflows/server-test.yml index e5030e038e..b3ad5f7fa6 100644 --- a/.github/workflows/server-test.yml +++ b/.github/workflows/server-test.yml @@ -38,12 +38,6 @@ jobs: - 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" - - - name: Load other environment changes - run: direnv export gha >> "$GITHUB_ENV" - - name: Rustfmt run: cargo --locked fmt -p bleep -- --check From 8845986a76cd4b58eaa01401dd71cead3e7408e9 Mon Sep 17 00:00:00 2001 From: Gabriel Gordon-Hall Date: Thu, 30 Nov 2023 14:23:09 +0000 Subject: [PATCH 3/7] github actions cache --- .github/workflows/build-on-pr-command.yml | 2 +- .github/workflows/build-on-pr.yml | 2 +- .github/workflows/build-on-release.yml | 2 +- .github/workflows/server-test.yml | 33 ++++++++++++----------- .github/workflows/tauri-test.yml | 6 ----- 5 files changed, 21 insertions(+), 24 deletions(-) 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 b3ad5f7fa6..3318f391d3 100644 --- a/.github/workflows/server-test.yml +++ b/.github/workflows/server-test.yml @@ -24,19 +24,25 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} - - 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- + toolchain: 1.73.0 + components: rustfmt, clippy - - name: Git LFS Pull - run: git lfs install && git lfs pull + # 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 @@ -45,7 +51,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 9f47722ee2..2809638849 100644 --- a/.github/workflows/tauri-test.yml +++ b/.github/workflows/tauri-test.yml @@ -38,12 +38,6 @@ jobs: - 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" - - - name: Load other environment changes - run: direnv export gha >> "$GITHUB_ENV" - - name: Rustfmt run: cargo --locked fmt -p bloop -- --check From e4fbd10a55900b3ac722e5cc19e4df34add65f11 Mon Sep 17 00:00:00 2001 From: Gabriel Gordon-Hall Date: Thu, 30 Nov 2023 14:58:53 +0000 Subject: [PATCH 4/7] fix clippy errors --- apps/desktop/src-tauri/src/main.rs | 13 +++++-------- server/bleep/src/agent/tools/answer.rs | 19 +++++++++++-------- server/bleep/src/cache.rs | 2 +- server/bleep/src/commits.rs | 18 ++++++++++-------- .../src/intelligence/scope_resolution.rs | 17 +++++++++-------- server/bleep/src/query/parser.rs | 1 + server/bleep/src/repo/iterator/git.rs | 2 +- server/bleep/src/semantic/execute.rs | 4 ++-- server/bleep/src/webserver/file.rs | 2 +- 9 files changed, 41 insertions(+), 37 deletions(-) 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) From efc2de29c804fbeecb6fa7033eca8f8760b5713f Mon Sep 17 00:00:00 2001 From: Gabriel Gordon-Hall Date: Thu, 30 Nov 2023 15:14:25 +0000 Subject: [PATCH 5/7] lfs --- .github/workflows/server-test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/server-test.yml b/.github/workflows/server-test.yml index 3318f391d3..e28b5530cd 100644 --- a/.github/workflows/server-test.yml +++ b/.github/workflows/server-test.yml @@ -23,6 +23,7 @@ jobs: uses: actions/checkout@v4 with: token: ${{ secrets.GITHUB_TOKEN }} + lfs: true - name: Install Rust stable uses: dtolnay/rust-toolchain@stable From 4b98f0050aa13178133814759007f342bcbe3885 Mon Sep 17 00:00:00 2001 From: Gabriel Gordon-Hall Date: Thu, 30 Nov 2023 15:36:51 +0000 Subject: [PATCH 6/7] update tauri-test --- .github/workflows/tauri-test.yml | 34 ++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/.github/workflows/tauri-test.yml b/.github/workflows/tauri-test.yml index 2809638849..96a2b1e764 100644 --- a/.github/workflows/tauri-test.yml +++ b/.github/workflows/tauri-test.yml @@ -23,20 +23,27 @@ jobs: 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- + toolchain: 1.73.0 + components: rustfmt, clippy - - name: Git LFS Pull - run: git lfs install && git lfs pull + # 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 @@ -45,7 +52,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 From 52e1514bbf2792607b1dfe2907f31db86f5c3111 Mon Sep 17 00:00:00 2001 From: Gabriel Gordon-Hall Date: Thu, 30 Nov 2023 15:43:15 +0000 Subject: [PATCH 7/7] install tauri deps --- .github/workflows/tauri-test.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/tauri-test.yml b/.github/workflows/tauri-test.yml index 96a2b1e764..9680564325 100644 --- a/.github/workflows/tauri-test.yml +++ b/.github/workflows/tauri-test.yml @@ -31,6 +31,19 @@ jobs: toolchain: 1.73.0 components: rustfmt, clippy + - 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 + # https://github.com/actions/cache/blob/main/examples.md#rust---cargo - name: Set up cargo cache uses: actions/cache@v3