diff --git a/.github/workflows/Build release.yml b/.github/workflows/Build release.yml index 79f59ed73..62cb2b0a3 100644 --- a/.github/workflows/Build release.yml +++ b/.github/workflows/Build release.yml @@ -5,9 +5,14 @@ on: tags: '*' branches: 'release/*' +defaults: + run: + shell: bash + jobs: build: strategy: + fail-fast: false matrix: os: - windows-latest @@ -28,17 +33,26 @@ jobs: id: setup-haskell with: ghc-version: 8.8.4 + - name: Workaround for https://github.com/actions/setup-haskell/issues/36 + if: runner.os == 'macOS' + run: | + ghcup list + ghcup set ghc 8.8.4 + - name: Verify Haskell version + run: | + cabal --version + ghc --version + [[ $(ghc --numeric-version) == 8.8.4 ]] - uses: actions/cache@v2 - name: Cache cabal store + name: Cache cabal-v2-${{ runner.os }}-${{ hashFiles('cabal.project.freeze') }} with: path: ${{ steps.setup-haskell.outputs.cabal-store }} - key: ${{ runner.os }}-${{ hashFiles('cabal.project.freeze') }} + key: cabal-v2-${{ runner.os }}-${{ hashFiles('cabal.project.freeze') }} - run: cabal v2-update - run: cabal v2-build --only-dependencies - run: cabal v2-build --only-dependencies --enable-tests - - run: cabal v2-install --lib shake - - name: Build dist - run: ./build.sh -- dist + - run: ./build.sh -- dependencies + - run: ./build.sh -- dist - uses: actions/upload-artifact@v2 with: name: elm-format-${{ github.sha }}-${{ runner.os }} diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index dbfe22cbd..823636b85 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -6,6 +6,10 @@ on: pull_request: branches: [ $default-branch ] +defaults: + run: + shell: bash + jobs: build: strategy: @@ -28,21 +32,20 @@ jobs: with: ghc-version: 8.8.4 - uses: actions/cache@v2 - name: Cache cabal store + name: Cache cabal-v2-${{ runner.os }}-${{ hashFiles('cabal.project.freeze') }} with: path: ${{ steps.setup-haskell.outputs.cabal-store }} - key: ${{ runner.os }}-${{ hashFiles('cabal.project.freeze') }} - - uses: actions/cache@v2 - name: Cache dist - with: - path: dist-newstyle - key: ${{ runner.os }}-dist + key: cabal-v2-${{ runner.os }}-${{ hashFiles('cabal.project.freeze') }} + # - uses: actions/cache@v2 + # name: Cache dist + # with: + # path: dist-newstyle + # key: dist-v1-${{ runner.os }} - run: cabal v2-update - run: cabal v2-build --only-dependencies - run: cabal v2-build --only-dependencies --enable-tests - - run: cabal v2-install --lib shake - - name: Build - run: ./build.sh -- build + - run: ./build.sh -- dependencies + - run: ./build.sh -- build - name: Tests if: matrix.os != 'windows-latest' run: | diff --git a/.gitignore b/.gitignore index c5af07d86..fa3b93e55 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,14 @@ +# Generated source files +/generated/ + +# Files generated by the test suite /formatted.elm /_input.elm /_input2.elm /_stdout.txt -*.tix -/dist-newstyle/ + +# Files generated by the build system /.shake/ /_build/ -/generated/ -/_profile/ +/dist-newstyle/ /bin/ diff --git a/.travis.yml b/.travis.yml index 02c503aaa..67958c1e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,11 +6,16 @@ cabal: "3.2" ghc: "8.8.4" +cache: + directories: + - "$HOME/.cabal/store" + + install: - cabal v2-update - cabal v2-build --only-dependencies - cabal v2-build --only-dependencies --enable-tests -- cabal v2-install --lib shake +- ./build.sh -- dependencies script: diff --git a/Shakefile.hs b/Shakefile.hs index f0d9aa1c5..d1258e3a8 100644 --- a/Shakefile.hs +++ b/Shakefile.hs @@ -34,6 +34,7 @@ cabalInstallOs = os = case System.Info.os of "darwin" -> "osx" + "mingw32" -> "windows" o -> o main :: IO () @@ -57,22 +58,26 @@ main = do want [ "test" ] - phony "test" $ do - need - [ "unit-tests" - , "integration-tests" - , "_build/shellcheck.ok" - ] + phony "test" $ need + [ "unit-tests" + , "integration-tests" + , "_build/shellcheck.ok" + ] phony "build" $ need [ elmFormat ] phony "unit-tests" $ need [ "_build/cabal-test.ok" ] phony "profile" $ need [ "_build/tests/test-files/prof.ok" ] phony "dist" $ need [ "dist/elm-format-" ++ gitDescribe ++ "-" ++ show os <.> zipFormat ] + phony "dependencies" $ need + [ shellcheck + ] + phony "clean" $ do removeFilesAfter "dist-newstyle" [ "//*" ] removeFilesAfter "_build" [ "//*" ] - removeFilesAfter "" + removeFilesAfter ".shake" [ "//*" ] + removeFilesAfter "." [ "_input.elm" , "_input2.elm" , "formatted.elm" @@ -111,13 +116,13 @@ main = do sourceFiles <- getDirectoryFiles "" sourceFilesPattern need sourceFiles need generatedSourceFiles - cmd_ "cabal" "new-build" "-O0" + cmd_ "cabal" "v2-build" "-O0" elmFormatDist %> \out -> do sourceFiles <- getDirectoryFiles "" sourceFilesPattern need sourceFiles need generatedSourceFiles - cmd_ "cabal" "new-build" "-O2" + cmd_ "cabal" "v2-build" "-O2" ("_build/dist/" ++ show os ++ "/elm-format" <.> exe) %> \out -> do need [ elmFormatDist ] @@ -151,7 +156,7 @@ main = do sourceFiles <- getDirectoryFiles "" sourceFilesPattern need sourceFiles need generatedSourceFiles - cmd_ "cabal new-test -O0" + cmd_ "cabal" "v2-test" "-O0" writeFile' out "" @@ -327,7 +332,8 @@ main = do -- shellcheck %> \out -> do - cmd_ "cabal" "new-install" "ShellCheck" "--installdir" localBinDir + -- install-method is currently needed because Windows doesn't support the default symlink method + cmd_ "cabal" "v2-install" "ShellCheck" "--installdir" localBinDir "--install-method=copy" "--overwrite-policy=always" "_build/shellcheck.ok" %> \out -> do scriptFiles <- getDirectoryFiles "" @@ -338,6 +344,7 @@ main = do , "package/mac/build-package.sh" , "package/nix/build.sh" , "package/win/build-package.sh" + , "build.sh" ] let oks = ["_build" f <.> "shellcheck.ok" | f <- scriptFiles] need oks diff --git a/build.sh b/build.sh index f813509af..349003b1b 100755 --- a/build.sh +++ b/build.sh @@ -1,8 +1,12 @@ #!/bin/bash set -euo pipefail -if [ ! -f _build/build ]; then - mkdir -p _build - cabal new-install --lib shake +PKG_ENV_FILE=_build/shake-package-env + +mkdir -p _build +if ! grep -qs '^package-id shk-' "$PKG_ENV_FILE"; then + echo "$0: installing shake" + cabal v2-install --package-env "$PKG_ENV_FILE" --lib shake fi -ghc --make Shakefile.hs -package shake -rtsopts -threaded -with-rtsopts=-I0 -outputdir=_build -o _build/build && _build/build "$@" +ghc --make Shakefile.hs -package-env "$PKG_ENV_FILE" -rtsopts -threaded -with-rtsopts=-I0 -outputdir=_build -o _build/build +_build/build "$@"