From 2e2f18ad496e8c88dd15041938daf8c2704771cf Mon Sep 17 00:00:00 2001 From: Lucas DELANIER Date: Wed, 8 Mar 2023 01:06:59 +0100 Subject: [PATCH] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'.drone.yml'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 188 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 161 insertions(+), 27 deletions(-) diff --git a/.drone.yml b/.drone.yml index c92527e..d4d7bf0 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,27 +1,161 @@ -kind: pipeline -type: docker -name: MovieFinderPipeline - - -trigger: - event: - - push - -steps: -# build CONTAINER for sonar on cirrusci IMAGE -- name: code-analysis - image: itporbit/react-native-android:latest - environment: - SONAR_TOKEN: - from_secret: sonar_token - settings: - sources: . - commands: - - export SONAR_SCANNER_VERSION=4.7.0.2747 - - export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux - - 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 - - unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ - - export PATH=$SONAR_SCANNER_HOME/bin:$PATH - - export SONAR_SCANNER_OPTS="-server" - - sonar-scanner -D sonar.projectKey=MovieFinder -D sonar.sources=. -D sonar.host.url=https://codefirst.iut.uca.fr/sonar - depends_on: [ app-build ] \ No newline at end of file +# .semaphore/semaphore.yml + +# Use the latest stable version of Semaphore 2.0 YML syntax: +version: v1.0 + +# Name your pipeline. In the event that you connect multiple pipelines with promotions, +# the name will help you differentiate between, for example, CI build phases +# and delivery phases. +name: MovieFinderPiepline + +# An agent defines the environment in which your code runs. +# It is a combination of one of available machine types and operating +# system images. +# See https://docs.semaphoreci.com/ci-cd-environment/machine-types/ +# and https://docs.semaphoreci.com/ci-cd-environment/ubuntu-18.04-image/ +agent: + machine: + type: e1-standard-2 + os_image: ubuntu1804 + +# Blocks are the heart of a pipeline and are executed sequentially. +# Each block has a task that defines one or more jobs. Jobs define the +# commands to execute. +# See https://docs.semaphoreci.com/essentials/concepts/ +blocks: + - name: Install dependencies + 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 \ No newline at end of file