GitHub Actions vs Linux laptop vs M1 Mac: Different behaviour?

Hey,

so I have a private repo (so I cannot share code, so I'll try to keep things at a higher level) for a Rust project. However, while all the tests pass in my Macbook M1 Pro, they fail on GitHub Actions. After noticing this, I tried the same in an old MacBook with Zorin OS and it works.

The error on GitHub Actions is a convergence/numerical error (i.e., the search for an iterative solution does not converge before a BIG number of iterations). It has nothing to do with compilation. It would seem like floating point numbers are treated differently...?

Details of each environment

M1 Macbook Pro

  • cargo test --> everything works.
  • rustup default --> stable-aarch64-apple-darwin (default)
  • rustup check --> stable-aarch64-apple-darwin - Up to date : 1.64.0 (a55dd71d5 2022-09-19)

Zorin OS:

  • cargo test --> everything works.
  • rustup default --> stable-x86_64-unknown-linux-gnu - Up to date : 1.64.0 ...
  • rustup check --> stable-x86_64-unknown-linux-gnu - Up to date : 1.64.0 ...

GitHub Actions

  • cargo test --verbose does not work.
  • rustc 1.64.0 (a55dd71d5 2022-09-19) | cargo 1.64.0 (387270bc7 2022-09-16) | clippy 0.1.64 (a55dd71 2022-09-19)
name: Tests

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

env:
  CARGO_TERM_COLOR: always

jobs:  
  test:
    runs-on: ubuntu-latest     
    steps:
    - uses: actions/checkout@v3     
    - name: Update
      run: rustup update stable
    - name: Run tests
      run: cargo test --verbose     
  

Any clues as to what might be happening?

THANKS!!!!

Try the ubuntu-22.04 runner and the windows-latest runner.

Reusing a previous post:

1 Like

this is awkward. Not only it did work now, but it took 3.5 minutes instead of (failing at) about 15. Any explanation for this? (I am not complaining, just wondering)

Anyway, this is the new action, for those with similar issues


name: Tests

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

env:
  CARGO_TERM_COLOR: always

jobs:  
  test:
    runs-on: ubuntu-22.04     
    steps:
    - uses: actions/checkout@v3     
    - name: Update
      run: rustup update stable
    - name: Run tests
      run: cargo test --verbose     
  

@scottmcm posted a link. An earlier post in that thread has the explanation. The Ubuntu 22.04 libm is different from the Ubuntu 20.04 (latest) libm.

But @scottmcm's linked post has the answer to the important question. The inconsistency you're seeing is very likely a result of trying to squeeze too much precision out of floating point numbers.

2 Likes

Yeah, I suspect the problem is raised because—in one case—the test is 'barely' passing, and in the other, it is 'barely failing'. Something to fix in the code anyway.

Thanks!