Skip to content

Commit

Permalink
fix(crc32,denolint): upgrade rust toolchain (#787)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Feb 14, 2024
1 parent ab1f977 commit 5586e4f
Show file tree
Hide file tree
Showing 20 changed files with 140 additions and 112 deletions.
25 changes: 25 additions & 0 deletions .github/actions/setup-rust/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: 'Setup Rust'
description: 'Set up the Rust toolchain'
inputs:
targets:
description: 'The target to install'
required: true
components:
description: 'The components to install'
required: false
runs:
using: 'composite'
steps:
- name: Print rustup toolchain version
shell: bash
id: rustup-version
run: |
export RUST_TOOLCHAIN_VERSION="$(grep 'channel' rust-toolchain.toml | head -1 | awk -F '"' '{print $2}')"
echo "Rust toolchain version: $RUST_TOOLCHAIN_VERSION"
echo "RUST_TOOLCHAIN_VERSION=$RUST_TOOLCHAIN_VERSION" >> "$GITHUB_OUTPUT"
- name: Install
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ inputs.targets }}
toolchain: ${{ steps.rustup-version.outputs.RUST_TOOLCHAIN_VERSION }}
components: ${{ inputs.components }}
38 changes: 35 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,37 @@ on:
pull_request:

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install
uses: ./.github/actions/setup-rust
with:
targets: x86_64-unknown-linux-gnu
components: rustfmt, clippy

- name: 'Install dependencies'
run: yarn install --mode=skip-build

- name: ESLint
run: yarn lint

- name: TypeCheck
run: yarn typecheck

- name: Cargo fmt
run: cargo fmt -- --check

- name: Clippy
run: cargo clippy
build:
strategy:
fail-fast: false
Expand Down Expand Up @@ -87,9 +118,8 @@ jobs:
cache: yarn

- name: Install
uses: dtolnay/rust-toolchain@stable
uses: ./.github/actions/setup-rust
with:
toolchain: nightly-2023-12-23
targets: ${{ matrix.settings.target }}

- name: Cache cargo registry
Expand Down Expand Up @@ -175,7 +205,8 @@ jobs:
sudo pkg install -y -f curl node libnghttp2 npm
sudo npm install -g yarn --ignore-scripts
curl https://sh.rustup.rs -sSf --output rustup.sh
sh rustup.sh -y --default-toolchain nightly-2023-12-23
export RUST_TOOLCHAIN_VERSION="$(grep 'channel' rust-toolchain.toml | head -1 | awk -F '"' '{print $2}')"
sh rustup.sh -y --default-toolchain "${RUST_TOOLCHAIN_VERSION}"
source "$HOME/.cargo/env"
echo "~~~~ rustc --version ~~~~"
rustc --version
Expand Down Expand Up @@ -570,6 +601,7 @@ jobs:
name: Publish
runs-on: ubuntu-latest
needs:
- lint
- build-freebsd
- test-linux-x64-gnu-binding
- test-linux-x64-centos-7
Expand Down
42 changes: 0 additions & 42 deletions .github/workflows/lint.yaml

This file was deleted.

2 changes: 0 additions & 2 deletions packages/argon2/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate napi_build;

