From 4ea3d5da5914ead0dd56d478bad66bb6a0f7b0ea Mon Sep 17 00:00:00 2001 From: Matt Parsons Date: Thu, 29 Oct 2020 15:10:54 -0600 Subject: [PATCH] Github Actions (#223) * Create haskell.yml --- .github/workflows/haskell.yml | 75 +++++++++++++++++++++++++++++++++++ test/MySQL/Test.hs | 6 ++- 2 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/haskell.yml diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml new file mode 100644 index 0000000..1d18fed --- /dev/null +++ b/.github/workflows/haskell.yml @@ -0,0 +1,75 @@ +name: CI +on: + push: + branches: + - master + pull_request: + types: + - opened + - synchronize +jobs: + build: + runs-on: ubuntu-latest + services: + # mysql-service Label used to access the service container + mysql-service: + # Docker Hub image (also with version) + image: mysql:8.0 + env: + ## Accessing to Github secrets, where you can store your configuration + MYSQL_USER: travis + MYSQL_PASSWORD: esqutest + MYSQL_ROOT_PASSWORD: esqutest + MYSQL_DATABASE: esqutest + ## map the "external" 33306 port with the "internal" 3306 + ports: + - 33306:3306 + # Set health checks to wait until mysql database has started (it takes some seconds to start) + options: >- + --health-cmd="mysqladmin ping" + --health-interval=10s + --health-timeout=5s + --health-retries=3 + strategy: + matrix: + cabal: ["3.2"] + ghc: ["8.6.5", "8.8.3", "8.10.1"] + env: + CONFIG: "--enable-tests --enable-benchmarks" + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-haskell@v1.1.2 + id: setup-haskell-cabal + with: + ghc-version: ${{ matrix.ghc }} + cabal-version: ${{ matrix.cabal }} + - uses: harmon758/postgresql-action@v1 + with: + postgresql version: '12' # See https://hub.docker.com/_/postgres for available versions + postgresql user: esqutest + postgresql password: esqutest + postgresql db: esqutest + - name: Create MySQL + run: mysql -utravis -pesqutest -h127.0.0.1 --port=33306 esqutest -e "SELECT 1;" + # - name: Shutdown Ubuntu MySQL (SUDO) + # run: sudo service mysql stop + # - uses: mirromutth/mysql-action@v1.1 + # with: + # mysql version: '8.0' # Optional, default value is "latest". The version of the MySQL + # mysql database: 'esqutest' # Optional, default value is "test". The specified database which will be create + # mysql user: 'travis' # Required if "mysql root password" is empty, default is empty. The superuser for the specified database. Can use secrets, too + # mysql password: 'esqutest' # Required if "mysql user" exists. The password for the "mysql user" + - run: cabal v2-update + - run: cabal v2-freeze $CONFIG + - uses: actions/cache@v2 + with: + path: | + ${{ steps.setup-haskell-cabal.outputs.cabal-store }} + dist-newstyle + key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.ghc }}- + - run: cabal v2-build $CONFIG + - run: cabal v2-test $CONFIG + - run: cabal v2-haddock $CONFIG + - run: cabal v2-sdist diff --git a/test/MySQL/Test.hs b/test/MySQL/Test.hs index 0350845..fb073af 100644 --- a/test/MySQL/Test.hs +++ b/test/MySQL/Test.hs @@ -16,6 +16,7 @@ import Database.Persist.MySQL ( withMySQLConn , connectDatabase , connectUser , connectPassword + , connectPort , defaultConnectInfo) import Database.Esqueleto import Database.Esqueleto.Experimental hiding (from, on) @@ -239,8 +240,9 @@ withConn :: RunDbMonad m => (SqlBackend -> R.ResourceT m a) -> m a withConn = R.runResourceT . withMySQLConn defaultConnectInfo - { connectHost = "localhost" + { connectHost = "127.0.0.1" , connectUser = "travis" - , connectPassword = "" + , connectPassword = "esqutest" , connectDatabase = "esqutest" + , connectPort = 33306 }