diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 12e12ffbb2e33dca4488b43c0d3bda1e67242650..3261183472fdeca77bdfd12a03a8c0d277ef2e9b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,148 +1,4 @@ --- -variables: - CI_FOREMAN_PLUGIN: $CI_PROJECT_NAME - CI_FOREMAN_WEB: 'false' - - POSTGRES_DB: test - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - -services: - - name: postgres:13-alpine - alias: db - -image: ruby:2.7 - -lint: - cache: - paths: - - vendor/ruby - when: always - - script: - - gem install bundler -N - - bundle config set path vendor - - bundle install -j $(nproc) --retry=3 - - bundle exec rubocop app/ config/ db/ lib/ -f p -f ju -o junit.xml - - artifacts: - reports: - junit: junit.xml - -test: - parallel: - matrix: - - FOREMAN_VERSION: - # - 2.5-stable - - 3.0-stable - # - 3.1-stable - # - 3.2-stable - # - 3.3-stable - - 3.4-stable - - cache: - key: foreman-$FOREMAN_VERSION - paths: - - vendor/ruby - when: always - - variables: - RAILS_ENV: test - DATABASE_URL: postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@db/$POSTGRES_DB - DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL: "true" - - before_script: - - | - # Set up Foreman for tests - if [ -d "$CI_PROJECT_DIR/test" ]; then - # Set up Ruby build dependencies - apt-get update -yqq - apt-get install -yqq build-essential libcurl4-openssl-dev postgresql-client-13 zlib1g-dev libpq-dev - apt-get install -yqq --no-install-recommends npm - gem install bundler -N - - # Install foreman - FOREMAN_DIR="$(dirname "$CI_PROJECT_DIR")/foreman" - git clone -b "$FOREMAN_VERSION" --depth=1 -- https://github.com/theforeman/foreman "$FOREMAN_DIR" - cd "$FOREMAN_DIR" - bundle config set path "$CI_PROJECT_DIR/vendor" - bundle config set without console development ec2 gce journald libvirt openstack ovirt sqlite vmware - bundle install -j $(nproc) --retry=3 - - # Configure database - bundle exec rake db:create - bundle exec rake db:migrate - - # Install plugin - "echo \"gem '$CI_FOREMAN_PLUGIN', path: '$CI_PROJECT_DIR'\" > bundler.d/local.rb" - bundle install -j $(nproc) --retry=3 - bundle exec rake db:migrate - - if [ "$CI_FOREMAN_WEB" = "true" ]; then - mkdir -p "$CI_PROJECT_DIR/node_modules" - ln -s "$CI_PROJECT_DIR/node_modules" node_modules - npm install --legacy-peer-deps - bundle exec rake webpack:compile - fi - fi - - script: - # Foreman-side tasks - - cd "$FOREMAN_DIR" - - | - if [ -d "$CI_PROJECT_DIR/test" ]; then - bundle exec rake "test:$CI_FOREMAN_PLUGIN" - [ -d 'jenkins/reports' ] && mv jenkins/reports "$CI_PROJECT_DIR" - fi - - artifacts: - reports: - junit: reports/unit/*.xml - -package: - cache: - key: foreman-package - paths: - - vendor/ruby - - node_modules - when: always - - services: [] - before_script: - - | - # Install asset building dependencies if necessary - if [ -d "$CI_PROJECT_DIR/app/assets" ]; then - # Set up Ruby build dependencies - apt-get update -yqq - apt-get install -yqq build-essential libcurl4-openssl-dev zlib1g-dev - apt-get install -yqq --no-install-recommends npm - gem install bundler -N - - # Install foreman - FOREMAN_DIR="$(dirname "$CI_PROJECT_DIR")/foreman" - git clone --depth=1 -- https://github.com/theforeman/foreman "$FOREMAN_DIR" - cd "$FOREMAN_DIR" - bundle config set path "$CI_PROJECT_DIR/vendor" - bundle config set without console development ec2 gce journald libvirt openstack ovirt postgresql sqlite vmware - bundle install -j $(nproc) --retry=3 - - # Install plugin - echo "gem '$CI_FOREMAN_PLUGIN', path: '$CI_PROJECT_DIR'" > bundler.d/local.rb - bundle install -j $(nproc) --retry=3 - cd "$CI_PROJECT_DIR" - fi - - script: - - | - # Precompile any existing assets - if [ -d "$CI_PROJECT_DIR/app/assets" ]; then - cd "$FOREMAN_DIR" - RAILS_ENV=production bundle exec rake "plugin:assets:precompile[$CI_FOREMAN_PLUGIN]" - cd "$CI_PROJECT_DIR" - fi - - gem build $CI_FOREMAN_PLUGIN.gemspec - - artifacts: - paths: - - '*.gem' - - 'public' +include: + - project: ITI/ci-pipelines + file: '/foreman-module.yaml'