mirror of
https://github.com/aelve/guide.git
synced 2024-12-01 20:54:08 +03:00
0336942072
Frontend E2E tests
178 lines
7.9 KiB
YAML
178 lines
7.9 KiB
YAML
sudo: true
|
|
dist: xenial
|
|
|
|
language: generic
|
|
|
|
addons:
|
|
chrome: stable
|
|
|
|
services:
|
|
- xvfb
|
|
- postgresql
|
|
|
|
before_install:
|
|
- nvm install --lts
|
|
|
|
cache:
|
|
directories:
|
|
- $HOME/.stack
|
|
- .stack-work
|
|
- back/.stack-work
|
|
timeout: 1000
|
|
|
|
jobs:
|
|
include:
|
|
- stage: "Build the backend and upload a Docker image"
|
|
before_script:
|
|
- sudo apt-get install -y libgmp-dev
|
|
- curl -sSL https://get.haskellstack.org/ | sh
|
|
# travis_retry works around https://github.com/commercialhaskell/stack/issues/4888
|
|
- travis_retry stack setup
|
|
# Decrypt the GitHub deploy key (travis_key.enc)
|
|
- openssl aes-256-cbc -k "$travis_key_password" -d -md sha256 -a -in travis_key.enc -out travis_key
|
|
- echo "Host github.com" > ~/.ssh/config
|
|
- echo " IdentityFile $(pwd)/travis_key" >> ~/.ssh/config
|
|
- chmod 400 travis_key
|
|
- git remote set-url origin git@github.com:aelve/guide.git
|
|
script:
|
|
# Build
|
|
- stack --no-terminal build --test --no-run-tests --dependencies-only
|
|
- stack --no-terminal build --test --no-run-tests
|
|
# Regenerate Swagger and push to the same branch, even if the branch
|
|
# is already ahead (which may happen if the previous build in the
|
|
# pipeline also pushed to it)
|
|
- |
|
|
if [ "$TRAVIS_EVENT_TYPE" = "push" ]; then
|
|
git checkout "$TRAVIS_BRANCH" && git pull
|
|
stack exec -- guide api-docs > back/swagger.json
|
|
git add back/swagger.json
|
|
# Will only push if the commit was created successfully. Note
|
|
# that we don't use "[skip ci]" in the commit message here
|
|
# because then Mergify goes "oh, but Travis hasn't passed, so I
|
|
# shouldn't merge this".
|
|
(git commit -m "Regenerate swagger.json" && git push) || true
|
|
git checkout "$TRAVIS_COMMIT"
|
|
fi
|
|
# Upload the Docker image
|
|
- |
|
|
if [ "$TRAVIS_EVENT_TYPE" = "push" ]; then
|
|
export BRANCH="$(echo "$TRAVIS_BRANCH" | tr '/' '-')"
|
|
make back/travis-docker "tag=$BRANCH--back"
|
|
docker login quay.io -u "$DOCKER_USER" -p "$DOCKER_PASS"
|
|
docker push "quay.io/aelve/guide:$BRANCH--back"
|
|
fi
|
|
# Check that no new undocumented definitions are introduced. Our
|
|
# goal is full documented code with ZERO undocumented definitions.
|
|
# This check warns if a commit increases the amount of undocumented
|
|
# definitions (currently 251).
|
|
#
|
|
# First we unregister the package so that Haddocks would be rebuilt
|
|
# from scratch, then we build haddocks and count the lines for
|
|
# "missing documentation".
|
|
- stack --no-terminal exec -- ghc-pkg unregister guide
|
|
- stack --no-terminal build --test --no-run-tests --haddock --no-haddock-deps --haddock-arguments='--no-warnings' 2> haddock.log
|
|
- export undocumented=$(awk '/\(src\// {count++} END{print count}' haddock.log)
|
|
- |
|
|
echo "Undocumented definitions: $undocumented"
|
|
- |
|
|
if [ $undocumented -gt 251 ]; then
|
|
>&2 echo "FAIL: found $undocumented top-level undocumented definitions. The current limit is 251. Please, add Haddock comments to undocumented definitions!"
|
|
exit 1
|
|
fi
|
|
before_cache:
|
|
- rm -rf $HOME/.stack/programs # GHC is faster to install than to cache
|
|
|
|
- stage: "Build the frontend and upload a Docker image, test frontend"
|
|
- name: "Build the frontend and upload a Docker image"
|
|
script:
|
|
# Build
|
|
- cd front
|
|
- npm install
|
|
- npm run build
|
|
- cd -
|
|
# Upload the Docker image
|
|
- |
|
|
if [ "$TRAVIS_EVENT_TYPE" = "push" ]; then
|
|
export BRANCH="$(echo "$TRAVIS_BRANCH" | tr '/' '-')"
|
|
make front/travis-docker "tag=$BRANCH--front"
|
|
docker login quay.io -u "$DOCKER_USER" -p "$DOCKER_PASS"
|
|
docker push "quay.io/aelve/guide:$BRANCH--front"
|
|
fi
|
|
|
|
- name: "Test frontend prod desktop"
|
|
script:
|
|
- node -v
|
|
- . ./scripts/ci-functions.sh
|
|
- cd front
|
|
- npm install
|
|
- npm run build
|
|
- export BRANCH="$(echo "$TRAVIS_BRANCH" | tr '/' '-')"
|
|
- run_back $BRANCH
|
|
- API_URL=http://localhost:4400/ npm run test:prod
|
|
|
|
- name: "Test frontend dev desktop"
|
|
script:
|
|
- . ./scripts/ci-functions.sh
|
|
- cd front
|
|
- npm install
|
|
- export BRANCH="$(echo "$TRAVIS_BRANCH" | tr '/' '-')"
|
|
- run_back $BRANCH
|
|
- API_URL=http://localhost:4400/ npm run test:dev
|
|
|
|
- name: "Test frontend prod mobile"
|
|
script:
|
|
- . ./scripts/ci-functions.sh
|
|
- cd front
|
|
- npm install
|
|
- npm run build
|
|
- export BRANCH="$(echo "$TRAVIS_BRANCH" | tr '/' '-')"
|
|
- run_back $BRANCH
|
|
- API_URL=http://localhost:4400/ npm run test:prod:mobile
|
|
|
|
- name: "Test frontend dev mobile"
|
|
script:
|
|
- . ./scripts/ci-functions.sh
|
|
- cd front
|
|
- npm install
|
|
- export BRANCH="$(echo "$TRAVIS_BRANCH" | tr '/' '-')"
|
|
- run_back $BRANCH
|
|
- API_URL=http://localhost:4400/ npm run test:dev:mobile
|
|
|
|
|
|
- stage: "Test the backend"
|
|
before_script:
|
|
- google-chrome-stable --headless --dis able-gpu --remote-debugging-port=5000 http://localhost &
|
|
- sudo apt-get install -y libgmp-dev fluxbox
|
|
- curl -sSL https://get.haskellstack.org/ | sh
|
|
# travis_retry works around https://github.com/commercialhaskell/stack/issues/4888
|
|
- travis_retry stack setup
|
|
# Install chromedriver
|
|
- wget https://chromedriver.storage.googleapis.com/78.0.3904.70/chromedriver_linux64.zip
|
|
- unzip chromedriver_linux64.zip
|
|
- chmod +x chromedriver
|
|
- sudo mv -f chromedriver /usr/local/share/chromedriver
|
|
- sudo ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver
|
|
- sudo ln -s /usr/local/share/chromedriver /usr/bin/chromedriver
|
|
# Run selenium-server
|
|
- travis_retry wget https://selenium-release.storage.googleapis.com/3.141/selenium-server-standalone-3.141.59.jar -O selenium.jar
|
|
- java -jar selenium.jar 2> /dev/null &
|
|
- sleep 15
|
|
# Create database
|
|
- psql -c 'create database guide;' -U postgres
|
|
script:
|
|
- stack --no-terminal test
|
|
- make back/test-db
|
|
- make back/load-into-postgres
|
|
before_cache:
|
|
- rm -rf $HOME/.stack/programs # GHC is faster to install than to cache
|
|
|
|
notifications:
|
|
slack:
|
|
secure: BgQpUYFmvXrf7HVBP/fefS/8UVwES800+fT+ufgJX8b2HMx2FvaWVsdv3ErKAryLE0B3fwmvforWugTdgLO3kq66YUgSt51SNQOBLkMVGubIoQsgvr3Ernu+Wpw1DyoMkXQH9q9O9rfCIc4IwkQCEHqu5SVRqdOd5px/CHFl/ktTI22JkT8ap/Be53qjlB2U2sWUf4GxYXq0V/gGF6fDwsUwTVKFb14RfSDrOgK5Vlce2GRf3gNr1C/j7A7EHIR/Z+rNd2hvv69cFw6TRc3s39QmP8XPe3SLZPIHTZ8vRveX1SZioMeEy747r5rHd9vylEjxWtVHhvP9fOt693+woXa8ZAl5uVRgB6S4mTWLZ+LAbqhaCmDGJYr9GrrBMoqWvJiMuBX3ZvHptsAc6O2l/fxZQU3otTE++SmHkhbyoDQkcPCjXPDUi/ZlnoLc5zfMAfApcsZZ8b9t47z12H0O4uDZd2YiNPiQJ1iUA6R879LH3pcxPB3RaoWsfXzv/klkKrU/V2K4SXD9j4/bmAFArlig+dar+Dm44L/a3/G7vbU1lQIa1bG0EqB36qgUS3UCkuy2ppti/JTHpkYx7HVF2BipoCjOVvfBl9G8RkvcQIhyuCfOGm7WL1TjrKVMccIEGJKhm7OO6wOZYCBfAI5zILxi8XEJAIvBm9NywhQlwxI=
|
|
|
|
# travis_key.enc decryption password, see:
|
|
# http://markbucciarelli.com/posts/2019-01-26_how-to-push-to-github-from-travis-ci.html
|
|
env:
|
|
matrix:
|
|
secure: RqWbR4JjNKL5+KS6um6R2xKRGMxYO4qxRdI/RFi5oHsjRwKAQPGATb00Zmd84V/jaVb+NOccG1qp0/SNVwAaFf6Yr1MO9aV3GKC0fDFwSffKLdtVO2yx/JHrRYZ2ymrjEkBGug1FMrHFGZsSLaZYsYKx974tBs04xwAmPv6Yby8bZTGJyknbuyIMeSe6XZIkinyKaw/Zay6QC2CtSLoX50gqY2/HX0fVBgWKDNStigH0UEEynSetRYm/PFRcoBwu3XmHW89Y9B0E/zgvnvFuAgMVmZSUZnD9wBRlnFvfC1pUaFZP8Tz2VZhcJ4xTRTq+r3t2IRTNQBIhlQseobQMxoTrv1Y/ZiEmO14CLSwy3yeX5vCiGmCaA3957FqnjTP07svbru/A0qWMyEtuBtpheCVbQSVvMUBnrl0txTMFiBb4dsJ7zWrp3f7RQ8SFB11FwpGv89d+FifOpXN42DWRXjU0fLCPs8S5iKODWkTSQ41vpGXXUoZdaUOUg1y6tZSoc8gs61KlhcDTrBI2ZCJMNY6c6JVE/BOnJrp6zqyKhY2znyJUodEvjPsy9iccmrt0bEZTVshzbW4Q9okQ26usNtwIJoHNDUdifpmMcobb/ATYEr+C7n9ztxRy9AnZLzp6SsCDlfSDDp32fr7762PMk+2jR9w7fMrR/PBMtDXNsYQ=
|