From 8cecd3bd9053b9d98be2f0d7c7b413b828885ed6 Mon Sep 17 00:00:00 2001 From: Jonas Date: Mon, 27 Nov 2023 19:35:51 +0100 Subject: [PATCH] Always save cache --- .github/workflows/ci.yml | 5 +++-- src/scripts/Setup.elm | 28 ++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bdd651f..62d3a34 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: with: node-version: 18 cache: 'npm' - - name: Restore cached Primes + - name: Restore cache id: cache-generated-elm-modules-restore uses: actions/cache/restore@v3 with: @@ -21,7 +21,8 @@ jobs: key: ${{ runner.os }}-generated-elm-modules - run: make install - run: make clean setup build - - name: Save Primes + - name: Save cache + if: always() id: cache-generated-elm-modules-save uses: actions/cache/save@v3 with: diff --git a/src/scripts/Setup.elm b/src/scripts/Setup.elm index e1ede78..404124c 100644 --- a/src/scripts/Setup.elm +++ b/src/scripts/Setup.elm @@ -8,7 +8,7 @@ import Http import Json.Decode as Decode import Process import Set -import Task +import Task exposing (Task) type alias Model = @@ -73,9 +73,26 @@ planFileWrites partials = in writeOutput (Generate.main_ moduleNames) :: List.map2 Cache.check moduleNames partials + --|> List.indexedMap + -- (\i cmd -> + -- Process.sleep (toFloat i * 10) + -- |> Task.andThen (\_ -> cmd) + -- ) |> Cmd.batch +delay : Int -> Cmd msg -> Cmd msg +delay ms cmd = + Process.sleep (toFloat ms) + |> Task.andThen (\_ -> cmd) + + +toCmd : Task Never (Cmd msg) -> Cmd msg +toCmd task = + Task.perform identity task + |> Cmd.unwrap + + fetchDocs : String -> Package.Metadata -> Cmd Msg fetchDocs elmVersion metadata = if Blacklist.contains metadata then @@ -93,13 +110,8 @@ fetchDocs elmVersion metadata = decoder = Package.decode elmVersion metadata in - Process.sleep 1000 - |> Task.andThen - (\_ -> - Http.get url decoder - |> Http.toTask - ) - |> Task.attempt (ensureOk Response) + Http.get url decoder + |> Http.send (ensureOk Response)