From 0f0d5d5726cae330238a545e26c7910f470373a0 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Mon, 23 Jan 2023 12:43:19 -0800 Subject: [PATCH] Added cargo-about auto-install and CI steps --- .github/workflows/ci.yml | 10 ++++++++-- .gitignore | 1 + assets/licenses.md | 1 - crates/zed/src/zed.rs | 6 ++++-- script/generate-licenses | 9 +++++++-- script/licenses/zed-licenses.toml | 2 +- 6 files changed, 21 insertions(+), 8 deletions(-) delete mode 100644 assets/licenses.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7072a3fe94..fce5717ca9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,16 +41,19 @@ jobs: with: clean: false submodules: 'recursive' - + - name: Run tests run: cargo test --workspace --no-fail-fast - + - name: Build collab run: cargo build -p collab - name: Build other binaries run: cargo build --workspace --bins --all-features + - name: Generate license file + run: script/generate-licenses + bundle: name: Bundle app runs-on: @@ -109,6 +112,9 @@ jobs: exit 1 fi + - name: Generate license file + run: script/generate-licenses + - name: Create app bundle run: script/bundle diff --git a/.gitignore b/.gitignore index 356f4d97cd..8bca2eafac 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ /assets/themes/*.json /assets/themes/Internal/*.json /assets/themes/Experiments/*.json +/assets/licenses.md **/venv .build Packages diff --git a/assets/licenses.md b/assets/licenses.md deleted file mode 100644 index 5d70eab88b..0000000000 --- a/assets/licenses.md +++ /dev/null @@ -1 +0,0 @@ -Place holder \ No newline at end of file diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index 30f5bef53b..53bc9d5abc 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -35,7 +35,7 @@ use search::{BufferSearchBar, ProjectSearchBar}; use serde::Deserialize; use serde_json::to_string_pretty; use settings::{keymap_file_json_schema, settings_file_json_schema, Settings}; -use std::{env, path::Path, str, sync::Arc}; +use std::{borrow::Cow, env, path::Path, str, sync::Arc}; use system_specs::SystemSpecs; use util::{channel::ReleaseChannel, paths, ResultExt}; pub use workspace; @@ -684,7 +684,9 @@ fn open_bundled_file( .with_local_workspace(&app_state, cx, |workspace, cx| { let project = workspace.project().clone(); let buffer = project.update(cx, |project, cx| { - let text = Assets::get(asset_path).unwrap().data; + let text = Assets::get(asset_path) + .map(|f| f.data) + .unwrap_or_else(|| Cow::Borrowed(b"File not found")); let text = str::from_utf8(text.as_ref()).unwrap(); project .create_buffer(text, project.languages().get_language(language), cx) diff --git a/script/generate-licenses b/script/generate-licenses index 31febf263f..e1a917292c 100755 --- a/script/generate-licenses +++ b/script/generate-licenses @@ -1,5 +1,10 @@ #!/bin/bash -cargo about generate --workspace -o assets/licenses.md -c script/licenses/zed-licenses.toml script/licenses/template.hbs.md + +set -e + +[[ "$(cargo about --version)" == "cargo-about 0.5.2" ]] || cargo install cargo-about --locked --git https://github.com/zed-industries/cargo-about --branch error-code-on-warn + +cargo about generate --fail-on-missing-license -o assets/licenses.md -c script/licenses/zed-licenses.toml script/licenses/template.hbs.md # cargo about automatically html-escapes all output, so we need to undo it here: sed -i '' 's/"/"/g' assets/licenses.md @@ -7,4 +12,4 @@ sed -i '' 's/'/'\''/g' assets/licenses.md # `'\''` ends the string, appends sed -i '' 's/=/=/g' assets/licenses.md sed -i '' 's/`/`/g' assets/licenses.md sed -i '' 's/<//g' assets/licenses.md +sed -i '' 's/>/>/g' assets/licenses.md \ No newline at end of file diff --git a/script/licenses/zed-licenses.toml b/script/licenses/zed-licenses.toml index 2e294878d7..d338e7ab0b 100644 --- a/script/licenses/zed-licenses.toml +++ b/script/licenses/zed-licenses.toml @@ -34,4 +34,4 @@ checksum = '5b698ca13897be3afdb7174256fa1574f8c6892b8bea1a66dd6469d3fe27885a' license = "BSD-3-Clause" [[fuchsia-cprng.clarify.files]] path = 'LICENSE' -checksum = '03b114f53e6587a398931762ee11e2395bfdba252a329940e2c8c9e81813845b' \ No newline at end of file +checksum = '03b114f53e6587a398931762ee11e2395bfdba252a329940e2c8c9e81813845b'