Skip to content

Commit

Permalink
fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
avh4 committed Sep 23, 2020
1 parent 9473c42 commit fbe7a81
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 35 deletions.
24 changes: 19 additions & 5 deletions .github/workflows/Build release.yml
Expand Up @@ -5,9 +5,14 @@ on:
tags: '*'
branches: 'release/*'

defaults:
run:
shell: bash

jobs:
build:
strategy:
fail-fast: false
matrix:
os:
- windows-latest
Expand All @@ -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 }}
Expand Down
23 changes: 13 additions & 10 deletions .github/workflows/CI.yml
Expand Up @@ -6,6 +6,10 @@ on:
pull_request:
branches: [ $default-branch ]

defaults:
run:
shell: bash

jobs:
build:
strategy:
Expand All @@ -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: |
Expand Down
11 changes: 7 additions & 4 deletions .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/
7 changes: 6 additions & 1 deletion .travis.yml
Expand Up @@ -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:
Expand Down
29 changes: 18 additions & 11 deletions Shakefile.hs
Expand Up @@ -34,6 +34,7 @@ cabalInstallOs =
os =
case System.Info.os of
"darwin" -> "osx"
"mingw32" -> "windows"
o -> o

main :: IO ()
Expand All @@ -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"
Expand Down Expand Up @@ -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 ]
Expand Down Expand Up @@ -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 ""


Expand Down Expand Up @@ -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 ""
Expand All @@ -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
Expand Down
12 changes: 8 additions & 4 deletions 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 "$@"

0 comments on commit fbe7a81

Please sign in to comment.