669 lines
33 KiB
YAML

name: gradido test CI
on:
push:
branches:
- 2352-feat-user-story-user-authentication-reset-password
jobs:
##############################################################################
# JOB: DOCKER BUILD TEST FRONTEND ############################################
##############################################################################
build_test_frontend:
name: Docker Build Test - Frontend
runs-on: ubuntu-latest
#needs: [nothing]
steps:
##########################################################################
# CHECKOUT CODE ##########################################################
##########################################################################
- name: Checkout code
uses: actions/checkout@v3
##########################################################################
# FRONTEND ###############################################################
##########################################################################
- name: Frontend | Build `test` image
run: |
docker build --target test -t "gradido/frontend:test" frontend/
docker save "gradido/frontend:test" > /tmp/frontend.tar
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: docker-frontend-test
path: /tmp/frontend.tar
##############################################################################
# JOB: DOCKER BUILD TEST ADMIN INTERFACE #####################################
##############################################################################
build_test_admin:
name: Docker Build Test - Admin Interface
runs-on: ubuntu-latest
steps:
##########################################################################
# CHECKOUT CODE ##########################################################
##########################################################################
- name: Checkout code
uses: actions/checkout@v3
##########################################################################
# ADMIN INTERFACE ########################################################
##########################################################################
- name: Admin | Build `test` image
run: |
docker build --target test -t "gradido/admin:test" admin/ --build-arg NODE_ENV="test"
docker save "gradido/admin:test" > /tmp/admin.tar
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: docker-admin-test
path: /tmp/admin.tar
##############################################################################
# JOB: DOCKER BUILD TEST BACKEND #############################################
##############################################################################
# build_test_backend:
# name: Docker Build Test - Backend
# runs-on: ubuntu-latest
# #needs: [nothing]
# steps:
# ##########################################################################
# # CHECKOUT CODE ##########################################################
# ##########################################################################
# - name: Checkout code
# uses: actions/checkout@v3
# ##########################################################################
# # BACKEND ################################################################
# ##########################################################################
# - name: Backend | Build `test` image
# run: |
# docker build -f ./backend/Dockerfile --target test -t "gradido/backend:test" .
# docker save "gradido/backend:test" > /tmp/backend.tar
# - name: Upload Artifact
# uses: actions/upload-artifact@v3
# with:
# name: docker-backend-test
# path: /tmp/backend.tar
##############################################################################
# JOB: DOCKER BUILD TEST DATABASE UP #########################################
##############################################################################
build_test_database_up:
name: Docker Build Test - Database up
runs-on: ubuntu-latest
#needs: [nothing]
steps:
##########################################################################
# CHECKOUT CODE ##########################################################
##########################################################################
- name: Checkout code
uses: actions/checkout@v3
##########################################################################
# DATABASE UP ############################################################
##########################################################################
- name: Database | Build `test_up` image
run: |
docker build --target test_up -t "gradido/database:test_up" database/
docker save "gradido/database:test_up" > /tmp/database_up.tar
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: docker-database-test_up
path: /tmp/database_up.tar
##############################################################################
# JOB: DOCKER BUILD TEST MARIADB #############################################
##############################################################################
build_test_mariadb:
name: Docker Build Test - MariaDB
runs-on: ubuntu-latest
#needs: [nothing]
steps:
##########################################################################
# CHECKOUT CODE ##########################################################
##########################################################################
- name: Checkout code
uses: actions/checkout@v3
##########################################################################
# BUILD MARIADB DOCKER IMAGE #############################################
##########################################################################
- name: mariadb | Build `test` image
run: |
docker build --target mariadb_server -t "gradido/mariadb:test" -f ./mariadb/Dockerfile ./
docker save "gradido/mariadb:test" > /tmp/mariadb.tar
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: docker-mariadb-test
path: /tmp/mariadb.tar
##############################################################################
# JOB: DOCKER BUILD TEST NGINX ###############################################
##############################################################################
build_test_nginx:
name: Docker Build Test - Nginx
runs-on: ubuntu-latest
steps:
##########################################################################
# CHECKOUT CODE ##########################################################
##########################################################################
- name: Checkout code
uses: actions/checkout@v3
##########################################################################
# BUILD NGINX DOCKER IMAGE ###############################################
##########################################################################
- name: nginx | Build `test` image
run: |
docker build -t "gradido/nginx:test" nginx/
docker save "gradido/nginx:test" > /tmp/nginx.tar
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: docker-nginx-test
path: /tmp/nginx.tar
##############################################################################
# JOB: LOCALES FRONTEND ######################################################
##############################################################################
# locales_frontend:
# name: Locales - Frontend
# runs-on: ubuntu-latest
# needs: [build_test_frontend]
# steps:
# ##########################################################################
# # CHECKOUT CODE ##########################################################
# ##########################################################################
# - name: Checkout code
# uses: actions/checkout@v3
# ##########################################################################
# # DOWNLOAD DOCKER IMAGE ##################################################
# ##########################################################################
# - name: Download Docker Image (Frontend)
# uses: actions/download-artifact@v3
# with:
# name: docker-frontend-test
# path: /tmp
# - name: Load Docker Image
# run: docker load < /tmp/frontend.tar
# ##########################################################################
# # LOCALES FRONTEND #######################################################
# ##########################################################################
# - name: Frontend | Locales
# run: docker run --rm gradido/frontend:test yarn run locales
##############################################################################
# JOB: LINT FRONTEND #########################################################
##############################################################################
# lint_frontend:
# name: Lint - Frontend
# runs-on: ubuntu-latest
# needs: [build_test_frontend]
# steps:
# ##########################################################################
# # CHECKOUT CODE ##########################################################
# ##########################################################################
# - name: Checkout code
# uses: actions/checkout@v3
# ##########################################################################
# # DOWNLOAD DOCKER IMAGE ##################################################
# ##########################################################################
# - name: Download Docker Image (Frontend)
# uses: actions/download-artifact@v3
# with:
# name: docker-frontend-test
# path: /tmp
# - name: Load Docker Image
# run: docker load < /tmp/frontend.tar
# ##########################################################################
# # LINT FRONTEND ##########################################################
# ##########################################################################
# - name: Frontend | Lint
# run: docker run --rm gradido/frontend:test yarn run lint
##############################################################################
# JOB: STYLELINT FRONTEND ####################################################
##############################################################################
# stylelint_frontend:
# name: Stylelint - Frontend
# runs-on: ubuntu-latest
# needs: [build_test_frontend]
# steps:
# ##########################################################################
# # CHECKOUT CODE ##########################################################
# ##########################################################################
# - name: Checkout code
# uses: actions/checkout@v3
# ##########################################################################
# # DOWNLOAD DOCKER IMAGE ##################################################
# ##########################################################################
# - name: Download Docker Image (Frontend)
# uses: actions/download-artifact@v3
# with:
# name: docker-frontend-test
# path: /tmp
# - name: Load Docker Image
# run: docker load < /tmp/frontend.tar
# ##########################################################################
# # STYLELINT FRONTEND #####################################################
# ##########################################################################
# - name: Frontend | Stylelint
# run: docker run --rm gradido/frontend:test yarn run stylelint
##############################################################################
# JOB: LINT ADMIN INTERFACE ##################################################
##############################################################################
# lint_admin:
# name: Lint - Admin Interface
# runs-on: ubuntu-latest
# needs: [build_test_admin]
# steps:
# ##########################################################################
# # CHECKOUT CODE ##########################################################
# ##########################################################################
# - name: Checkout code
# uses: actions/checkout@v3
# ##########################################################################
# # DOWNLOAD DOCKER IMAGE ##################################################
# ##########################################################################
# - name: Download Docker Image (Admin Interface)
# uses: actions/download-artifact@v3
# with:
# name: docker-admin-test
# path: /tmp
# - name: Load Docker Image
# run: docker load < /tmp/admin.tar
# ##########################################################################
# # LINT ADMIN INTERFACE ###################################################
# ##########################################################################
# - name: Admin Interface | Lint
# run: docker run --rm gradido/admin:test yarn run lint
##############################################################################
# JOB: STYLELINT ADMIN INTERFACE ##############################################
##############################################################################
# stylelint_admin:
# name: Stylelint - Admin Interface
# runs-on: ubuntu-latest
# needs: [build_test_admin]
# steps:
# ##########################################################################
# # CHECKOUT CODE ##########################################################
# ##########################################################################
# - name: Checkout code
# uses: actions/checkout@v3
# ##########################################################################
# # DOWNLOAD DOCKER IMAGE ##################################################
# ##########################################################################
# - name: Download Docker Image (Admin Interface)
# uses: actions/download-artifact@v3
# with:
# name: docker-admin-test
# path: /tmp
# - name: Load Docker Image
# run: docker load < /tmp/admin.tar
# ##########################################################################
# # STYLELINT ADMIN INTERFACE ##############################################
# ##########################################################################
# - name: Admin Interface | Stylelint
# run: docker run --rm gradido/admin:test yarn run stylelint
##############################################################################
# JOB: LOCALES ADMIN #########################################################
##############################################################################
# locales_admin:
# name: Locales - Admin Interface
# runs-on: ubuntu-latest
# needs: [build_test_admin]
# steps:
# ##########################################################################
# # CHECKOUT CODE ##########################################################
# ##########################################################################
# - name: Checkout code
# uses: actions/checkout@v3
# ##########################################################################
# # DOWNLOAD DOCKER IMAGE ##################################################
# ##########################################################################
# - name: Download Docker Image (Admin Interface)
# uses: actions/download-artifact@v3
# with:
# name: docker-admin-test
# path: /tmp
# - name: Load Docker Image
# run: docker load < /tmp/admin.tar
# ##########################################################################
# # LOCALES FRONTEND #######################################################
# ##########################################################################
# - name: admin | Locales
# run: docker run --rm gradido/admin:test yarn run locales
##############################################################################
# JOB: LINT BACKEND ##########################################################
##############################################################################
# lint_backend:
# name: Lint - Backend
# runs-on: ubuntu-latest
# needs: [build_test_backend]
# steps:
# ##########################################################################
# # CHECKOUT CODE ##########################################################
# ##########################################################################
# - name: Checkout code
# uses: actions/checkout@v3
# ##########################################################################
# # DOWNLOAD DOCKER IMAGE ##################################################
# ##########################################################################
# - name: Download Docker Image (Backend)
# uses: actions/download-artifact@v3
# with:
# name: docker-backend-test
# path: /tmp
# - name: Load Docker Image
# run: docker load < /tmp/backend.tar
# ##########################################################################
# # LINT BACKEND ###########################################################
# ##########################################################################
# - name: backend | Lint
# run: docker run --rm gradido/backend:test yarn run lint
##############################################################################
# JOB: LINT DATABASE UP ######################################################
##############################################################################
# lint_database_up:
# name: Lint - Database Up
# runs-on: ubuntu-latest
# needs: [build_test_database_up]
# steps:
# ##########################################################################
# # CHECKOUT CODE ##########################################################
# ##########################################################################
# - name: Checkout code
# uses: actions/checkout@v3
# ##########################################################################
# # DOWNLOAD DOCKER IMAGE ##################################################
# ##########################################################################
# - name: Download Docker Image (Backend)
# uses: actions/download-artifact@v3
# with:
# name: docker-database-test_up
# path: /tmp
# - name: Load Docker Image
# run: docker load < /tmp/database_up.tar
# ##########################################################################
# # LINT DATABASE ##########################################################
# ##########################################################################
# - name: database | Lint
# run: docker run --rm gradido/database:test_up yarn run lint
##############################################################################
# JOB: UNIT TEST FRONTEND ###################################################
##############################################################################
# unit_test_frontend:
# name: Unit tests - Frontend
# runs-on: ubuntu-latest
# needs: [build_test_frontend]
# steps:
# ##########################################################################
# # CHECKOUT CODE ##########################################################
# ##########################################################################
# - name: Checkout code
# uses: actions/checkout@v3
# ##########################################################################
# # DOWNLOAD DOCKER IMAGES #################################################
# ##########################################################################
# - name: Download Docker Image (Frontend)
# uses: actions/download-artifact@v3
# with:
# name: docker-frontend-test
# path: /tmp
# - name: Load Docker Image
# run: docker load < /tmp/frontend.tar
# ##########################################################################
# # UNIT TESTS FRONTEND ####################################################
# ##########################################################################
# - name: frontend | Unit tests
# run: |
# docker run --env NODE_ENV=test -v ~/coverage:/app/coverage --rm gradido/frontend:test yarn run test
# cp -r ~/coverage ./coverage
# ##########################################################################
# # COVERAGE REPORT FRONTEND ###############################################
# ##########################################################################
# #- name: frontend | Coverage report
# # uses: romeovs/lcov-reporter-action@v0.2.21
# # with:
# # github-token: ${{ secrets.GITHUB_TOKEN }}
# # lcov-file: ./coverage/lcov.info
# ##########################################################################
# # COVERAGE CHECK FRONTEND ################################################
# ##########################################################################
# - name: frontend | Coverage check
# uses: webcraftmedia/coverage-check-action@master
# with:
# report_name: Coverage Frontend
# type: lcov
# result_path: ./coverage/lcov.info
# min_coverage: 95
# token: ${{ github.token }}
##############################################################################
# JOB: UNIT TEST ADMIN INTERFACE #############################################
##############################################################################
# unit_test_admin:
# name: Unit tests - Admin Interface
# runs-on: ubuntu-latest
# needs: [build_test_admin]
# steps:
# ##########################################################################
# # CHECKOUT CODE ##########################################################
# ##########################################################################
# - name: Checkout code
# uses: actions/checkout@v3
# ##########################################################################
# # DOWNLOAD DOCKER IMAGES #################################################
# ##########################################################################
# - name: Download Docker Image (Admin Interface)
# uses: actions/download-artifact@v3
# with:
# name: docker-admin-test
# path: /tmp
# - name: Load Docker Image
# run: docker load < /tmp/admin.tar
# ##########################################################################
# # UNIT TESTS ADMIN INTERFACE #############################################
# ##########################################################################
# - name: Admin Interface | Unit tests
# run: |
# docker run -v ~/coverage:/app/coverage --rm gradido/admin:test yarn run test
# cp -r ~/coverage ./coverage
# ##########################################################################
# # COVERAGE CHECK ADMIN INTERFACE #########################################
# ##########################################################################
# - name: Admin Interface | Coverage check
# uses: webcraftmedia/coverage-check-action@master
# with:
# report_name: Coverage Admin Interface
# type: lcov
# result_path: ./coverage/lcov.info
# min_coverage: 96
# token: ${{ github.token }}
##############################################################################
# JOB: UNIT TEST BACKEND ####################################################
##############################################################################
# unit_test_backend:
# name: Unit tests - Backend
# runs-on: ubuntu-latest
# needs: [build_test_mariadb]
# steps:
# ##########################################################################
# # CHECKOUT CODE ##########################################################
# ##########################################################################
# - name: Checkout code
# uses: actions/checkout@v3
# ##########################################################################
# # DOWNLOAD DOCKER IMAGES #################################################
# ##########################################################################
# - name: Download Docker Image (Mariadb)
# uses: actions/download-artifact@v3
# with:
# name: docker-mariadb-test
# path: /tmp
# - name: Load Docker Image
# run: docker load < /tmp/mariadb.tar
# ##########################################################################
# # UNIT TESTS BACKEND #####################################################
# ##########################################################################
# - name: backend | docker-compose mariadb
# run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps mariadb
# - name: Sleep for 30 seconds
# run: sleep 30s
# shell: bash
# - name: backend | docker-compose database
# run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps database
# - name: backend Unit tests | test
# run: cd database && yarn && yarn build && cd ../backend && yarn && yarn test
# # run: docker-compose -f docker-compose.yml -f docker-compose.test.yml exec -T backend yarn test
# ##########################################################################
# # COVERAGE CHECK BACKEND #################################################
# ##########################################################################
# - name: backend | Coverage check
# uses: webcraftmedia/coverage-check-action@master
# with:
# report_name: Coverage Backend
# type: lcov
# result_path: ./backend/coverage/lcov.info
# min_coverage: 78
# token: ${{ github.token }}
##########################################################################
# DATABASE MIGRATION TEST UP + RESET #####################################
##########################################################################
# database_migration_test:
# name: Database Migration Test - Up + Reset
# runs-on: ubuntu-latest
# #needs: [nothing]
# steps:
# ##########################################################################
# # CHECKOUT CODE ##########################################################
# ##########################################################################
# - name: Checkout code
# uses: actions/checkout@v3
# ##########################################################################
# # DOCKER COMPOSE DATABASE UP + RESET #####################################
# ##########################################################################
# - name: database | docker-compose
# run: docker-compose -f docker-compose.yml up --detach mariadb
# - name: database | up
# run: docker-compose -f docker-compose.yml run -T database yarn up
# - name: database | reset
# run: docker-compose -f docker-compose.yml run -T database yarn reset
##############################################################################
# JOB: END-TO-END TESTS #####################################################
##############################################################################
end-to-end-tests:
name: End-to-End Tests
runs-on: ubuntu-latest
needs: [build_test_mariadb, build_test_database_up, build_test_admin, build_test_frontend, build_test_nginx]
steps:
##########################################################################
# CHECKOUT CODE ##########################################################
##########################################################################
- name: Checkout code
uses: actions/checkout@v3
##########################################################################
# DOWNLOAD DOCKER IMAGES #################################################
##########################################################################
- name: Download Docker Image (Mariadb)
uses: actions/download-artifact@v3
with:
name: docker-mariadb-test
path: /tmp
- name: Load Docker Image (Mariadb)
run: docker load < /tmp/mariadb.tar
- name: Download Docker Image (Database Up)
uses: actions/download-artifact@v3
with:
name: docker-database-test_up
path: /tmp
- name: Load Docker Image (Database Up)
run: docker load < /tmp/database_up.tar
# - name: Download Docker Image (Backend)
# uses: actions/download-artifact@v3
# with:
# name: docker-backend-test
# path: /tmp
# - name: Load Docker Image (Backend)
# run: docker load < /tmp/backend.tar
- name: Download Docker Image (Frontend)
uses: actions/download-artifact@v3
with:
name: docker-frontend-test
path: /tmp
- name: Load Docker Image (Frontend)
run: docker load < /tmp/frontend.tar
- name: Download Docker Image (Admin Interface)
uses: actions/download-artifact@v3
with:
name: docker-admin-test
path: /tmp
- name: Load Docker Image (Admin Interface)
run: docker load < /tmp/admin.tar
- name: Download Docker Image (Nginx)
uses: actions/download-artifact@v3
with:
name: docker-nginx-test
path: /tmp
- name: Load Docker Image (Nginx)
run: docker load < /tmp/nginx.tar
##########################################################################
# BOOT UP THE TEST SYSTEM ################################################
##########################################################################
- name: Boot up test system | docker-compose mariadb
run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach mariadb
- name: Boot up test system | docker-compose database
run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps database
- name: Boot up test system | docker-compose backend
run: |
cd backend
cp .env.test_e2e .env
cd ..
docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps backend
- name: Sleep for 10 seconds
run: sleep 10s
- name: Boot up test system | seed backend
run: |
sudo chown runner:docker -R *
cd database
yarn && yarn dev_reset
cd ../backend
yarn && yarn seed
cd ..
- name: Boot up test system | docker-compose frontends
run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps frontend admin nginx
- name: Boot up test system | docker-compose frontends
run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps mailserver
- name: Sleep for 15 seconds
run: sleep 15s
##########################################################################
# END-TO-END TESTS #######################################################
##########################################################################
- name: End-to-end tests | run tests
id: e2e-tests
run: |
cd e2e-tests/cypress/tests/
yarn
yarn run cypress run --spec cypress/e2e/User.Authentication.feature,cypress/e2e/User.Authentication.ResetPassword.feature
- name: End-to-end tests | if tests failed, upload screenshots
if: ${{ failure() && steps.e2e-tests.conclusion == 'failure' }}
uses: actions/upload-artifact@v3
with:
name: cypress-screenshots
path: /home/runner/work/gradido/gradido/e2e-tests/cypress/tests/cypress/screenshots/