This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects
.gitlab-ci.yml 8.97 KiB
Newer Older
Michael Breu's avatar
Michael Breu committed
image: sharing-codeability.uibk.ac.at:5051/development/sharing/codeability-sharing-platform/root-jhipster
cache: &global_cache
Eduard Frankford's avatar
Eduard Frankford committed
  key: '$CI_COMMIT_REF_SLUG'
Eduard Frankford's avatar
Eduard Frankford committed
    - .npm/
  policy: pull-push

Lukas Kaltenbrunner's avatar
Lukas Kaltenbrunner committed
stages:
  - lint
  - build
  - test
  - analyze
  - release
Eduard Frankford's avatar
Eduard Frankford committed
  - deploy
  - e2e
  - releaseProd
  - deployProd
Lukas Kaltenbrunner's avatar
Lukas Kaltenbrunner committed
before_script:
  - export NG_CLI_ANALYTICS="false"
  - export MAVEN_USER_HOME=`pwd`/.maven

include:
  - template: Jobs/Secret-Detection.gitlab-ci.yml

secret_detection:
  variables:
    GIT_DEPTH: 100
    SECRET_DETECTION_LOG_OPTIONS: ${CI_MERGE_REQUEST_DIFF_BASE_SHA}..${CI_COMMIT_SHA}
  script:
    - apk add jq
    - /analyzer run
    - NUMBER_OF_VULNERABILITIES=$(cat gl-secret-detection-report.json | jq --raw-output '.vulnerabilities | length')
    - if [[ $NUMBER_OF_VULNERABILITIES -gt 0 ]]; then exit "1"; fi
  allow_failure: false
  artifacts:
    paths: [gl-secret-detection-report.json]
    when: always

pmdCheckstylePrettierLint:
  stage: lint
  cache: []
  when: always
  script:
    - 'export VERSION="6.40.0"'
    - 'wget "https://github.com/pmd/pmd/releases/download/pmd_releases%2F$VERSION/pmd-bin-$VERSION.zip"'
    - 'jar -xf "pmd-bin-$VERSION.zip"'
    - 'chmod u+x "pmd-bin-$VERSION/bin/run.sh"'
    - SUCCESS=true
    - echo "Running PMD"
    - '"pmd-bin-$VERSION/bin/run.sh" pmd -d src/main/java -f textcolor -R pmd_rules.xml -no-cache 2>&1 | tee pmd.log || SUCCESS=false'
    - echo "Running checkstyle"
    - ./mvnw -ntp checkstyle:check -Dmaven.repo.local=$MAVEN_USER_HOME || SUCCESS=false
    - echo "Running prettier"
Michael Breu's avatar
Michael Breu committed
    - node --version; npm --version
    - npm install
    - npm run prettier:check
    - echo "Running eslint"
    - 'npm run lint | tee lint.log'
    - "! grep -qE '✖ [0-9]+ problem' lint.log || SUCCESS=false"
    - $SUCCESS
  needs: []
  artifacts:
    when: on_failure
    expire_in: 2 days
Michael Breu's avatar
Michael Breu committed
      - lint.log
maven-compile:
  stage: build
  script:
    - ./mvnw -ntp compile -P-webapp -Dmaven.repo.local=$MAVEN_USER_HOME
  needs: []
  cache: []
maven-test:
  services:
    - docker:20-dind
  variables:
    DOCKER_HOST: 'tcp://docker:2375'
    DOCKER_TLS_CERTDIR: ''
    # APPLICATION_GITLAB_ADMINACCESSTOKEN: $APPLICATION_GITLAB_ADMINACCESSTOKEN
    # APPLICATION_GITLAB_GENERALACCESSTOKEN: $APPLICATION_GITLAB_GENERALACCESSTOKEN
  stage: test
  cache:
    # inherit all global cache settings
    <<: *global_cache
    # override the policy
    policy: pull
  script:
    - java --version
    - ./mvnw -ntp verify -P-webapp -Dmaven.repo.local=$MAVEN_USER_HOME -Dapplication.gitlab.guestAccessToken=$APPLICATION_GITLAB_GENERALACCESSTOKEN -Dapplication.gitlab.adminAccessToken=$APPLICATION_GITLAB_ADMINACCESSTOKEN -Dspring.profiles.active=testcontainers
  allow_failure: true
  artifacts:
    reports:
      junit:
        - target/surefire-reports/TEST-*.xml
        - target/failsafe-reports/TEST-*.xml
    paths:
      - target/surefire-reports
      - target/failsafe-reports
      - target/site
    when: always
    expire_in: 2 days
  before_script:
    - export APPLICATION_GITLAB_ADMINACCESSTOKEN=$APPLICATION_GITLAB_ADMINACCESSTOKEN
    - export APPLICATION_GITLAB_GENERALACCESSTOKEN=$APPLICATION_GITLAB_GENERALACCESSTOKEN
