mirror of
https://github.com/denoland/deno.git
synced 2024-12-24 08:09:08 -05:00
ci: lint on all operating systems (#20012)
This commit is contained in:
parent
45572e329a
commit
5e89d1a0ab
3 changed files with 37 additions and 18 deletions
22
.github/workflows/ci.generate.ts
vendored
22
.github/workflows/ci.generate.ts
vendored
|
@ -369,6 +369,14 @@ const ci = {
|
||||||
os: Runners.ubuntu,
|
os: Runners.ubuntu,
|
||||||
job: "lint",
|
job: "lint",
|
||||||
profile: "debug",
|
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
|
// Always run main branch builds to completion. This allows the cache to
|
||||||
|
@ -394,7 +402,7 @@ const ci = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...submoduleStep("./tools/node_compat/node"),
|
...submoduleStep("./tools/node_compat/node"),
|
||||||
if: "matrix.job == 'lint'",
|
if: "matrix.job == 'lint' && startsWith(matrix.os, 'ubuntu')",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Create source tarballs (release, linux)",
|
name: "Create source tarballs (release, linux)",
|
||||||
|
@ -488,9 +496,8 @@ const ci = {
|
||||||
"rustc --version",
|
"rustc --version",
|
||||||
"cargo --version",
|
"cargo --version",
|
||||||
"which dpkg && dpkg -l",
|
"which dpkg && dpkg -l",
|
||||||
// Deno is installed when linting.
|
// Deno is installed when linting or testing.
|
||||||
'if [ "${{ matrix.job }}" == "lint" ]',
|
'if [[ "${{ matrix.job }}" == "lint" ]] || [[ "${{ matrix.job }}" == "test" ]]; then',
|
||||||
"then",
|
|
||||||
" deno --version",
|
" deno --version",
|
||||||
"fi",
|
"fi",
|
||||||
// Node is installed for benchmarks.
|
// Node is installed for benchmarks.
|
||||||
|
@ -543,13 +550,14 @@ const ci = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "test_format.js",
|
name: "test_format.js",
|
||||||
if: "matrix.job == 'lint'",
|
if: "matrix.job == 'lint' && startsWith(matrix.os, 'ubuntu')",
|
||||||
run:
|
run:
|
||||||
"deno run --unstable --allow-write --allow-read --allow-run ./tools/format.js --check",
|
"deno run --unstable --allow-write --allow-read --allow-run ./tools/format.js --check",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Lint PR title",
|
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: {
|
env: {
|
||||||
PR_TITLE: "${{ github.event.pull_request.title }}",
|
PR_TITLE: "${{ github.event.pull_request.title }}",
|
||||||
},
|
},
|
||||||
|
@ -563,7 +571,7 @@ const ci = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "node_compat/setup.ts --check",
|
name: "node_compat/setup.ts --check",
|
||||||
if: "matrix.job == 'lint'",
|
if: "matrix.job == 'lint' && startsWith(matrix.os, 'ubuntu')",
|
||||||
run:
|
run:
|
||||||
"deno run --allow-write --allow-read --allow-run=git ./tools/node_compat/setup.ts --check",
|
"deno run --allow-write --allow-read --allow-run=git ./tools/node_compat/setup.ts --check",
|
||||||
},
|
},
|
||||||
|
|
19
.github/workflows/ci.yml
vendored
19
.github/workflows/ci.yml
vendored
|
@ -95,6 +95,14 @@ jobs:
|
||||||
job: lint
|
job: lint
|
||||||
profile: debug
|
profile: debug
|
||||||
os_display_name: ubuntu-x86_64
|
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/'')) }}'
|
fail-fast: '${{ github.event_name == ''pull_request'' || (github.ref != ''refs/heads/main'' && !startsWith(github.ref, ''refs/tags/'')) }}'
|
||||||
env:
|
env:
|
||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
|
@ -128,7 +136,7 @@ jobs:
|
||||||
if: '!(github.event_name == ''pull_request'' && matrix.skip_pr) && (matrix.wpt)'
|
if: '!(github.event_name == ''pull_request'' && matrix.skip_pr) && (matrix.wpt)'
|
||||||
- name: Clone submodule ./tools/node_compat/node
|
- name: Clone submodule ./tools/node_compat/node
|
||||||
run: git submodule update --init --recursive --depth=1 -- ./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)'
|
- name: 'Create source tarballs (release, linux)'
|
||||||
if: |-
|
if: |-
|
||||||
!(github.event_name == 'pull_request' && matrix.skip_pr) && (startsWith(matrix.os, 'ubuntu') &&
|
!(github.event_name == 'pull_request' && matrix.skip_pr) && (startsWith(matrix.os, 'ubuntu') &&
|
||||||
|
@ -289,8 +297,7 @@ jobs:
|
||||||
rustc --version
|
rustc --version
|
||||||
cargo --version
|
cargo --version
|
||||||
which dpkg && dpkg -l
|
which dpkg && dpkg -l
|
||||||
if [ "${{ matrix.job }}" == "lint" ]
|
if [[ "${{ matrix.job }}" == "lint" ]] || [[ "${{ matrix.job }}" == "test" ]]; then
|
||||||
then
|
|
||||||
deno --version
|
deno --version
|
||||||
fi
|
fi
|
||||||
if [ "${{ matrix.job }}" == "bench" ]
|
if [ "${{ matrix.job }}" == "bench" ]
|
||||||
|
@ -324,10 +331,10 @@ jobs:
|
||||||
with:
|
with:
|
||||||
cache-path: ./target
|
cache-path: ./target
|
||||||
- name: test_format.js
|
- 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
|
run: deno run --unstable --allow-write --allow-read --allow-run ./tools/format.js --check
|
||||||
- name: Lint PR title
|
- 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:
|
env:
|
||||||
PR_TITLE: '${{ github.event.pull_request.title }}'
|
PR_TITLE: '${{ github.event.pull_request.title }}'
|
||||||
run: deno run ./tools/verify_pr_title.js "$PR_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'')'
|
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
|
run: deno run --unstable --allow-write --allow-read --allow-run ./tools/lint.js
|
||||||
- name: node_compat/setup.ts --check
|
- 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
|
run: deno run --allow-write --allow-read --allow-run=git ./tools/node_compat/setup.ts --check
|
||||||
- name: Build debug
|
- name: Build debug
|
||||||
if: '!(github.event_name == ''pull_request'' && matrix.skip_pr) && (matrix.job == ''test'' && matrix.profile == ''debug'')'
|
if: '!(github.event_name == ''pull_request'' && matrix.skip_pr) && (matrix.job == ''test'' && matrix.profile == ''debug'')'
|
||||||
|
|
|
@ -4,9 +4,6 @@ use crate::NodePermissions;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::op;
|
use deno_core::op;
|
||||||
use deno_core::OpState;
|
use deno_core::OpState;
|
||||||
use errno::errno;
|
|
||||||
use errno::set_errno;
|
|
||||||
use errno::Errno;
|
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
pub fn op_node_os_get_priority<P>(
|
pub fn op_node_os_get_priority<P>(
|
||||||
|
@ -54,11 +51,12 @@ where
|
||||||
Ok(whoami::username())
|
Ok(whoami::username())
|
||||||
}
|
}
|
||||||
|
|
||||||
const PRIORITY_HIGH: i32 = -14;
|
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
mod priority {
|
mod priority {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use errno::errno;
|
||||||
|
use errno::set_errno;
|
||||||
|
use errno::Errno;
|
||||||
use libc::id_t;
|
use libc::id_t;
|
||||||
use libc::PRIO_PROCESS;
|
use libc::PRIO_PROCESS;
|
||||||
|
|
||||||
|
@ -69,6 +67,8 @@ mod priority {
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
type priority_t = u32;
|
type priority_t = u32;
|
||||||
|
|
||||||
|
const PRIORITY_HIGH: i32 = -14;
|
||||||
|
|
||||||
// Ref: https://github.com/libuv/libuv/blob/55376b044b74db40772e8a6e24d67a8673998e02/src/unix/core.c#L1533-L1547
|
// Ref: https://github.com/libuv/libuv/blob/55376b044b74db40772e8a6e24d67a8673998e02/src/unix/core.c#L1533-L1547
|
||||||
pub fn get_priority(pid: u32) -> Result<i32, AnyError> {
|
pub fn get_priority(pid: u32) -> Result<i32, AnyError> {
|
||||||
set_errno(Errno(0));
|
set_errno(Errno(0));
|
||||||
|
@ -119,10 +119,12 @@ mod priority {
|
||||||
const PRIORITY_BELOW_NORMAL: i32 = 10;
|
const PRIORITY_BELOW_NORMAL: i32 = 10;
|
||||||
const PRIORITY_NORMAL: i32 = 0;
|
const PRIORITY_NORMAL: i32 = 0;
|
||||||
const PRIORITY_ABOVE_NORMAL: i32 = -7;
|
const PRIORITY_ABOVE_NORMAL: i32 = -7;
|
||||||
|
const PRIORITY_HIGH: i32 = -14;
|
||||||
const PRIORITY_HIGHEST: i32 = -20;
|
const PRIORITY_HIGHEST: i32 = -20;
|
||||||
|
|
||||||
// Ported from: https://github.com/libuv/libuv/blob/a877ca2435134ef86315326ef4ef0c16bdbabf17/src/win/util.c#L1649-L1685
|
// Ported from: https://github.com/libuv/libuv/blob/a877ca2435134ef86315326ef4ef0c16bdbabf17/src/win/util.c#L1649-L1685
|
||||||
pub fn get_priority(pid: u32) -> Result<i32, AnyError> {
|
pub fn get_priority(pid: u32) -> Result<i32, AnyError> {
|
||||||
|
// SAFETY: Windows API calls
|
||||||
unsafe {
|
unsafe {
|
||||||
let handle = if pid == 0 {
|
let handle = if pid == 0 {
|
||||||
GetCurrentProcess()
|
GetCurrentProcess()
|
||||||
|
@ -150,6 +152,7 @@ mod priority {
|
||||||
|
|
||||||
// Ported from: https://github.com/libuv/libuv/blob/a877ca2435134ef86315326ef4ef0c16bdbabf17/src/win/util.c#L1688-L1719
|
// 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> {
|
pub fn set_priority(pid: u32, priority: i32) -> Result<(), AnyError> {
|
||||||
|
// SAFETY: Windows API calls
|
||||||
unsafe {
|
unsafe {
|
||||||
let handle = if pid == 0 {
|
let handle = if pid == 0 {
|
||||||
GetCurrentProcess()
|
GetCurrentProcess()
|
||||||
|
@ -159,6 +162,7 @@ mod priority {
|
||||||
if handle == NULL {
|
if handle == NULL {
|
||||||
Err(std::io::Error::last_os_error().into())
|
Err(std::io::Error::last_os_error().into())
|
||||||
} else {
|
} else {
|
||||||
|
#[allow(clippy::manual_range_contains)]
|
||||||
let priority_class =
|
let priority_class =
|
||||||
if priority < PRIORITY_HIGHEST || priority > PRIORITY_LOW {
|
if priority < PRIORITY_HIGHEST || priority > PRIORITY_LOW {
|
||||||
return Err(type_error("Invalid priority"));
|
return Err(type_error("Invalid priority"));
|
||||||
|
|
Loading…
Reference in a new issue