diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..a10ab6ff --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,43 @@ +name: CI + +on: + # Trigger the workflow on push or pull request, + # but only for the master branch + push: + branches: + - master + pull_request: + +jobs: + build: + name: ghc ${{ matrix.ghc }} + runs-on: ubuntu-16.04 + strategy: + matrix: + ghc: ["8.2.2", "8.4.4", "8.6.5", "8.8.2"] + cabal: ["3.0"] + + steps: + - uses: actions/checkout@v2 + if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master' + + - uses: actions/setup-haskell@v1 + name: Setup Haskell + with: + ghc-version: ${{ matrix.ghc }} + cabal-version: ${{ matrix.cabal }} + + - uses: actions/cache@v1 + name: Cache ~/.cabal/store + with: + path: ~/.cabal/store + key: ${{ runner.os }}-${{ matrix.ghc }}-cabal + + - name: Build + run: | + cabal new-update + cabal new-build all --enable-tests --enable-benchmarks --write-ghc-environment-files=always + + - name: Test + run: | + cabal new-test all --enable-tests diff --git a/README.md b/README.md index 0acd77ad..2eeaa206 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,7 @@ Features related to the structure and content of the generated projects. [Dead simple Haskell Travis Settings for Cabal and Stack](https://chshersh.github.io/posts/2019-02-25-haskell-travis). + Generation of the `appveyor.yaml` file which runs build and tests on CI under Windows. + Generation of the `.github/workflows/ci.yml` file that runs build and tests on - GitHub ACtuions CI under Linux using Cabal. + GitHub Actions CI under Linux using Cabal. + Configuration matrix on CI to build with multiple GHC versions and various build tools. + `-Werror` is enabled on CI not to miss any warnings. + Run HLint checks on CI. diff --git a/cabal.project b/cabal.project index a404f47d..4e99296a 100644 --- a/cabal.project +++ b/cabal.project @@ -1,3 +1,5 @@ packages: summoner-cli/ - summoner-tui/ \ No newline at end of file + summoner-tui/ + +tests: true \ No newline at end of file diff --git a/summoner-cli/src/Summoner/Template/GitHub.hs b/summoner-cli/src/Summoner/Template/GitHub.hs index 0bcb7aca..6188ad04 100644 --- a/summoner-cli/src/Summoner/Template/GitHub.hs +++ b/summoner-cli/src/Summoner/Template/GitHub.hs @@ -139,34 +139,19 @@ gitHubFiles Settings{..} = concat ghc-version: ${{ matrix.ghc }} cabal-version: ${{ matrix.cabal }} - # We cache the elements of the Cabal store separately, - # as the entirety of ~/.cabal can grow very large - # for projects with many dependencies. - - - uses: actions/cache@v1 - name: Cache ~/.cabal/packages - with: - path: ~/.cabal/packages - key: ${{ runner.os }}-${{ matrix.ghc }}-cabal-packages - uses: actions/cache@v1 name: Cache ~/.cabal/store with: path: ~/.cabal/store - key: ${{ runner.os }}-${{ matrix.ghc }}-cabal-store - - uses: actions/cache@v1 - name: Cache dist-newstyle - with: - path: dist-newstyle - key: ${{ runner.os }}-${{ matrix.ghc }}-dist + key: ${{ runner.os }}-${{ matrix.ghc }}-cabal - - name: Install dependencies + - name: Build run: | cabal new-update - cabal new-configure --enable-tests --enable-benchmarks --write-ghc-environment-files=always -j2 - cabal new-build --only-dependencies - - name: Build & test + cabal new-build --enable-tests --enable-benchmarks --write-ghc-environment-files=always + + - name: Test run: | - cabal v2-build ${cabalTest} |] diff --git a/summoner-cli/test/golden/fullProject/.github/workflows/ci.yml b/summoner-cli/test/golden/fullProject/.github/workflows/ci.yml index e7277edf..a12c9de3 100644 --- a/summoner-cli/test/golden/fullProject/.github/workflows/ci.yml +++ b/summoner-cli/test/golden/fullProject/.github/workflows/ci.yml @@ -27,32 +27,17 @@ jobs: ghc-version: ${{ matrix.ghc }} cabal-version: ${{ matrix.cabal }} - # We cache the elements of the Cabal store separately, - # as the entirety of ~/.cabal can grow very large - # for projects with many dependencies. - - - uses: actions/cache@v1 - name: Cache ~/.cabal/packages - with: - path: ~/.cabal/packages - key: ${{ runner.os }}-${{ matrix.ghc }}-cabal-packages - uses: actions/cache@v1 name: Cache ~/.cabal/store with: path: ~/.cabal/store - key: ${{ runner.os }}-${{ matrix.ghc }}-cabal-store - - uses: actions/cache@v1 - name: Cache dist-newstyle - with: - path: dist-newstyle - key: ${{ runner.os }}-${{ matrix.ghc }}-dist + key: ${{ runner.os }}-${{ matrix.ghc }}-cabal - - name: Install dependencies + - name: Build run: | cabal new-update - cabal new-configure --enable-tests --enable-benchmarks --write-ghc-environment-files=always -j2 - cabal new-build --only-dependencies - - name: Build & test + cabal new-build --enable-tests --enable-benchmarks --write-ghc-environment-files=always + + - name: Test run: | - cabal v2-build cabal new-test --enable-tests