From 95869f956028f76079d26cd11817012f315534e1 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Tue, 20 Dec 2022 14:00:26 +0800 Subject: [PATCH] Improve CI --- .github/scripts/common.sh | 22 +++++++++++++++++---- .github/scripts/hls.sh | 4 ++-- .github/workflows/cache.yaml | 37 ++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/cache.yaml diff --git a/.github/scripts/common.sh b/.github/scripts/common.sh index e53c9a8..480c6ba 100644 --- a/.github/scripts/common.sh +++ b/.github/scripts/common.sh @@ -10,6 +10,16 @@ ecabal() { cabal "$@" } +sync_from_retry() { + if [ "${RUNNER_OS}" != "Windows" ] ; then + cabal_store_path="$(dirname "$(cabal help user-config | tail -n 1 | xargs)")/store" + else + cabal_store_path="${CABAL_DIR}/store" + fi + + sync_from || { sleep 9 ; rm -rf "${cabal_store_path:?}"/* ; sync_from || { sleep 20 ; rm -rf "${cabal_store_path:?}"/* ; sync_from ; } } +} + sync_from() { if [ "${RUNNER_OS}" != "Windows" ] ; then cabal_store_path="$(dirname "$(cabal help user-config | tail -n 1 | xargs)")/store" @@ -24,6 +34,10 @@ sync_from() { --archive-uri "s3://ghcup-hs/${RUNNER_OS}-${ARCH}-${DISTRO}" } +sync_to_retry() { + sync_to || { sleep 9 ; sync_to || { sleep 20 ; sync_to ; } } +} + sync_to() { if [ "${RUNNER_OS}" != "Windows" ] ; then cabal_store_path="$(dirname "$(cabal help user-config | tail -n 1 | xargs)")/store" @@ -129,11 +143,11 @@ download_cabal_cache() { build_with_cache() { ecabal configure "$@" ecabal build --dependencies-only "$@" --dry-run - sync_from - ecabal build --dependencies-only "$@" || sync_to - sync_to + sync_from_retry + ecabal build --dependencies-only "$@" || sync_to_retry + sync_to_retry ecabal build "$@" - sync_to + sync_to_retry } install_ghcup() { diff --git a/.github/scripts/hls.sh b/.github/scripts/hls.sh index d1c80bc..0435fa1 100644 --- a/.github/scripts/hls.sh +++ b/.github/scripts/hls.sh @@ -57,9 +57,9 @@ eghcup debug-info cd "haskell-language-server-${HLS_TARGET_VERSION}/" ecabal configure -w "ghc-${GHC_VERSION}" --disable-profiling --disable-tests --jobs="$(nproc)" ecabal build --dependencies-only -w "ghc-${GHC_VERSION}" --disable-profiling --disable-tests --jobs="$(nproc)" --dry-run - sync_from + sync_from_retry ecabal build --dependencies-only -w "ghc-${GHC_VERSION}" --disable-profiling --disable-tests --jobs="$(nproc)" || sync_to - sync_to + sync_to_retry ) eghcup -v compile hls -j "$(nproc)" -g "${HLS_TARGET_VERSION}" --ghc "${GHC_VERSION}" diff --git a/.github/workflows/cache.yaml b/.github/workflows/cache.yaml new file mode 100644 index 0000000..14269ee --- /dev/null +++ b/.github/workflows/cache.yaml @@ -0,0 +1,37 @@ +name: Cache eviction + +on: + workflow_dispatch: + inputs: + key: + description: Which cache to evict + required: true + default: '/' + type: choice + options: + - FreeBSD-64-na + - Linux-32-Alpine + - Linux-64-Alpine + - Linux-64-Ubuntu + - Linux-ARM-Ubuntu + - Linux-ARM64-Ubuntu + - Windows-64-na + - macOS-64-na + - macOS-ARM64-na + - / +jobs: + evict: + runs-on: ubuntu-latest + + steps: + - name: Remove from S3 + uses: vitorsgomes/s3-rm-action@master + with: + args: --recursive + env: + AWS_S3_ENDPOINT: ${{ secrets.S3_HOST }} + AWS_S3_BUCKET: ghcup-hs + AWS_REGION: us-west-2 + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + PATH_TO_DELETE: ${{ github.event.inputs.key }}