diff --git a/.github/workflows/ci.generate.ts b/.github/workflows/ci.generate.ts index 17e0bae060..148fb1b26e 100755 --- a/.github/workflows/ci.generate.ts +++ b/.github/workflows/ci.generate.ts @@ -369,6 +369,14 @@ const ci = { os: Runners.ubuntu, job: "lint", profile: "debug", + }, { + os: Runners.macos, + job: "lint", + profile: "debug", + }, { + os: Runners.windows, + job: "lint", + profile: "debug", }]), }, // Always run main branch builds to completion. This allows the cache to @@ -394,7 +402,7 @@ const ci = { }, { ...submoduleStep("./tools/node_compat/node"), - if: "matrix.job == 'lint'", + if: "matrix.job == 'lint' && startsWith(matrix.os, 'ubuntu')", }, { name: "Create source tarballs (release, linux)", @@ -488,9 +496,8 @@ const ci = { "rustc --version", "cargo --version", "which dpkg && dpkg -l", - // Deno is installed when linting. - 'if [ "${{ matrix.job }}" == "lint" ]', - "then", + // Deno is installed when linting or testing. + 'if [[ "${{ matrix.job }}" == "lint" ]] || [[ "${{ matrix.job }}" == "test" ]]; then', " deno --version", "fi", // Node is installed for benchmarks. @@ -543,13 +550,14 @@ const ci = { }, { name: "test_format.js", - if: "matrix.job == 'lint'", + if: "matrix.job == 'lint' && startsWith(matrix.os, 'ubuntu')", run: "deno run --unstable --allow-write --allow-read --allow-run ./tools/format.js --check", }, { name: "Lint PR title", - if: "matrix.job == 'lint' && github.event_name == 'pull_request'", + if: + "matrix.job == 'lint' && github.event_name == 'pull_request' && startsWith(matrix.os, 'ubuntu')", env: { PR_TITLE: "${{ github.event.pull_request.title }}", }, @@ -563,7 +571,7 @@ const ci = { }, { name: "node_compat/setup.ts --check", - if: "matrix.job == 'lint'", + if: "matrix.job == 'lint' && startsWith(matrix.os, 'ubuntu')", run: "deno run --allow-write --allow-read --allow-run=git ./tools/node_compat/setup.ts --check", }, diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 16b029a852..f777026f84 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -95,6 +95,14 @@ jobs: job: lint profile: debug os_display_name: ubuntu-x86_64 + - os: macos-12 + job: lint + profile: debug + os_display_name: macos-x86_64 + - os: windows-2022 + job: lint + profile: debug + os_display_name: windows-x86_64 fail-fast: '${{ github.event_name == ''pull_request'' || (github.ref != ''refs/heads/main'' && !startsWith(github.ref, ''refs/tags/'')) }}' env: CARGO_TERM_COLOR: always @@ -128,7 +136,7 @@ jobs: if: '!(github.event_name == ''pull_request'' && matrix.skip_pr) && (matrix.wpt)' - name: Clone submodule ./tools/node_compat/node run: git submodule update --init --recursive --depth=1 -- ./tools/node_compat/node - if: '!(github.event_name == ''pull_request'' && matrix.skip_pr) && (matrix.job == ''lint'')' + if: '!(github.event_name == ''pull_request'' && matrix.skip_pr) && (matrix.job == ''lint'' && startsWith(matrix.os, ''ubuntu''))' - name: 'Create source tarballs (release, linux)' if: |- !(github.event_name == 'pull_request' && matrix.skip_pr) && (startsWith(matrix.os, 'ubuntu') && @@ -289,8 +297,7 @@ jobs: rustc --version cargo --version which dpkg && dpkg -l - if [ "${{ matrix.job }}" == "lint" ] - then + if [[ "${{ matrix.job }}" == "lint" ]] || [[ "${{ matrix.job }}" == "test" ]]; then deno --version fi if [ "${{ matrix.job }}" == "bench" ] @@ -324,10 +331,10 @@ jobs: with: cache-path: ./target - name: test_format.js - if: '!(github.event_name == ''pull_request'' && matrix.skip_pr) && (matrix.job == ''lint'')' + if: '!(github.event_name == ''pull_request'' && matrix.skip_pr) && (matrix.job == ''lint'' && startsWith(matrix.os, ''ubuntu''))' run: deno run --unstable --allow-write --allow-read --allow-run ./tools/format.js --check - name: Lint PR title - if: '!(github.event_name == ''pull_request'' && matrix.skip_pr) && (matrix.job == ''lint'' && github.event_name == ''pull_request'')' + if: '!(github.event_name == ''pull_request'' && matrix.skip_pr) && (matrix.job == ''lint'' && github.event_name == ''pull_request'' && startsWith(matrix.os, ''ubuntu''))' env: PR_TITLE: '${{ github.event.pull_request.title }}' run: deno run ./tools/verify_pr_title.js "$PR_TITLE" @@ -335,7 +342,7 @@ jobs: if: '!(github.event_name == ''pull_request'' && matrix.skip_pr) && (matrix.job == ''lint'')' run: deno run --unstable --allow-write --allow-read --allow-run ./tools/lint.js - name: node_compat/setup.ts --check - if: '!(github.event_name == ''pull_request'' && matrix.skip_pr) && (matrix.job == ''lint'')' + if: '!(github.event_name == ''pull_request'' && matrix.skip_pr) && (matrix.job == ''lint'' && startsWith(matrix.os, ''ubuntu''))' run: deno run --allow-write --allow-read --allow-run=git ./tools/node_compat/setup.ts --check - name: Build debug if: '!(github.event_name == ''pull_request'' && matrix.skip_pr) && (matrix.job == ''test'' && matrix.profile == ''debug'')' diff --git a/ext/node/ops/os.rs b/ext/node/ops/os.rs index 0a841a72ac..59bfba4b84 100644 --- a/ext/node/ops/os.rs +++ b/ext/node/ops/os.rs @@ -4,9 +4,6 @@ use crate::NodePermissions; use deno_core::error::AnyError; use deno_core::op; use deno_core::OpState; -use errno::errno; -use errno::set_errno; -use errno::Errno; #[op] pub fn op_node_os_get_priority

( @@ -54,11 +51,12 @@ where Ok(whoami::username()) } -const PRIORITY_HIGH: i32 = -14; - #[cfg(unix)] mod priority { use super::*; + use errno::errno; + use errno::set_errno; + use errno::Errno; use libc::id_t; use libc::PRIO_PROCESS; @@ -69,6 +67,8 @@ mod priority { #[allow(non_camel_case_types)] type priority_t = u32; + const PRIORITY_HIGH: i32 = -14; + // Ref: https://github.com/libuv/libuv/blob/55376b044b74db40772e8a6e24d67a8673998e02/src/unix/core.c#L1533-L1547 pub fn get_priority(pid: u32) -> Result { set_errno(Errno(0)); @@ -119,10 +119,12 @@ mod priority { const PRIORITY_BELOW_NORMAL: i32 = 10; const PRIORITY_NORMAL: i32 = 0; const PRIORITY_ABOVE_NORMAL: i32 = -7; + const PRIORITY_HIGH: i32 = -14; const PRIORITY_HIGHEST: i32 = -20; // Ported from: https://github.com/libuv/libuv/blob/a877ca2435134ef86315326ef4ef0c16bdbabf17/src/win/util.c#L1649-L1685 pub fn get_priority(pid: u32) -> Result { + // SAFETY: Windows API calls unsafe { let handle = if pid == 0 { GetCurrentProcess() @@ -150,6 +152,7 @@ mod priority { // Ported from: https://github.com/libuv/libuv/blob/a877ca2435134ef86315326ef4ef0c16bdbabf17/src/win/util.c#L1688-L1719 pub fn set_priority(pid: u32, priority: i32) -> Result<(), AnyError> { + // SAFETY: Windows API calls unsafe { let handle = if pid == 0 { GetCurrentProcess() @@ -159,6 +162,7 @@ mod priority { if handle == NULL { Err(std::io::Error::last_os_error().into()) } else { + #[allow(clippy::manual_range_contains)] let priority_class = if priority < PRIORITY_HIGHEST || priority > PRIORITY_LOW { return Err(type_error("Invalid priority"));