pasosdeJesus/msip

View on GitHub
.gitlab-ci.yml

Summary

Maintainability
Test Coverage
# Basado entre otros en: https://dev.to/mpressen/rails-minitest-gitlab-ci-31ap

image: "ruby:3.2.1"

services:
  - name: vtamara/postgis-es_co:13.3-1
    alias: postgres

variables:
  POSTGRES_ENABLED: 'true'
  POSTGRES_USER: runner
  POSTGRES_PASSWORD: ''
  POSTGRES_DB: msipdes_pru
  POSTGRES_HOST_AUTH_METHOD: trust
  RAILS_ENV: test
  BUNDLE_PATH: vendor/bundle
  NOKOGIRI_USE_SYSTEM_LIBRARIES: 'true'
  CC_TEST_REPORTER_ID: "0b795636959c0c2fc716869449d4c0bbe5743d7626dba9235a942a9ba68869cd"
  CI: 'Si'

stages:
  - test
  - dast

test:
  stage: test
  cache:
    paths:
      - apt-cache
      - node_modules
      - vendor/bundle
  before_script:
    - uname -a
    - whoami
    - echo "HOME=${HOME}"
    - pwd
    - which ruby
    - ruby -v
    - export APT_CACHE_DIR=`pwd`/apt-cache && mkdir -pv $APT_CACHE_DIR
    - apt-get update -yy && apt-get install build-essential libpq-dev postgresql-client -y
    - apt install -y poppler-utils  # pdftoppm para presentar portada de anexo
    - which pdftoppm
    - curl -fsSL https://deb.nodesource.com/setup_18.x | bash - # https://www.linuxcapable.com/how-to-install-node-js-14-lts-16-npm-on-debian-11-bullseye/
    - apt install -y -qq nodejs
    - curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
    - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
    - apt-get install -yq gconf-service libasound2 libatk1.0-0 libc6 libcairo2
      libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4
      libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0
      libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 
      libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 
      libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates 
      fonts-liberation libnss3 lsb-release xdg-utils wget libgbm-dev w3m
    - apt-get update -qq && apt-get -o dir::cache::archives="$APT_CACHE_DIR" install -yqq yarn
    - gem install bundler dotenv --no-document
    - bundle install --jobs $(nproc) "${FLAGS[@]}"
    - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
    - chmod +x ./cc-test-reporter
    - ./cc-test-reporter -v
    - ./cc-test-reporter before-build
    - cd test/dummy
    - cp .env.gitlab .env
    - cp db/structure.sql db/structure.sql.copia 
    - sed -e 's/provider = libc,//g;s/SET default_table_access_method.*/-- &/g' db/structure.sql.copia > db/structure.sql 
    - bin/rails db:drop db:create db:setup db:seed
    - bin/rails msip:indices
    - yarn
    - bin/rails msip:stimulus_motores
    - RAILS_ENV=test bin/rails assets:precompile
    - yarn add -D puppeteer
    - for i in `find ./test -name "*js" -type f -exec grep -l "puppeteer-core" {} ';'`; do echo "Remplazando p-c por p en $i"; sed -i -e 's/preparar,//g;import puppeteer from \"puppeteer-core\"/import puppeteer from \"puppeteer\";\nimport {preparar} from \".\/pgitlab.mjs\";/g' $i; cat $i; done
    - cd ../..
  script:
    - bin/regresion.sh
    - export exit_code=$?
  after_script:
    - if (test "${exit_code}" == "") then { exit_code=0; } fi; ./cc-test-reporter after-build -t simplecov --exit-code "${exit_code}" || true


include:
    - template: Security/Dependency-Scanning.gitlab-ci.yml
    - template: Security/License-Scanning.gitlab-ci.yml
    - template: Security/SAST.gitlab-ci.yml
    - template: Security/Secret-Detection.gitlab-ci.yml
    - template: Security/DAST.gitlab-ci.yml
      #    - template: Code-Quality.gitlab-ci.yml