Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github actions for Rust shows Node.js warning (12 - 16)

Does anyone know why Node.js is needed here?


name: Rust

on:
  push:
    branches: [ "develop" ]
  pull_request:
    branches: [ "develop" ]

env:
  CARGO_TERM_COLOR: always

jobs:
  fmt:
    name: Rustfmt
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          override: true
          components: rustfmt
      - uses: actions-rs/cargo@v1
        with:
          command: fmt
          args: --all -- --check
...

Rustfmt

Node.js 12 actions are deprecated. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/.

Please update the following actions to use Node.js 16: actions-rs/toolchain, actions-rs/cargo

Full source

like image 642
MortalFool Avatar asked Sep 04 '26 16:09

MortalFool


1 Answers

The GitHub actions mentioned in that quote are themselves dependent on Node.js, specifically on major version 12 of Node.js. And, as stated in that quote, the use of Node.js 12 in actions has recently become deprecated.

Support for Node.js 12 will not be dropped out of a sudden. However, maintainers should act to update their actions and users should be on the look-out for new versions. Unfortunately in this case, issues have been filed for both actions here (actions-rs/toolchain#219 and actions-rs/cargo#216), but they might never be attended because actions-rs is unmaintained since 2020. As such, we may need to rely on alternative actions.

To use setup-rust-toolchain, for example, we can port the fmt job to in the question into the code below.

  # Check formatting with rustfmt
  fmt:
    name: Rustfmt
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          toolchain: stable
          components: rustfmt
      - name: Check formatting
        uses: actions-rust-lang/rustfmt@v1

Alternatively, there is dtolnay's toolchain action.

  fmt:
    name: Rustfmt
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt
      - name: Check formatting
        run: cargo fmt --all -- --check
like image 142
E_net4 stands with Ukraine Avatar answered Sep 07 '26 13:09

E_net4 stands with Ukraine



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!