Skip to content

Commit

Permalink
Merge pull request #710 from denoland/main
Browse files Browse the repository at this point in the history
Create a new pull request by comparing changes across two branches
  • Loading branch information
GulajavaMinistudio authored Jan 7, 2025
2 parents 3eba60b + b7fb5a5 commit ed8e18b
Show file tree
Hide file tree
Showing 44 changed files with 2,301 additions and 1,789 deletions.
30 changes: 7 additions & 23 deletions .github/workflows/ci.generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ const ci = {
needs: ["pre_build"],
if: "${{ needs.pre_build.outputs.skip_build != 'true' }}",
"runs-on": "${{ matrix.runner }}",
"timeout-minutes": 180,
"timeout-minutes": 240,
defaults: {
run: {
// GH actions does not fail fast by default on
Expand Down Expand Up @@ -716,19 +716,6 @@ const ci = {
"df -h",
].join("\n"),
},
{
name: "Build denort release",
if: [
"matrix.job == 'test' &&",
"matrix.profile == 'release' &&",
"github.repository == 'denoland/deno'",
].join("\n"),
run: [
"df -h",
"cargo build --profile=release-slim --locked --bin denort",
"df -h",
].join("\n"),
},
{
// Run a minimal check to ensure that binary is not corrupted, regardless
// of our build mode
Expand Down Expand Up @@ -775,11 +762,10 @@ const ci = {
"cd target/release",
"zip -r deno-${{ matrix.arch }}-unknown-linux-gnu.zip deno",
"shasum -a 256 deno-${{ matrix.arch }}-unknown-linux-gnu.zip > deno-${{ matrix.arch }}-unknown-linux-gnu.zip.sha256sum",
"./deno types > lib.deno.d.ts",
"cd ../release-slim",
"zip -r ../release/denort-${{ matrix.arch }}-unknown-linux-gnu.zip denort",
"cd ../release",
"strip denort",
"zip -r denort-${{ matrix.arch }}-unknown-linux-gnu.zip denort",
"shasum -a 256 denort-${{ matrix.arch }}-unknown-linux-gnu.zip > denort-${{ matrix.arch }}-unknown-linux-gnu.zip.sha256sum",
"./deno types > lib.deno.d.ts",
].join("\n"),
},
{
Expand All @@ -804,9 +790,8 @@ const ci = {
"cd target/release",
"zip -r deno-${{ matrix.arch }}-apple-darwin.zip deno",
"shasum -a 256 deno-${{ matrix.arch }}-apple-darwin.zip > deno-${{ matrix.arch }}-apple-darwin.zip.sha256sum",
"cd ../release-slim",
"zip -r ../release/denort-${{ matrix.arch }}-apple-darwin.zip denort",
"cd ../release",
"strip denort",
"zip -r denort-${{ matrix.arch }}-apple-darwin.zip denort",
"shasum -a 256 denort-${{ matrix.arch }}-apple-darwin.zip > denort-${{ matrix.arch }}-apple-darwin.zip.sha256sum",
]
.join("\n"),
Expand All @@ -823,8 +808,7 @@ const ci = {
run: [
"Compress-Archive -CompressionLevel Optimal -Force -Path target/release/deno.exe -DestinationPath target/release/deno-${{ matrix.arch }}-pc-windows-msvc.zip",
"Get-FileHash target/release/deno-${{ matrix.arch }}-pc-windows-msvc.zip -Algorithm SHA256 | Format-List > target/release/deno-${{ matrix.arch }}-pc-windows-msvc.zip.sha256sum",

"Compress-Archive -CompressionLevel Optimal -Force -Path target/release-slim/denort.exe -DestinationPath target/release/denort-${{ matrix.arch }}-pc-windows-msvc.zip",
"Compress-Archive -CompressionLevel Optimal -Force -Path target/release/denort.exe -DestinationPath target/release/denort-${{ matrix.arch }}-pc-windows-msvc.zip",
"Get-FileHash target/release/denort-${{ matrix.arch }}-pc-windows-msvc.zip -Algorithm SHA256 | Format-List > target/release/denort-${{ matrix.arch }}-pc-windows-msvc.zip.sha256sum",
].join("\n"),
},
Expand Down
25 changes: 7 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
- pre_build
if: '${{ needs.pre_build.outputs.skip_build != ''true'' }}'
runs-on: '${{ matrix.runner }}'
timeout-minutes: 180
timeout-minutes: 240
defaults:
run:
shell: bash
Expand Down Expand Up @@ -419,15 +419,6 @@ jobs:
df -h
cargo build --release --locked --all-targets
df -h
- name: Build denort release
if: |-
!(matrix.skip) && (matrix.job == 'test' &&
matrix.profile == 'release' &&
github.repository == 'denoland/deno')
run: |-
df -h
cargo build --profile=release-slim --locked --bin denort
df -h
- name: Check deno binary
if: '!(matrix.skip) && (matrix.job == ''test'')'
run: 'target/${{ matrix.profile }}/deno eval "console.log(1+2)" | grep 3'
Expand Down Expand Up @@ -457,11 +448,10 @@ jobs:
cd target/release
zip -r deno-${{ matrix.arch }}-unknown-linux-gnu.zip deno
shasum -a 256 deno-${{ matrix.arch }}-unknown-linux-gnu.zip > deno-${{ matrix.arch }}-unknown-linux-gnu.zip.sha256sum
./deno types > lib.deno.d.ts
cd ../release-slim
zip -r ../release/denort-${{ matrix.arch }}-unknown-linux-gnu.zip denort
cd ../release
strip denort
zip -r denort-${{ matrix.arch }}-unknown-linux-gnu.zip denort
shasum -a 256 denort-${{ matrix.arch }}-unknown-linux-gnu.zip > denort-${{ matrix.arch }}-unknown-linux-gnu.zip.sha256sum
./deno types > lib.deno.d.ts
- name: Pre-release (mac)
if: |-
!(matrix.skip) && (matrix.os == 'macos' &&
Expand All @@ -477,9 +467,8 @@ jobs:
cd target/release
zip -r deno-${{ matrix.arch }}-apple-darwin.zip deno
shasum -a 256 deno-${{ matrix.arch }}-apple-darwin.zip > deno-${{ matrix.arch }}-apple-darwin.zip.sha256sum
cd ../release-slim
zip -r ../release/denort-${{ matrix.arch }}-apple-darwin.zip denort
cd ../release
strip denort
zip -r denort-${{ matrix.arch }}-apple-darwin.zip denort
shasum -a 256 denort-${{ matrix.arch }}-apple-darwin.zip > denort-${{ matrix.arch }}-apple-darwin.zip.sha256sum
- name: Pre-release (windows)
if: |-
Expand All @@ -491,7 +480,7 @@ jobs:
run: |-
Compress-Archive -CompressionLevel Optimal -Force -Path target/release/deno.exe -DestinationPath target/release/deno-${{ matrix.arch }}-pc-windows-msvc.zip
Get-FileHash target/release/deno-${{ matrix.arch }}-pc-windows-msvc.zip -Algorithm SHA256 | Format-List > target/release/deno-${{ matrix.arch }}-pc-windows-msvc.zip.sha256sum
Compress-Archive -CompressionLevel Optimal -Force -Path target/release-slim/denort.exe -DestinationPath target/release/denort-${{ matrix.arch }}-pc-windows-msvc.zip
Compress-Archive -CompressionLevel Optimal -Force -Path target/release/denort.exe -DestinationPath target/release/denort-${{ matrix.arch }}-pc-windows-msvc.zip
Get-FileHash target/release/denort-${{ matrix.arch }}-pc-windows-msvc.zip -Algorithm SHA256 | Format-List > target/release/denort-${{ matrix.arch }}-pc-windows-msvc.zip.sha256sum
- name: Upload canary to dl.deno.land
if: |-
Expand Down
5 changes: 0 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,6 @@ incremental = true
lto = true
opt-level = 'z' # Optimize for size

[profile.release-slim]
inherits = "release"
panic = "abort"
strip = "symbols"

# Build release with debug symbols: cargo build --profile=release-with-debug
[profile.release-with-debug]
inherits = "release"
Expand Down
4 changes: 2 additions & 2 deletions cli/cache/cache_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ impl CacheDBHash {
Self(hash)
}

pub fn from_source(source: impl std::hash::Hash) -> Self {
pub fn from_hashable(hashable: impl std::hash::Hash) -> Self {
Self::new(
// always write in the deno version just in case
// the clearing on deno version change doesn't work
FastInsecureHasher::new_deno_versioned()
.write_hashable(source)
.write_hashable(hashable)
.finish(),
)
}
Expand Down
21 changes: 12 additions & 9 deletions cli/cache/incremental.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ pub static INCREMENTAL_CACHE_DB: CacheDBConfiguration = CacheDBConfiguration {
pub struct IncrementalCache(IncrementalCacheInner);

impl IncrementalCache {
pub fn new<TState: std::hash::Hash>(
pub fn new(
db: CacheDB,
state: &TState,
state_hash: CacheDBHash,
initial_file_paths: &[PathBuf],
) -> Self {
IncrementalCache(IncrementalCacheInner::new(db, state, initial_file_paths))
IncrementalCache(IncrementalCacheInner::new(
db,
state_hash,
initial_file_paths,
))
}

pub fn is_file_same(&self, file_path: &Path, file_text: &str) -> bool {
Expand Down Expand Up @@ -67,12 +71,11 @@ struct IncrementalCacheInner {
}

impl IncrementalCacheInner {
pub fn new<TState: std::hash::Hash>(
pub fn new(
db: CacheDB,
state: &TState,
state_hash: CacheDBHash,
initial_file_paths: &[PathBuf],
) -> Self {
let state_hash = CacheDBHash::from_source(state);
let sql_cache = SqlIncrementalCache::new(db, state_hash);
Self::from_sql_incremental_cache(sql_cache, initial_file_paths)
}
Expand Down Expand Up @@ -112,13 +115,13 @@ impl IncrementalCacheInner {

pub fn is_file_same(&self, file_path: &Path, file_text: &str) -> bool {
match self.previous_hashes.get(file_path) {
Some(hash) => *hash == CacheDBHash::from_source(file_text),
Some(hash) => *hash == CacheDBHash::from_hashable(file_text),
None => false,
}
}

pub fn update_file(&self, file_path: &Path, file_text: &str) {
let hash = CacheDBHash::from_source(file_text);
let hash = CacheDBHash::from_hashable(file_text);
if let Some(previous_hash) = self.previous_hashes.get(file_path) {
if *previous_hash == hash {
return; // do not bother updating the db file because nothing has changed
Expand Down Expand Up @@ -262,7 +265,7 @@ mod test {
let sql_cache = SqlIncrementalCache::new(conn, CacheDBHash::new(1));
let file_path = PathBuf::from("/mod.ts");
let file_text = "test";
let file_hash = CacheDBHash::from_source(file_text);
let file_hash = CacheDBHash::from_hashable(file_text);
sql_cache.set_source_hash(&file_path, file_hash).unwrap();
let cache = IncrementalCacheInner::from_sql_incremental_cache(
sql_cache,
Expand Down
2 changes: 1 addition & 1 deletion cli/cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ impl Loader for FetchCacher {
module_info: &deno_graph::ModuleInfo,
) {
log::debug!("Caching module info for {}", specifier);
let source_hash = CacheDBHash::from_source(source);
let source_hash = CacheDBHash::from_hashable(source);
let result = self.module_info_cache.set_module_info(
specifier,
media_type,
Expand Down
4 changes: 2 additions & 2 deletions cli/cache/module_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ impl<'a> ModuleInfoCacheModuleAnalyzer<'a> {
source: &Arc<str>,
) -> Result<ModuleInfo, deno_ast::ParseDiagnostic> {
// attempt to load from the cache
let source_hash = CacheDBHash::from_source(source);
let source_hash = CacheDBHash::from_hashable(source);
if let Some(info) =
self.load_cached_module_info(specifier, media_type, source_hash)
{
Expand Down Expand Up @@ -228,7 +228,7 @@ impl<'a> deno_graph::ModuleAnalyzer for ModuleInfoCacheModuleAnalyzer<'a> {
media_type: MediaType,
) -> Result<ModuleInfo, deno_ast::ParseDiagnostic> {
// attempt to load from the cache
let source_hash = CacheDBHash::from_source(&source);
let source_hash = CacheDBHash::from_hashable(&source);
if let Some(info) =
self.load_cached_module_info(specifier, media_type, source_hash)
{
Expand Down
5 changes: 3 additions & 2 deletions cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,9 @@ fn resolve_flags_and_init(
}
};

deno_telemetry::init(crate::args::otel_runtime_config())?;
util::logger::init(flags.log_level, Some(flags.otel_config()));
let otel_config = flags.otel_config();
deno_telemetry::init(crate::args::otel_runtime_config(), &otel_config)?;
util::logger::init(flags.log_level, Some(otel_config));

// TODO(bartlomieju): remove in Deno v2.5 and hard error then.
if flags.unstable_config.legacy_flag_enabled {
Expand Down
5 changes: 4 additions & 1 deletion cli/mainrt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ fn main() {
let future = async move {
match standalone {
Ok(Some(data)) => {
deno_telemetry::init(crate::args::otel_runtime_config())?;
deno_telemetry::init(
crate::args::otel_runtime_config(),
&data.metadata.otel_config,
)?;
util::logger::init(
data.metadata.log_level,
Some(data.metadata.otel_config.clone()),
Expand Down
2 changes: 1 addition & 1 deletion cli/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl CliCjsCodeAnalyzer {
specifier: &ModuleSpecifier,
source: &str,
) -> Result<CliCjsAnalysis, AnyError> {
let source_hash = CacheDBHash::from_source(source);
let source_hash = CacheDBHash::from_hashable(source);
if let Some(analysis) =
self.cache.get_cjs_analysis(specifier.as_str(), source_hash)
{
Expand Down
3 changes: 2 additions & 1 deletion cli/tools/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ use crate::args::FmtOptions;
use crate::args::FmtOptionsConfig;
use crate::args::ProseWrap;
use crate::args::UnstableFmtOptions;
use crate::cache::CacheDBHash;
use crate::cache::Caches;
use crate::cache::IncrementalCache;
use crate::colors;
Expand Down Expand Up @@ -202,7 +203,7 @@ async fn format_files(
let paths = paths_with_options.paths;
let incremental_cache = Arc::new(IncrementalCache::new(
caches.fmt_incremental_cache_db(),
&(&fmt_options.options, &fmt_options.unstable), // cache key
CacheDBHash::from_hashable((&fmt_options.options, &fmt_options.unstable)),
&paths,
));
formatter
Expand Down
3 changes: 2 additions & 1 deletion cli/tools/lint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ use crate::args::Flags;
use crate::args::LintFlags;
use crate::args::LintOptions;
use crate::args::WorkspaceLintOptions;
use crate::cache::CacheDBHash;
use crate::cache::Caches;
use crate::cache::IncrementalCache;
use crate::colors;
Expand Down Expand Up @@ -291,7 +292,7 @@ impl WorkspaceLinter {
lint_rules.incremental_cache_state().map(|state| {
Arc::new(IncrementalCache::new(
self.caches.lint_incremental_cache_db(),
&state,
CacheDBHash::from_hashable(&state),
&paths,
))
});
Expand Down
42 changes: 32 additions & 10 deletions cli/tsc/dts/lib.deno.unstable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1268,16 +1268,15 @@ declare namespace Deno {
* OpenTelemetry API. This is done using the official OpenTelemetry package
* for JavaScript:
* [`npm:@opentelemetry/api`](https://opentelemetry.io/docs/languages/js/).
* Deno integrates with this package to provide trace context propagation
* between native Deno APIs (like `Deno.serve` or `fetch`) and custom user
* code. Deno also provides APIs that allow exporting custom telemetry data
* via the same OTLP channel used by the Deno runtime. This is done using the
* [`jsr:@deno/otel`](https://jsr.io/@deno/otel) package.
* Deno integrates with this package to provide tracing, metrics, and trace
* context propagation between native Deno APIs (like `Deno.serve` or `fetch`)
* and custom user code. Deno automatically registers the providers with the
* OpenTelemetry API, so users can start creating custom traces, metrics, and
* logs without any additional setup.
*
* @example Using OpenTelemetry API to create custom traces
* ```ts,ignore
* import { trace } from "npm:@opentelemetry/api@1";
* import "jsr:@deno/[email protected]/register";
*
* const tracer = trace.getTracer("example-tracer");
*
Expand All @@ -1301,20 +1300,43 @@ declare namespace Deno {
*/
export namespace telemetry {
/**
* A SpanExporter compatible with OpenTelemetry.js
* https://open-telemetry.github.io/opentelemetry-js/interfaces/_opentelemetry_sdk_trace_base.SpanExporter.html
* A TracerProvider compatible with OpenTelemetry.js
* https://open-telemetry.github.io/opentelemetry-js/interfaces/_opentelemetry_api.TracerProvider.html
*
* This is a singleton object that implements the OpenTelemetry
* TracerProvider interface.
*
* @category Telemetry
* @experimental
*/
export class SpanExporter {}
// deno-lint-ignore no-explicit-any
export const tracerProvider: any;

/**
* A ContextManager compatible with OpenTelemetry.js
* https://open-telemetry.github.io/opentelemetry-js/interfaces/_opentelemetry_api.ContextManager.html
*
* This is a singleton object that implements the OpenTelemetry
* ContextManager interface.
*
* @category Telemetry
* @experimental
*/
// deno-lint-ignore no-explicit-any
export const contextManager: any;

/**
* A MeterProvider compatible with OpenTelemetry.js
* https://open-telemetry.github.io/opentelemetry-js/interfaces/_opentelemetry_api.MeterProvider.html
*
* This is a singleton object that implements the OpenTelemetry
* MeterProvider interface.
*
* @category Telemetry
* @experimental
*/
export class ContextManager {}
// deno-lint-ignore no-explicit-any
export const meterProvider: any;

export {}; // only export exports
}
Expand Down
Loading

0 comments on commit ed8e18b

Please sign in to comment.