From ca8edfd731ff7e40ffbf35bfbe44521ace92e23e Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Fri, 8 Nov 2019 13:51:04 +0100 Subject: [PATCH] chore: set up backend tests --- .gitlab-ci.yml | 93 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 92 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7a78487ef..025c8aa33 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,14 +1,22 @@ default: image: fpco/stack-build:lts-13.21 +services: + - postgres:latest + variables: STACK_ROOT: "${CI_PROJECT_DIR}/.stack" CHROME_BIN: "/usr/bin/chromium-browser" + POSTGRES_DB: uniworx_test + POSTGRES_USER: uniworx + POSTGRES_PASSWORD: uniworx + PGHOST: postgres stages: - setup - frontend:build - yesod:build + - lint - test npm install: @@ -44,6 +52,16 @@ frontend:build: dependencies: - npm install +frontend:lint: + stage: lint + script: + - npm run frontend:lint + before_script: *npm + needs: + - npm install + dependencies: + - npm install + yesod:build:dev: stage: yesod:build script: @@ -61,12 +79,40 @@ yesod:build:dev: - .stack-work artifacts: paths: - - bin/uniworx + - bin/ name: "${CI_JOB_NAME}" expire_in: "1 week" dependencies: - frontend:build + + only: + - '${CI_COMMIT_REF_SLUG} !~ /^v[0-9].*/' +yesod:build: + stage: yesod:build + script: + - stack build --copy-bins --local-bin-path $(pwd)/bin --flag uniworx:-library-only --flag uniworx:-dev --flag uniworx:pedantic + needs: + - frontend:build + before_script: + - apt-get update + - apt-get install -y --no-install-recommends locales-all + - ln -s $(which g++-7) $(dirname $(which g++-7))/g++ + cache: + key: "${CI_COMMIT_REF_SLUG}" + paths: + - .stack + - .stack-work + artifacts: + paths: + - bin/ + name: "${CI_JOB_NAME}" + dependencies: + - frontend:build + + only: + - '${CI_COMMIT_REF_SLUG} =~ /^v[0-9].*/' + frontend:test: stage: test script: @@ -80,3 +126,48 @@ frontend:test: - apt-get install -y --no-install-recommends chromium-browser dependencies: - npm install + +hlint:dev: + stage: lint + script: + - stack test --fast --flag uniworx:-library-only --flag uniworx:dev --flag uniworx:pedantic uniworx:test:hlint + needs: + - frontend:build + - yesod:build:dev # For caching + before_script: + - apt-get update + - apt-get install -y --no-install-recommends locales-all + - ln -s $(which g++-7) $(dirname $(which g++-7))/g++ + dependencies: + - frontend:build + cache: + key: "${CI_COMMIT_REF_SLUG}" + paths: + - .stack + - .stack-work + + only: + - '${CI_COMMIT_REF_SLUG} !~ /^v[0-9].*/' + +yesod:test:dev: + stage: test + script: + - stack test --coverage --fast --flag uniworx:-library-only --flag uniworx:-dev --flag uniworx:pedantic --skip hlint + needs: + - frontend:build + - yesod:build:dev # For caching + before_script: + - apt-get update + - apt-get install -y --no-install-recommends locales-all + - ln -s $(which g++-7) $(dirname $(which g++-7))/g++ + dependencies: + - frontend:build + cache: + key: "${CI_COMMIT_REF_SLUG}" + paths: + - .stack + - .stack-work + + only: + - '${CI_COMMIT_REF_SLUG} !~ /^v[0-9].*/' +