From aaaad2fed1cd50f2bd011411bc350632152b194f Mon Sep 17 00:00:00 2001 From: Ting-Gian LUA Date: Wed, 4 Dec 2024 01:07:17 +0800 Subject: [PATCH] [ ci ] Remove hardcoded Stack root on Windows --- .github/workflows/test-linux.yaml | 111 --------------- .github/workflows/test-mac.yaml | 203 ---------------------------- .github/workflows/test-unix.yaml | 24 ++-- .github/workflows/test-windows.yaml | 56 +++----- 4 files changed, 33 insertions(+), 361 deletions(-) delete mode 100644 .github/workflows/test-linux.yaml delete mode 100644 .github/workflows/test-mac.yaml diff --git a/.github/workflows/test-linux.yaml b/.github/workflows/test-linux.yaml deleted file mode 100644 index 94fd5b2..0000000 --- a/.github/workflows/test-linux.yaml +++ /dev/null @@ -1,111 +0,0 @@ -# modified from https://github.com/simonmichael/hledger/blob/master/.github/workflows/linux.yml - -name: CI (Linux) - -on: - push: - branches: [master] - # branches: [master, ci-*, ci] - tags: - - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 - pull_request: - branches: [master] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - - name: ๐Ÿ“ฅ Checkout repository - uses: actions/checkout@v4 - - - name: ๐Ÿ” Determine stack resolver & GHC - run: | - STACK_RESOLVER=$(yq .resolver stack.yaml) - GHC_VERSION=$(echo $(yq .compiler stack.yaml) | cut -c 5-) - echo STACK_RESOLVER="${STACK_RESOLVER}" >> "${GITHUB_ENV}" - echo GHC_VERSION="${GHC_VERSION}" >> "${GITHUB_ENV}" - - # things to be restored: - # Include STACK_RESOLVER in cache key, otherwise caches accumulate build products for different resolvers. - - - name: ๐Ÿ’พ Restore cached stack global package db - id: stack-global - uses: actions/cache/restore@v3 - with: - path: ~/.stack - key: ${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-global-${{ hashFiles('**.yaml') }} - restore-keys: | - ${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-global - - - name: ๐Ÿ’พ Restore cached .stack-work - id: stack-work - uses: actions/cache/restore@v3 - with: - path: .stack-work - key: ${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-work-${{ hashFiles('**.yaml') }} - restore-keys: | - ${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-work - - # actions: - - - name: โฌ Setup Haskell - uses: haskell-actions/setup@v2 - id: setup-haskell - with: - ghc-version: ${{ env.GHC_VERSION }} - enable-stack: true - stack-version: 'latest' - - - name: โฌ Install dependencies - run: | - stack build --only-dependencies - - - name: ๐Ÿ”จ Build and run tests - run: | - stack test - - # things to be cached - - - name: ๐Ÿ’พ Cache stack global package db - if: always() && steps.stack-global.outputs.cache-hit != 'true' - uses: actions/cache/save@v3 - with: - path: ~/.stack - key: ${{ steps.stack-global.outputs.cache-primary-key }} - - - name: ๐Ÿ’พ Cache .stack-work - if: always() && steps.stack-work.outputs.cache-hit != 'true' - uses: actions/cache/save@v3 - with: - path: .stack-work - key: ${{ steps.stack-work.outputs.cache-primary-key }} - - # release (optional) - - - name: ๐Ÿ“ฆ Compress files - id: zip - run: | - # locate the data-dir - datadir=$(find "$(stack path --snapshot-install-root)/share" -type d -name "Agda-*") - - # locate the executable - executable=$(find "$(stack path --local-install-root)/bin" -name "als") - - # make a temporary directory for compresssing - mkdir zip - cp -r "$datadir" zip/data - cp "$executable" zip/ - - # compress - cd zip - zip -r als-ubuntu.zip ./* - cd .. - mv zip/als-ubuntu.zip . - - - name: ๐Ÿšข Release Artifacts - if: startsWith(github.ref, 'refs/tags/v') # so that only commits with a git tag would upload artifacts - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh release upload ${{ github.ref_name }} als-ubuntu.zip --clobber diff --git a/.github/workflows/test-mac.yaml b/.github/workflows/test-mac.yaml deleted file mode 100644 index e7cfad6..0000000 --- a/.github/workflows/test-mac.yaml +++ /dev/null @@ -1,203 +0,0 @@ -# modified from https://github.com/simonmichael/hledger/blob/master/.github/workflows/mac.yml - -name: CI (macOS) - -on: - push: - branches: [master, ci-*, ci] - tags: - - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 - pull_request: - branches: [master] - -jobs: - build: - runs-on: macos-latest - steps: - - - name: ๐Ÿ“ฅ Checkout repository - uses: actions/checkout@v4 - - - name: ๐Ÿ” Determine stack resolver & GHC - run: | - STACK_RESOLVER=$(yq .resolver stack.yaml) - GHC_VERSION=$(echo $(yq .compiler stack.yaml) | cut -c 5-) - echo STACK_RESOLVER="${STACK_RESOLVER}" >> "${GITHUB_ENV}" - echo GHC_VERSION="${GHC_VERSION}" >> "${GITHUB_ENV}" - - # things to be restored: - # Include STACK_RESOLVER in cache key, otherwise caches accumulate build products for different resolvers. - - - name: ๐Ÿ’พ Restore cached stack global package db - id: stack-global - uses: actions/cache/restore@v3 - with: - path: ~/.stack - key: ${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-global-${{ hashFiles('**.yaml') }} - restore-keys: | - ${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-global - - - name: ๐Ÿ’พ Restore cached .stack-work - id: stack-work - uses: actions/cache/restore@v3 - with: - path: .stack-work - key: ${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-work-${{ hashFiles('**.yaml') }} - restore-keys: | - ${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-work - - # actions: - - - name: Set PKG_CONFIG_PATH for the ICU library - run: | - echo PKG_CONFIG_PATH="$(brew --prefix)/opt/icu4c/lib/pkgconfig" >> "${GITHUB_ENV}" - - - name: โฌ Setup Haskell - uses: haskell-actions/setup@v2 - id: setup-haskell - with: - ghc-version: ${{ env.GHC_VERSION }} - enable-stack: true - stack-version: 'latest' - - - name: โฌ Install dependencies - run: | - stack build --only-dependencies - - - name: ๐Ÿ”จ Build and run tests - run: | - stack test - - # things to be cached - - - name: ๐Ÿ’พ Cache stack global package db - if: always() && steps.stack-global.outputs.cache-hit != 'true' - uses: actions/cache/save@v3 - with: - path: ~/.stack - key: ${{ steps.stack-global.outputs.cache-primary-key }} - - - name: ๐Ÿ’พ Cache .stack-work - if: always() && steps.stack-work.outputs.cache-hit != 'true' - uses: actions/cache/save@v3 - with: - path: .stack-work - key: ${{ steps.stack-work.outputs.cache-primary-key }} - - # release (optional) - - - name: ๐Ÿ”— Bundle ICU4C DLLs - run: | # Bundle icu4c DLLs - - # see if icu4c has been installed - if [ "$(brew list | grep icu4c)" = "" ] - then - echo "installing icu4c" - brew install icu4c - fi - - # get the directory of the DDLs we want (icuuc, icui18n, icudata) - dylib_dir=$(dirname "$(brew list icu4c | grep icuuc.dylib)") - - # find the path of "als" - executable=$(find "$(stack path --local-install-root)"/bin -name "als") - - # remove the old dylib, and make a new one - rm -rf dylib - mkdir dylib - - ################################################################################ - # icuuc - ################################################################################ - - icuuc_id=$(otool -L "$executable" | grep icuuc | awk '{print $1}') - icuuc_id_basename=$(basename "$icuuc_id") - - icuuc_path=$dylib_dir/$icuuc_id_basename - icuuc_path_new=dylib/$icuuc_id_basename - icuuc_id_new=@loader_path/dylib/$icuuc_id_basename - - # copy icuuc to the new directory - cp "$icuuc_path" "$icuuc_path_new" - - # change icuuc's ID referenced by ALS - install_name_tool -change "$icuuc_id" "$icuuc_id_new" "$executable" - - echo "icuuc referenced by ALS" - echo " old ID : $icuuc_id" - echo " new ID : $icuuc_id_new" - echo " old path: $icuuc_path" - echo " new path: $icuuc_path_new" - - ################################################################################ - # icui18n - ################################################################################ - - icui18n_id=$(otool -L "$executable" | grep icui18n | awk '{print $1}') - icui18n_id_basename=$(basename "$icui18n_id") - - icui18n_path=$dylib_dir/$icui18n_id_basename - icui18n_path_new=dylib/$icui18n_id_basename - icui18n_id_new=@loader_path/dylib/$icui18n_id_basename - - # copy icui18n to the new directory - cp "$icui18n_path" "$icui18n_path_new" - - # change icui18n's ID referenced by ALS - install_name_tool -change "$icui18n_id" "$icui18n_id_new" "$executable" - - echo "icui18n referenced by ALS" - echo " old ID : $icui18n_id" - echo " new ID : $icui18n_id_new" - echo " old path: $icui18n_path" - echo " new path: $icui18n_path_new" - - ################################################################################ - # icudata - ################################################################################ - - # otool -L "$icui18n_id" | grep icudata | awk '{print $1}' - icudata_id=$(otool -L "$icuuc_path" | grep icudata | awk '{print $1}') - icudata_id_basename=$(basename "$icudata_id") - - icudata_path=$dylib_dir/$icudata_id_basename - icudata_path_new=dylib/$icudata_id_basename - - # copy icudata to the new directory - cp "$icudata_path" "$icudata_path_new" - - # no need of changing the ID because supposely it's already of "@loader_path" - - echo "icudata referenced by icuuc" - echo " old ID : $icudata_id" - echo " old path : $icudata_path" - echo " new path : $icudata_path_new" - - - - name: ๐Ÿ“ฆ Compress files - id: zip - run: | - # locate the data-dir - datadir=$(find "$(stack path --snapshot-install-root)/share" -type d -name "Agda-*") - - # locate the executable - executable=$(find "$(stack path --local-install-root)/bin" -name "als") - - # make a temporary directory for compresssing - mkdir zip - cp -r "$datadir" zip/data - cp -r dylib zip/dylib - cp "$executable" zip/ - - # compress - cd zip - zip -r als-macos.zip ./* - cd .. - mv zip/als-macos.zip . - - - name: ๐Ÿšข Release Artifacts - if: startsWith(github.ref, 'refs/tags/v') # so that only commits with a git tag would upload artifacts - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh release upload ${{ github.ref_name }} als-macos.zip --clobber diff --git a/.github/workflows/test-unix.yaml b/.github/workflows/test-unix.yaml index 3d2e561..5d101d0 100644 --- a/.github/workflows/test-unix.yaml +++ b/.github/workflows/test-unix.yaml @@ -22,8 +22,12 @@ jobs: - name: ๐Ÿ“ฅ Checkout repository uses: actions/checkout@v4 + - name: ๐Ÿ— Install yq + uses: frenck/action-setup-yq@v1 + - name: ๐Ÿ” Determine stack resolver & GHC run: | + STACK_ROOT="$(stack path --stack-root)" STACK_RESOLVER=$(yq .resolver stack.yaml) GHC_VERSION=$(echo $(yq .compiler stack.yaml) | cut -c 5-) echo STACK_RESOLVER="${STACK_RESOLVER}" >> "${GITHUB_ENV}" @@ -36,7 +40,7 @@ jobs: id: stack-global uses: actions/cache/restore@v4 with: - path: ~/.stack + path: ${{ env.STACK_ROOT }} key: ${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-global-${{ hashFiles('**.yaml') }} restore-keys: | ${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-global @@ -64,26 +68,24 @@ jobs: enable-stack: true stack-version: 'latest' - - name: โฌ Install dependencies - run: | - stack build + - name: ๐Ÿ”จ Build + run: stack build - - name: ๐Ÿ”จ Build and run tests - run: | - stack test + - name: ๐Ÿงช Run tests + run: stack test # things to be cached - name: ๐Ÿ’พ Cache stack global package db if: always() && steps.stack-global.outputs.cache-hit != 'true' - uses: actions/cache/save@v3 + uses: actions/cache/save@v4 with: - path: ~/.stack + path: ${{ env.STACK_ROOT }} key: ${{ steps.stack-global.outputs.cache-primary-key }} - name: ๐Ÿ’พ Cache .stack-work if: always() && steps.stack-work.outputs.cache-hit != 'true' - uses: actions/cache/save@v3 + uses: actions/cache/save@v4 with: path: .stack-work key: ${{ steps.stack-work.outputs.cache-primary-key }} @@ -215,7 +217,7 @@ jobs: - name: ๐Ÿ”จ Build and run tests run: | - + stack test --ta --als-path=zip/als # release (optional) diff --git a/.github/workflows/test-windows.yaml b/.github/workflows/test-windows.yaml index 8858cbb..77485c3 100644 --- a/.github/workflows/test-windows.yaml +++ b/.github/workflows/test-windows.yaml @@ -26,12 +26,8 @@ jobs: uses: frenck/action-setup-yq@v1 - name: ๐Ÿ” Determine stack root and resolver and GHC - ## 2023-11-21 https://github.com/commercialhaskell/stack/issues/6340 - ## Asking stack for the stack root unfortunately does not work - ## if stack is not fully operational (meaning e.g. that GHC is installed) - ## so we hardcode its location instead. run: | - STACK_ROOT="C:/Users/runneradmin/AppData/Local/Programs/stack/x86_64-windows" + STACK_ROOT="$(stack path --stack-root)" STACK_RESOLVER=$(yq .resolver stack.yaml) GHC_VERSION=$(echo $(yq .compiler stack.yaml) | cut -c 5-) echo STACK_ROOT="${STACK_ROOT}" >> "${GITHUB_ENV}" @@ -48,7 +44,7 @@ jobs: - name: ๐Ÿ’พ Restore cached stack global package db id: stack-global - uses: actions/cache/restore@v3 + uses: actions/cache/restore@v4 with: path: ${{ env.STACK_ROOT }} key: ${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-global-${{ hashFiles('**.yaml') }} @@ -57,7 +53,7 @@ jobs: - name: ๐Ÿ’พ Restore cached .stack-work id: stack-work - uses: actions/cache/restore@v3 + uses: actions/cache/restore@v4 with: path: .stack-work key: ${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-work-${{ hashFiles('**.yaml') }} @@ -65,57 +61,44 @@ jobs: ${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-work # actions + - name: Install the icu library + run: | + stack exec -- pacman -S --noconfirm mingw-w64-x86_64-icu mingw-w64-x86_64-pkgconf - # - name: โฌ Install stack - # ## Stack is preinstalled on GHA runners. - # # - # #if: steps.stack-programs-dir.outputs.cache-hit != 'true' - # # this step is needed to get stack.exe into PATH, for now - # # curl -sL https://get.haskellstack.org/stable/windows-x86_64.zip -o stack.zip - # # 7z x stack.zip stack.exe + # - name: ๐Ÿ“ธ Build Snapshot # run: | - # which stack - # stack --version + # stack build --no-terminal --only-snapshot -j1 - # - name: โฌ Install GHC - # # if: steps.stack-programs-dir.outputs.cache-hit != 'true' - # # set PATH=C:\Users\runneradmin\AppData\Local\Programs\stack\local\bin;%PATH% + # - name: ๐Ÿงฐ Build Dependencies # run: | - # stack --no-terminal setup --install-ghc - - - name: Install the icu library - run: | - stack exec -- pacman -S --noconfirm mingw-w64-x86_64-icu mingw-w64-x86_64-pkgconf + # stack build --no-terminal --only-dependencies - - name: ๐Ÿ“ธ Build Snapshot - run: | - stack build --no-terminal --only-snapshot -j1 + # - name: ๐Ÿ”จ Build and run tests + # run: | + # stack test - - name: ๐Ÿงฐ Build Dependencies - run: | - stack build --no-terminal --only-dependencies + - name: ๐Ÿ”จ Build + run: stack build - - name: ๐Ÿ”จ Build and run tests - run: | - stack test + - name: ๐Ÿงช Run tests + run: stack test # things to be cached - name: ๐Ÿ’พ Cache stack global package db if: always() && steps.stack-global.outputs.cache-hit != 'true' - uses: actions/cache/save@v3 + uses: actions/cache/save@v4 with: path: ${{ env.STACK_ROOT }} key: ${{ steps.stack-global.outputs.cache-primary-key }} - name: ๐Ÿ’พ Cache .stack-work if: always() && steps.stack-work.outputs.cache-hit != 'true' - uses: actions/cache/save@v3 + uses: actions/cache/save@v4 with: path: .stack-work key: ${{ steps.stack-work.outputs.cache-primary-key }} - # release (optional) # artifacts: - name: ๐Ÿ“ฆ Compress executable and data files @@ -148,6 +131,7 @@ jobs: cd .. mv zip/als-windows.zip . + # release (optional) - name: ๐Ÿšข Release Artifacts if: startsWith(github.ref, 'refs/tags/v') # so that only commits with a git tag would upload artifacts env: