rust-toolchain icon indicating copy to clipboard operation
rust-toolchain copied to clipboard

Toolchain version 1.70 is parsed as 1.7

Open Thomasdezeeuw opened this issue 1 year ago • 4 comments

Happens in this pr: https://github.com/tokio-rs/mio/pull/1806, workflow: https://github.com/tokio-rs/mio/actions/runs/9514447708/job/26226798660.

Relevant GitHub Action config:

    - uses: dtolnay/rust-toolchain@master
      with:
        toolchain: 1.70

Relevant part of the job logs:

Run : parse toolchain version
  : parse toolchain version
  if [[ $toolchain =~ ^stable' '[0-9]+' '(year|month|week|day)s?' 'ago$ ]]; then
    if [[ Linux == macOS ]]; then
      echo "toolchain=1.$((($(date -v-$(sed 's/stable \([0-9]*\) \(.\).*/\1\2/' <<< $toolchain) +%s)/60/60/24-16569)/7/6))" >> $GITHUB_OUTPUT
    else
      echo "toolchain=1.$((($(date --date "${toolchain#stable }" +%s)/60/60/24-16569)/7/6))" >> $GITHUB_OUTPUT
    fi
  elif [[ $toolchain =~ ^stable' 'minus' '[0-9]+' 'releases?$ ]]; then
    echo "toolchain=1.$((($(date +%s)/60/60/24-16569)/7/6-${toolchain//[^0-9]/}))" >> $GITHUB_OUTPUT
  else
    echo "toolchain=$toolchain" >> $GITHUB_OUTPUT
  fi
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    CARGO_TERM_COLOR: always
    RUST_BACKTRACE: full
    CI: true
    toolchain: 1.7

Thomasdezeeuw avatar Jun 14 '24 10:06 Thomasdezeeuw

A workaround for this is using 1.70.0, that seems to work ok.

Thomasdezeeuw avatar Jun 14 '24 10:06 Thomasdezeeuw

I think this is because the YAML itself treated the data as numbers. You can fix it by quoting it in strings e.g. '1.70'.

willnode avatar Jul 13 '24 23:07 willnode

That could be it, would explain why 1.70.0 also works.

It that case there is not much we can do to fix it. Maybe it's worth pointing out in the documentation?

Thomasdezeeuw avatar Jul 14 '24 12:07 Thomasdezeeuw

See #91.

wackbyte avatar Aug 27 '24 03:08 wackbyte

I think this is because the YAML itself treated the data as numbers. You can fix it by quoting it in strings e.g. '1.70'.

Yes this is just the YAML Document from Hell strikes again...

You should quote all strings in YAML. It's good habit. Like tying your shoes so you don't fall face down in the sidewalk. Please tie your own YAML shoes.

    - uses: dtolnay/rust-toolchain@master
      with:
        toolchain: "1.70"

The dark magic regex in #131 is not the proper way to fix this...

storopoli avatar Dec 14 '24 09:12 storopoli