forked from lucas.delanier/MovieFinder
parent
22c30b0765
commit
2e2f18ad49
@ -1,27 +1,161 @@
|
|||||||
kind: pipeline
|
# .semaphore/semaphore.yml
|
||||||
type: docker
|
|
||||||
name: MovieFinderPipeline
|
# Use the latest stable version of Semaphore 2.0 YML syntax:
|
||||||
|
version: v1.0
|
||||||
|
|
||||||
trigger:
|
# Name your pipeline. In the event that you connect multiple pipelines with promotions,
|
||||||
event:
|
# the name will help you differentiate between, for example, CI build phases
|
||||||
- push
|
# and delivery phases.
|
||||||
|
name: MovieFinderPiepline
|
||||||
steps:
|
|
||||||
# build CONTAINER for sonar on cirrusci IMAGE
|
# An agent defines the environment in which your code runs.
|
||||||
- name: code-analysis
|
# It is a combination of one of available machine types and operating
|
||||||
image: itporbit/react-native-android:latest
|
# system images.
|
||||||
environment:
|
# See https://docs.semaphoreci.com/ci-cd-environment/machine-types/
|
||||||
SONAR_TOKEN:
|
# and https://docs.semaphoreci.com/ci-cd-environment/ubuntu-18.04-image/
|
||||||
from_secret: sonar_token
|
agent:
|
||||||
settings:
|
machine:
|
||||||
sources: .
|
type: e1-standard-2
|
||||||
commands:
|
os_image: ubuntu1804
|
||||||
- export SONAR_SCANNER_VERSION=4.7.0.2747
|
|
||||||
- export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
|
# Blocks are the heart of a pipeline and are executed sequentially.
|
||||||
- curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
|
# Each block has a task that defines one or more jobs. Jobs define the
|
||||||
- unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
|
# commands to execute.
|
||||||
- export PATH=$SONAR_SCANNER_HOME/bin:$PATH
|
# See https://docs.semaphoreci.com/essentials/concepts/
|
||||||
- export SONAR_SCANNER_OPTS="-server"
|
blocks:
|
||||||
- sonar-scanner -D sonar.projectKey=MovieFinder -D sonar.sources=. -D sonar.host.url=https://codefirst.iut.uca.fr/sonar
|
- name: Install dependencies
|
||||||
depends_on: [ app-build ]
|
task:
|
||||||
|
# Set environment variables that your project requires.
|
||||||
|
# See https://docs.semaphoreci.com/essentials/environment-variables/
|
||||||
|
env_vars:
|
||||||
|
- name: NODE_ENV
|
||||||
|
value: test
|
||||||
|
- name: CI
|
||||||
|
value: 'true'
|
||||||
|
|
||||||
|
# This block runs two jobs in parallel and they both share common
|
||||||
|
# setup steps. We can group them in a prologue.
|
||||||
|
# See https://docs.semaphoreci.com/reference/pipeline-yaml-reference/#prologue
|
||||||
|
prologue:
|
||||||
|
commands:
|
||||||
|
# Get the latest version of our source code from GitHub:
|
||||||
|
- checkout
|
||||||
|
|
||||||
|
# Use the version of Node.js specified in .nvmrc.
|
||||||
|
# Semaphore provides nvm preinstalled.
|
||||||
|
- nvm use
|
||||||
|
- node --version
|
||||||
|
- npm --version
|
||||||
|
jobs:
|
||||||
|
# First parallel job:
|
||||||
|
- name: client npm install and cache
|
||||||
|
commands:
|
||||||
|
- cd src/client
|
||||||
|
|
||||||
|
# Restore dependencies from cache. This command will not fail in
|
||||||
|
# the event of a cache miss. In the event of a cache hit, npm install will
|
||||||
|
# run very fast.
|
||||||
|
# For more info on caching, see https://docs.semaphoreci.com/essentials/caching-dependencies-and-directories/
|
||||||
|
- cache restore client-node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum package-lock.json),client-node-modules-$SEMAPHORE_GIT_BRANCH,client-node-modules-master
|
||||||
|
- npm install
|
||||||
|
|
||||||
|
# Store the latest version of node modules in the cache to reuse in
|
||||||
|
# further blocks:
|
||||||
|
- cache store client-node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum package-lock.json) node_modules
|
||||||
|
|
||||||
|
# Second parallel job:
|
||||||
|
- name: server npm install and cache
|
||||||
|
commands:
|
||||||
|
- cd src/server
|
||||||
|
- cache restore server-node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum package-lock.json),server-node-modules-$SEMAPHORE_GIT_BRANCH,server-node-modules-master
|
||||||
|
- npm install
|
||||||
|
- cache store server-node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum package-lock.json) node_modules
|
||||||
|
|
||||||
|
- name: Lint
|
||||||
|
task:
|
||||||
|
env_vars:
|
||||||
|
- name: NODE_ENV
|
||||||
|
value: test
|
||||||
|
- name: CI
|
||||||
|
value: 'true'
|
||||||
|
prologue:
|
||||||
|
commands:
|
||||||
|
- checkout
|
||||||
|
- nvm use
|
||||||
|
- node --version
|
||||||
|
- npm --version
|
||||||
|
jobs:
|
||||||
|
- name: Client Lint
|
||||||
|
commands:
|
||||||
|
- cd src/client
|
||||||
|
# At this point we can assume 100% cache hit rate of node modules:
|
||||||
|
- cache restore client-node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum package-lock.json),client-node-modules-$SEMAPHORE_GIT_BRANCH,client-node-modules-master
|
||||||
|
|
||||||
|
# Run task as defined in package.json:
|
||||||
|
- npm run lint
|
||||||
|
- name: Server Lint
|
||||||
|
commands:
|
||||||
|
- cd src/server
|
||||||
|
- cache restore server-node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum package-lock.json),server-node-modules-$SEMAPHORE_GIT_BRANCH,server-node-modules-master
|
||||||
|
- npm run lint
|
||||||
|
|
||||||
|
- name: Tests
|
||||||
|
task:
|
||||||
|
env_vars:
|
||||||
|
- name: NODE_ENV
|
||||||
|
value: test
|
||||||
|
- name: CI
|
||||||
|
value: 'true'
|
||||||
|
prologue:
|
||||||
|
commands:
|
||||||
|
- checkout
|
||||||
|
- nvm use
|
||||||
|
- node --version
|
||||||
|
- npm --version
|
||||||
|
jobs:
|
||||||
|
- name: Client Tests
|
||||||
|
commands:
|
||||||
|
- cd src/client
|
||||||
|
- cache restore client-node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum package-lock.json),client-node-modules-$SEMAPHORE_GIT_BRANCH,client-node-modules-master
|
||||||
|
- npm test
|
||||||
|
- name: Server Tests
|
||||||
|
commands:
|
||||||
|
- cd src/server
|
||||||
|
- cache restore server-node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum package-lock.json),server-node-modules-$SEMAPHORE_GIT_BRANCH,server-node-modules-master
|
||||||
|
- npm test
|
||||||
|
|
||||||
|
- name: E2e Tests
|
||||||
|
task:
|
||||||
|
env_vars:
|
||||||
|
- name: NODE_ENV
|
||||||
|
value: test
|
||||||
|
- name: CI
|
||||||
|
value: 'true'
|
||||||
|
prologue:
|
||||||
|
commands:
|
||||||
|
- checkout
|
||||||
|
- nvm use
|
||||||
|
- node --version
|
||||||
|
- npm --version
|
||||||
|
# Start a Postgres database. On Semaphore, databases run in the same
|
||||||
|
# environment as your code.
|
||||||
|
# See https://docs.semaphoreci.com/ci-cd-environment/ubuntu-18.04-image/#databases-and-services
|
||||||
|
- sem-service start postgres
|
||||||
|
# With unrestricted sudo access, you can install any additional
|
||||||
|
# system package:
|
||||||
|
- sudo apt-get install -y libgtk2.0-0
|
||||||
|
jobs:
|
||||||
|
- name: Client Tests
|
||||||
|
commands:
|
||||||
|
- cd src/client
|
||||||
|
- cache restore client-node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum package-lock.json),client-node-modules-$SEMAPHORE_GIT_BRANCH,client-node-modules-master
|
||||||
|
- npx cypress install
|
||||||
|
- npm run test:e2e
|
||||||
|
- name: Server Tests
|
||||||
|
commands:
|
||||||
|
- cd src/server
|
||||||
|
- cache restore server-node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum package-lock.json),server-node-modules-$SEMAPHORE_GIT_BRANCH,server-node-modules-master
|
||||||
|
- cp ci.env .env
|
||||||
|
- cp ormconfig.ci.json ormconfig.json
|
||||||
|
- npm run migrate:up
|
||||||
|
- npm run test:e2e
|
Loading…
Reference in new issue