1
0
Fork 0
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:
David Sherret 2023-08-01 16:08:41 -04:00 committed by GitHub
parent 45572e329a
commit 5e89d1a0ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 18 deletions

View file

@ -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",
},

View file

@ -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'')'

View file

@ -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<P>(
@ -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<i32, AnyError> {
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<i32, AnyError> {
// 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"));