I’ve been tasked with building an integration testing platform for a webapp that uses a Ruby on Rails backend and a React frontend (one-to-one relationship). Basically, I want to “boot up” the Rails server when running my frontend pipeline to be able to send requests and receive responses.
Here’s the ci we’re using at the frontend (without integration testing)
image: node:14.18.0
stages:
- install
- test
- approve
- deploy
install_packages:
stage: install
before_script:
- node -v
script:
- yarn install
cache:
key: ${CI_BUILD_REF_NAME}
paths:
- node_modules/
artifacts:
paths:
- node_modules/
test:
stage: test
script:
- yarn lint
- yarn test:nowatch
deploy-app-to-develop:
stage: deploy
before_script:
- export NODE_OPTIONS=--max_old_space_size=4096
script:
- yarn global add firebase-tools
- yarn build
- firebase deploy --only hosting:staging --token $FIREBASE_TOKEN
only:
- develop_nala
approve:
stage: approve
script:
- echo Approved to master
when: manual
allow_failure: false
only:
- master
deploy-app-to-production:
stage: deploy
script:
- yarn global add firebase-tools
- yarn build:prod
- firebase deploy --only hosting:production --token $FIREBASE_TOKEN
only:
- master
and this is the one for backend
# Official language image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/ruby/tags/
image: "ruby:2.7.1-alpine3.10"
stages:
- rspec
- approve
- deploy
# Cache gems in between builds
cache:
paths:
- vendor/ruby
# This is a basic example for a gem or script which doesn't use
# services such as redis or postgres
before_script:
- ruby -v # Print out ruby version for debugging
# Uncomment next line if your rails app needs a JS runtime:
# - apt-get update -q && apt-get install nodejs -yqq
- bundle config set path 'vendor'
- apk add git
- apk add --no-cache openssh
- apk add --no-cache build-base
- apk add --no-cache postgresql-libs
- apk add --no-cache --virtual .build-deps gcc musl-dev postgresql-dev
- gem install nokogiri
- bundle install -j $(nproc) # Install dependencies into ./vendor/ruby
## SSH Configuration pipeline with deploy key
## Install ssh-agent if not already installed, it is required by Docker.
## (change apt-get to yum if you use an RPM-based image)
##
- 'command -v ssh-agent >/dev/null || ( apk add openssh-client )'
##
## Run ssh-agent (inside the build environment)
##
- eval $(ssh-agent -s)
##
## Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
## We're using tr to fix line endings which makes ed25519 keys work
## without extra base64 encoding.
## https://gitlab.com/gitlab-examples/ssh-private-key/issues/1#note_48526556
##
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
##
## Create the SSH directory and give it the right permissions
##
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
##
## Optionally, if you will be using any Git commands, set the user name and
## and email.
##
# - git config --global user.email "user@example.com"
# - git config --global user.name "User name"
# Optional - Delete if not using `rubocop`
#rubocop:
# script:
# - rubocop
# FIXME: rspec with errores
#rspec:
# stage: rspec
# script:
# - bundle exec rspec spec
approve:
stage: approve
script:
- echo Approved to master
when: manual
allow_failure: false
only:
- master
# This deploy job uses a simple deploy flow to Heroku, other providers, e.g. AWS Elastic Beanstalk
# are supported too: https://github.com/travis-ci/dpl
deploy_staging:
stage: deploy
script:
- bundle exec cap staging deploy
only:
- development
deploy_prod:
stage: deploy
script:
- bundle exec cap production deploy
only:
- master
I’ve been reading about triggers, but it doesn’t seems very useful to my situation. As I’m not really a devops guy, I would appreciate any indication of what I “should be looking for”