Eduard Frankford's avatar
Eduard Frankford committed
    - export MAIL_FROM=no-reply@uibk.ac.at
frontend-test:
  stage: test
  cache:
    <<: *global_cache
    policy: pull
  script:
    - npm test
  artifacts:
    reports:
      junit: target/test-results/TESTS-results-jest.xml
    paths:
      - target/test-results
    when: always
    expire_in: 2 days
  needs: []
  before_script:
    - export NG_CLI_ANALYTICS="false"
    - export MAVEN_USER_HOME=`pwd`/.maven
    - npm ci --cache .npm --prefer-offline
Eduard Frankford's avatar
Eduard Frankford committed

Eduard Frankford's avatar
Eduard Frankford committed
deploy:
  stage: deploy
  cache: []
  before_script:
    - mkdir -p ~/.ssh
    - echo "${SSH_BKY_DEPLOY}" > ~/.ssh/id_rsa
    - chmod 700 ~/.ssh/id_rsa
    - eval "$(ssh-agent -s)"
    - ssh-add ~/.ssh/id_rsa
    - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
  variables:
    REGISTRY_URL: sharing-codeability.uibk.ac.at:5051
Michael Breu's avatar
Michael Breu committed
    IMAGE_TAG: sharing-codeability.uibk.ac.at:5051/development/sharing/codeability-sharing-platform/gitsearch/$CI_COMMIT_REF_NAME
Eduard Frankford's avatar
Eduard Frankford committed
  script:
    - ssh contDeploy@codeability-austria -p 1022 "export CI_COMMIT_REF_NAME=$CI_COMMIT_REF_NAME && export COMMIT_DATE=$(git show -s --format=%ct $CI_COMMIT_SHA) && cd gitsearch2/gitsearch && git fetch && git stash && git checkout $CI_COMMIT_REF_NAME && git pull && ./manual_deploy.sh && exit"
deployProd:
  stage: deployProd
  cache: []
  only:
    refs:
      - master
  before_script:
    - mkdir -p ~/.ssh
    - echo "${SSH_BKY_DEPLOY_PROD}" > ~/.ssh/id_rsa
    - chmod 700 ~/.ssh/id_rsa
    - eval "$(ssh-agent -s)"
    - ssh-add ~/.ssh/id_rsa
    - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
  variables:
    REGISTRY_URL: sharing-codeability.uibk.ac.at:5051
    IMAGE_TAG: sharing-codeability.uibk.ac.at:5051/development/sharing/codeability-sharing-platform/gitsearch/$CI_COMMIT_REF_NAME
Eduard Frankford's avatar
Eduard Frankford committed
    - ssh contDeploy@sharing-codeability -p 1022 "export REGISTRY_URL=$REGISTRY_URL export CI_COMMIT_REF_NAME=$CI_COMMIT_REF_NAME && export COMMIT_DATE=$(git show -s --format=%ct $CI_COMMIT_SHA) && cd gitsearch/ && git fetch && git stash && git checkout $CI_COMMIT_REF_NAME && git pull && ./manual_deploy.sh && exit"
  when: manual

e2e-test:
  stage: e2e
  cache:
    # inherit all global cache settings
    <<: *global_cache
    # override the policy
    policy: pull
Eduard Frankford's avatar
Eduard Frankford committed
  # only:
  #   refs:
  #     - development
Eduard Frankford's avatar
Eduard Frankford committed
    - selenium/standalone-chrome:104.0
  dependencies:
    - deploy
  before_script:
    - mkdir -p ~/.ssh
    - echo "${SSH_BKY_DEPLOY}" > ~/.ssh/id_rsa
    - chmod 700 ~/.ssh/id_rsa
    - eval "$(ssh-agent -s)"
    - ssh-add ~/.ssh/id_rsa
    - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
  script:
