bats-core / bats-action

Github action that setup Bats and all the bats libs: support, assert, detik, file.
MIT License
1 stars 4 forks source link

Does not work on windows #13

Open tbutler-qontigo opened 4 days ago

tbutler-qontigo commented 4 days ago

Hi Trying to use this in a github action on windows-latest it fails due to lack of sudo:

VERSION=0.3.0
  DESTDIR=D:\a\devops-gh-actions\devops-gh-actions/_buildtools/bats/1.11.0/bats-support
  TEMPDIR="/tmp/bats-support"
  url="[https://github.com/bats-core/bats-support/archive/refs/tags/v${VERSION}.tar.gz](https://github.com/bats-core/bats-support/archive/refs/tags/v$%7BVERSION%7D.tar.gz)"

  mkdir -p ${TEMPDIR}
  [[ "${DESTDIR}" == "$HOME"* ]] && CMD="" || CMD="sudo"
  ${CMD} mkdir -p ${DESTDIR}/src/
  curl -sL ${url} | tar xz -C ${TEMPDIR} --strip-components 1 && cd ${TEMPDIR}
  # Archlinux style, except that we are not in a fakeroot env
  ${CMD} install -Dm755 load.bash ${DESTDIR}/load.bash
  for fn in src/*.bash; do
    ${CMD} install -Dm755 $fn \
       ${DESTDIR}/src/$(basename $fn)
  done
  echo "Bats Support v$VERSION installed in $DESTDIR"
  echo "support-installed=true" >> $GITHUB_OUTPUT
  # Cleanup bats-support if required
  [[ "true" = "true"  ]] && rm -rf ${TEMPDIR} || exit 0
  shell: C:\Program Files\Git\bin\bash.EXE --noprofile --norc -e -o pipefail {0}
D:\a\_temp\f5e99e24-da2b-4206-a0ee-ba2419854757.sh: line 8: sudo: command not found

I am installing in ${{ github.workspace }}/_buildtools/bats-support

brokenpip3 commented 3 days ago

Hi :wave:

honestly never tried on windows runners :D

and yes it will probably not work 'cause this check will check for $HOME, in windows runners seems C:\Users\runneradmin probably bash on windows is not capable to expand the home directory? not sure since I can't test it on my own (no win systems).

Anyway should be not too so complex to fix, so we can support windows runners as well :) Will try a branch and let you know

tbutler-qontigo commented 3 days ago

Hi Yes it can work with using the $HOME folder to avoid the need to try to load sudo but IMO it would be better if it can work with any folder like it can on linux

You could have your CI tests run on windows-latest as well as ubuntu-latest to validate your changes work - so no local windows required ;)

thanls

brokenpip3 commented 2 days ago

You could have your CI tests run on windows-latest as well as ubuntu-latest to validate your changes work - so no local windows required ;)

yup that's my plan, I was also thinking to add the macos in the matrix so we can assure that we support that os as well