Home > Enterprise >  The configure script can't find grep on Windows on GitHub Actions
The configure script can't find grep on Windows on GitHub Actions

Time:04-18

I'm trying to make a PR to build my Haskell project on Windows on Github Actions, but the configuration script of the process-1.6.14.0 can't find grep. The complete GA log is here and here (the same log but I've uploaded it as a Gists in case the log retention time is expired).

grep is installed on /usr/bin/grep.

  which grep
  grep --version
  /usr/bin/grep --version
  shell: D:\a\_temp\setup-msys2\msys2.CMD {0}
  env:
    MSYSTEM: MINGW64
/usr/bin/grep
grep (GNU grep) 3.0
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3 : GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Mike Haertel and others, see <http://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.
grep (GNU grep) 3.0
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3 : GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Mike Haertel and others, see <http://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.

However, the configuration script can't find it.

checking for grep that handles long lines and -e... configure: error: no acceptable grep could be found in /mingw64/bin:/c/Users/runneradmin/AppData/Roaming/cabal/bin:/usr/bin:/d/a/_temp/msys64/mingw64/bin:/d/a/_temp/msys64/usr/local/bin:/d/a/_temp/msys64/usr/bin:/d/a/_temp/msys64/usr/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/d/a/_temp/msys64/usr/bin/site_perl:/d/a/_temp/msys64/usr/bin/vendor_perl:/d/a/_temp/msys64/usr/bin/core_perl;/usr/xpg4/bin

I think that grep satisfies all the requirements because I could build process-1.6.14.0 on my local Windows with the same version of grep.

Here is the GA script.

name: Haskell CI

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

jobs:
  test:

    strategy:
      matrix:
        sys:
        - { os: ubuntu-latest, shell: bash }
        - { os: windows-latest, shell: 'msys2 {0}' }

    runs-on: ${{ matrix.sys.os }}

    defaults:
      run:
        shell: ${{ matrix.sys.shell }}

    steps:
    - uses: actions/checkout@v2

    - uses: msys2/setup-msys2@v2
      with:
        update: true
        install: |
            base-devel
            mingw-w64-x86_64-pkg-config
            mingw-w64-x86_64-SDL2
            mingw-w64-x86_64-freeglut
            mingw-w64-x86_64-glew
            mingw-w64-x86_64-freetype
      if: runner.os == 'Windows'

    - uses: haskell/actions/setup@v1
      id: haskell_setup
      with:
        ghc-version: '8.10.7'
        cabal-version: '3.6.0.0'

    # Adding a path to msys2's PATH on GitHub Actions is pretty troublesome. So I'll output the path to a file.
    # (See https://github.com/msys2/setup-msys2/issues/98 to how to add a path to PATH.)
    - name: Store the path to Cabal (Windows)
      run: |
        echo "$(cygpath --unix '${{ steps.haskell_setup.outputs.cabal-exe }}') "'$@ '"-w $(cygpath --unix '${{ steps.haskell_setup.outputs.ghc-exe }}')" > cabal.sh
        chmod  x cabal.sh
      if: runner.os == 'Windows'

    - name: Store the path to Cabal (Linux)
      run: |
        echo '${{ steps.haskell_setup.outputs.cabal-exe }} $@' > cabal.sh
        chmod  x cabal.sh
      if: runner.os == 'Linux'

    - name: Cache
      uses: actions/cache@v2
      env:
        cache-name: cache-cabal
      with:
        path: |
          ~/.cabal/packages
          ~/.cabal/store
          dist-newstyle
        key: ${{ runner.os }}-${{ hashFiles('cabal.project.freeze') }}-${{ github.sha }}
        restore-keys: ${{ runner.os }}-${{ hashFiles('cabal.project.freeze') }}

    - name: Install dependencies (Linux)
      run: |
        sudo apt update
        sudo apt install libsdl2-dev libglew-dev moreutils
      if: runner.os == 'Linux'

    - name: Update Cabal
      run: ./cabal.sh update

    - name: Test grep
      run: |
        which grep
        grep --version
        /usr/bin/grep --version
      if: runner.os == 'Windows'

    - name: Build
      run: ./cabal.sh build --enable-tests --enable-benchmarks all -j

    - name: Run tests
      run: ./cabal.sh test all -j

  format_and_lint:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - uses: haskell/actions/setup@v1
      with:
        ghc-version: '8.10.7'
        cabal-version: '3.6.0.0'

    - name: Cache
      uses: actions/cache@v2
      env:
        cache-name: cache-cabal
      with:
        path: |
          ~/.cabal/packages
          ~/.cabal/store
          dist-newstyle
        key: ${{ runner.os }}-${{ hashFiles('cabal.project.freeze') }}-${{ github.sha }}
        restore-keys: ${{ runner.os }}-${{ hashFiles('cabal.project.freeze') }}

    - name: Update the PATH environment variable
      run: echo "$HOME/.cabal/bin" >> $GITHUB_PATH

    - name: Install dependencies
      run: |
        sudo apt update
        sudo apt install libsdl2-dev libglew-dev moreutils

        cabal update -j

        # See https://tokuchan3515.hatenablog.com/entry/2022/03/26/133158 why we separate `cabal install`s.
        cabal install weeder -j -z
        cabal install hindent -j -z
        cabal install stylish-haskell -j -z

    - name: Generate `cabal.project.local` for `weeder`
      run: "echo \"package * \n  ghc-options: -fwrite-ide-info\" > cabal.project.local"

    - name: Detect unused lines
      run: |
        cabal clean # This is necessary to run `weeder` correctly. See https://hackage.haskell.org/package/weeder.
        weeder

    - name: Set up HLint
      uses: haskell/actions/hlint-setup@v1

    - name: Run HLint
      uses: haskell/actions/hlint-run@v1
      with:
        path: '["src/", "tests/", "app/"]'
        fail-on: warning

    - name: Check format
      run: ./formatter.sh --check


Why is the build failed on GA?

CodePudding user response:

The configuration script accepts the GREP variable to specify where grep is. So, I updated the GA script.

    - name: Store the path to Cabal (Windows)
      run: |
        echo "GREP=$(which grep) $(cygpath --unix '${{ steps.haskell_setup.outputs.cabal-exe }}') "'$@ '"-w $(cygpath --unix '${{ steps.haskell_setup.outputs.ghc-exe }}')" > cabal.sh
        chmod  x cabal.sh
      if: runner.os == 'Windows'
  • Related