Cont Deploy's avatar
Cont Deploy committed
    - ssh contDeploy@codeability-austria -p 1022 "export GITBRANCH=$CI_COMMIT_REF_NAME && cd gitsearch && git fetch && git stash && git checkout $CI_COMMIT_REF_NAME && git pull && npm install && export E2E_PASSWORD=$E2E_PASSWORD && npm run e2e:ci --host=selenium__standalone-chrome && exit"
Eduard Frankford's avatar
Eduard Frankford committed
  when: manual

# If you want to update the chromediver and chrome browser for e2e tests add:
# package.json
#"e2e:update-webdriver": "webdriver-manager update --gecko false",
#"postinstall": "npm run e2e:update-webdriver",

#execute in the server as contDeploy
# cd gitsearch2/gitsearch
# delete the existing google-chrome-stable_current_amd64.deb
# - wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
# - sudo dpkg -i google-chrome*.deb

sonar-analyze:
  stage: analyze
  cache:
    # inherit all global cache settings
    <<: *global_cache
    # override the policy
    policy: pull
  variables:
    GIT_STRATEGY: clone # clone entire repo instead of reusing workspace
    GIT_DEPTH: 0 # avoid shallow clone to give sonar all the info it needs
  dependencies:
    - maven-test
    - frontend-test
  script:
    - ./mvnw -ntp org.jacoco:jacoco-maven-plugin:prepare-agent initialize sonar:sonar -Dsonar.organization=codeAbility -Dsonar.host.url=https://qe-sonarqube.uibk.ac.at/ -Dsonar.login=${SONAR_TOKEN_QE} -Dmaven.repo.local=$MAVEN_USER_HOME
  #    - ./mvnw -ntp org.jacoco:jacoco-maven-plugin:prepare-agent initialize sonar:sonar -Dsonar.organization=codeAbility -Dsonar.host.url=https://server.arctis.at/sonar/ -Dsonar.login=${SONAR_TOKEN} -Dmaven.repo.local=$MAVEN_USER_HOME
  allow_failure: true
  before_script:
    - export NG_CLI_ANALYTICS="false"
    - export MAVEN_USER_HOME=`pwd`/.maven
    - npm ci --cache .npm --prefer-offline

sonar-analyze-manual:
  stage: analyze
  cache:
    # inherit all global cache settings
    <<: *global_cache
    # override the policy
    policy: pull
  variables:
    GIT_STRATEGY: clone # clone entire repo instead of reusing workspace
    GIT_DEPTH: 0 # avoid shallow clone to give sonar all the info it needs
  dependencies:
    - maven-test
    - frontend-test
  script:
    - ./mvnw -ntp org.jacoco:jacoco-maven-plugin:prepare-agent initialize sonar:sonar -Dsonar.organization=codeAbility -Dsonar.host.url=https://qe-sonarqube.uibk.ac.at/ -Dsonar.login=${SONAR_TOKEN_QE} -Dmaven.repo.local=$MAVEN_USER_HOME
  #    - ./mvnw -ntp org.jacoco:jacoco-maven-plugin:prepare-agent initialize sonar:sonar -Dsonar.organization=codeAbility -Dsonar.host.url=https://server.arctis.at/sonar/ -Dsonar.login=${SONAR_TOKEN} -Dmaven.repo.local=$MAVEN_USER_HOME
  allow_failure: true
  before_script:
    - export NG_CLI_ANALYTICS="false"
    - export MAVEN_USER_HOME=`pwd`/.maven
    - npm ci --cache .npm --prefer-offline
  when: manual
Michael Breu's avatar
Michael Breu committed

pages:
  tags:
    - python3.7
Michael Breu's avatar
Michael Breu committed
  stage: analyze
Michael Breu's avatar
Michael Breu committed
  before_script:
    - apt-get update
    - apt-get install -y python3-pip python3-sphinx
    - pip3 install sphinx_rtd_theme
    - 'pip3 install -r src/main/docs/requirements-docs.txt'
Michael Breu's avatar
Michael Breu committed
  script:
    - cd src/main/docs
Michael Breu's avatar
Michael Breu committed
    - make html
    - mv -v build/html/ ../../../public/
Michael Breu's avatar
Michael Breu committed
  artifacts:
    paths:
      - public
  only:
    - master
    - development
    - 431-restarbeiten-fur-migration-indexing-von-filehooks-nach-gitsearch
  needs: []