fn main() {
napi_build::setup();
}
24 changes: 6 additions & 18 deletions packages/bcrypt/binding.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,11 @@ export function genSalt(round: number, version?: '2a' | '2x' | '2y' | '2b', sign

export function genSaltSync(round: number, version?: '2a' | '2x' | '2y' | '2b'): string

export function hash(
input: string | Buffer,
cost?: number | undefined | null,
salt?: Buffer | undefined | null,
signal?: AbortSignal | undefined | null,
): Promise<string>

export function hashSync(
input: string | Buffer,
cost?: number | undefined | null,
salt?: Buffer | undefined | null,
): string

export function verify(
password: string | Buffer,
hash: string | Buffer,
signal?: AbortSignal | undefined | null,
): Promise<boolean>
export function hash(input: string | Buffer, cost?: number | undefined | null, salt?: Buffer | undefined | null, signal?: AbortSignal | undefined | null): Promise<string>

export function hashSync(input: string | Buffer, cost?: number | undefined | null, salt?: Buffer | undefined | null): string

export function verify(password: string | Buffer, hash: string | Buffer, signal?: AbortSignal | undefined | null): Promise<boolean>

export function verifySync(input: string | Buffer, hash: string | Buffer): boolean

48 changes: 36 additions & 12 deletions packages/bcrypt/binding.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ switch (platform) {
case 'win32':
switch (arch) {
case 'x64':
localFileExisted = existsSync(join(__dirname, 'bcrypt.win32-x64-msvc.node'))
localFileExisted = existsSync(
join(__dirname, 'bcrypt.win32-x64-msvc.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./bcrypt.win32-x64-msvc.node')
Expand All @@ -106,7 +108,9 @@ switch (platform) {
}
break
case 'ia32':
localFileExisted = existsSync(join(__dirname, 'bcrypt.win32-ia32-msvc.node'))
localFileExisted = existsSync(
join(__dirname, 'bcrypt.win32-ia32-msvc.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./bcrypt.win32-ia32-msvc.node')
Expand All @@ -118,7 +122,9 @@ switch (platform) {
}
break
case 'arm64':
localFileExisted = existsSync(join(__dirname, 'bcrypt.win32-arm64-msvc.node'))
localFileExisted = existsSync(
join(__dirname, 'bcrypt.win32-arm64-msvc.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./bcrypt.win32-arm64-msvc.node')
Expand Down Expand Up @@ -157,7 +163,9 @@ switch (platform) {
}
break
case 'arm64':
localFileExisted = existsSync(join(__dirname, 'bcrypt.darwin-arm64.node'))
localFileExisted = existsSync(
join(__dirname, 'bcrypt.darwin-arm64.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./bcrypt.darwin-arm64.node')
Expand Down Expand Up @@ -191,7 +199,9 @@ switch (platform) {
switch (arch) {
case 'x64':
if (isMusl()) {
localFileExisted = existsSync(join(__dirname, 'bcrypt.linux-x64-musl.node'))
localFileExisted = existsSync(
join(__dirname, 'bcrypt.linux-x64-musl.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./bcrypt.linux-x64-musl.node')
Expand All @@ -202,7 +212,9 @@ switch (platform) {
loadError = e
}
} else {
localFileExisted = existsSync(join(__dirname, 'bcrypt.linux-x64-gnu.node'))
localFileExisted = existsSync(
join(__dirname, 'bcrypt.linux-x64-gnu.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./bcrypt.linux-x64-gnu.node')
Expand All @@ -216,7 +228,9 @@ switch (platform) {
break
case 'arm64':
if (isMusl()) {
localFileExisted = existsSync(join(__dirname, 'bcrypt.linux-arm64-musl.node'))
localFileExisted = existsSync(
join(__dirname, 'bcrypt.linux-arm64-musl.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./bcrypt.linux-arm64-musl.node')
Expand All @@ -227,7 +241,9 @@ switch (platform) {
loadError = e
}
} else {
localFileExisted = existsSync(join(__dirname, 'bcrypt.linux-arm64-gnu.node'))
localFileExisted = existsSync(
join(__dirname, 'bcrypt.linux-arm64-gnu.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./bcrypt.linux-arm64-gnu.node')
Expand All @@ -240,7 +256,9 @@ switch (platform) {
}
break
case 'arm':
localFileExisted = existsSync(join(__dirname, 'bcrypt.linux-arm-gnueabihf.node'))
localFileExisted = existsSync(
join(__dirname, 'bcrypt.linux-arm-gnueabihf.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./bcrypt.linux-arm-gnueabihf.node')
Expand All @@ -253,7 +271,9 @@ switch (platform) {
break
case 'riscv64':
if (isMusl()) {
localFileExisted = existsSync(join(__dirname, 'bcrypt.linux-riscv64-musl.node'))
localFileExisted = existsSync(
join(__dirname, 'bcrypt.linux-riscv64-musl.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./bcrypt.linux-riscv64-musl.node')
Expand All @@ -264,7 +284,9 @@ switch (platform) {
loadError = e
}
} else {
localFileExisted = existsSync(join(__dirname, 'bcrypt.linux-riscv64-gnu.node'))
localFileExisted = existsSync(
join(__dirname, 'bcrypt.linux-riscv64-gnu.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./bcrypt.linux-riscv64-gnu.node')
Expand All @@ -277,7 +299,9 @@ switch (platform) {
}
break
case 's390x':
localFileExisted = existsSync(join(__dirname, 'bcrypt.linux-s390x-gnu.node'))
localFileExisted = existsSync(
join(__dirname, 'bcrypt.linux-s390x-gnu.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./bcrypt.linux-s390x-gnu.node')
Expand Down
2 changes: 0 additions & 2 deletions packages/bcrypt/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate napi_build;

fn main() {
napi_build::setup();
}
2 changes: 1 addition & 1 deletion packages/crc32/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ crate-type = ["cdylib"]

[dependencies]
crc32c = { version = "0.6" }
crc32fast = { version = "1.3", features = ["nightly"] }
crc32fast = { version = "1.4", features = ["nightly"] }
global_alloc = { path = "../../crates/alloc" }
napi = { version = "2", default-features = false, features = ["napi3"] }
napi-derive = { version = "2" }
Expand Down
7 changes: 4 additions & 3 deletions packages/deno-lint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ crate-type = ["cdylib"]
[dependencies]
annotate-snippets = { version = "0.10" }
anyhow = "1"
deno_ast = "=1.0.1"
deno_lint = "=0.55.2"
deno_ast = "=0.33.2"
deno_lint = "=0.56.0"
env_logger = "0.11"
global_alloc = { path = "../../crates/alloc" }
globwalk = "0.9"
ignore = "0.4"
miette = { version = "5", features = ["fancy-no-backtrace"] }
miette = { version = "7", features = ["fancy-no-backtrace"] }
napi = { version = "2", default-features = false, features = ["napi3"] }
napi-derive = { version = "2" }
serde = "1"
serde_json = "1"
url = "2.5"

[build-dependencies]
napi-build = "2"
2 changes: 0 additions & 2 deletions packages/deno-lint/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate napi_build;

fn main() {
napi_build::setup();
}
17 changes: 10 additions & 7 deletions packages/deno-lint/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,19 @@ pub fn display_diagnostics(
.collect()
}

#[derive(Debug)]
struct MietteDiagnostic<'a> {
source_code: &'a MietteSourceCode<'a>,
lint_diagnostic: &'a LintDiagnostic,
}

impl std::error::Error for MietteDiagnostic<'_> {}

impl std::fmt::Debug for MietteDiagnostic<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&self.lint_diagnostic.message)
}
}

impl Display for MietteDiagnostic<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&self.lint_diagnostic.message)
Expand All @@ -62,10 +67,9 @@ impl miette::Diagnostic for MietteDiagnostic<'_> {
}

fn labels(&self) -> Option<Box<dyn Iterator<Item = miette::LabeledSpan> + '_>> {
let len =
self.lint_diagnostic.range.end.byte_index - self.lint_diagnostic.range.start.byte_index;
let start = miette::SourceOffset::from(self.lint_diagnostic.range.start.byte_index);
let len = miette::SourceOffset::from(len);
let len = self.lint_diagnostic.range.end - self.lint_diagnostic.range.start;
let start =
miette::SourceOffset::from(self.lint_diagnostic.range.start.as_byte_pos().0 as usize);
let span = miette::SourceSpan::new(start, len);
let text = self
.lint_diagnostic
Expand Down Expand Up @@ -114,8 +118,7 @@ impl miette::SourceCode for MietteSourceCode<'_> {
let byte_range = range.as_byte_range(start_pos);
let name = Some(self.filename.to_string());
let start = miette::SourceOffset::from(byte_range.start);
let len = miette::SourceOffset::from(byte_range.len());
let span = miette::SourceSpan::new(start, len);
let span = miette::SourceSpan::new(start, byte_range.len());

Ok(Box::new(SpanContentsImpl {
data: src_text,
Expand Down

0 comments on commit 5586e4f

Please sign in to comment.