Skip to content
Snippets Groups Projects
.gitlab-ci.yml 2.06 KiB
Newer Older
  • Learn to ignore specific revisions
  • François Agneray's avatar
    François Agneray committed
    stages:
        - install_dependencies
    
        - test
    
    François Agneray's avatar
    François Agneray committed
        - sonar
        - build
        - dockerize
    
    variables:
        VERSION: "3.7.0"
        SONARQUBE_URL: https://sonarqube.lam.fr
    
    install_dependencies:
        image: node:16-slim
        stage: install_dependencies
        cache: 
    
            key: ${CI_COMMIT_REF_SLUG}_client
    
    François Agneray's avatar
    François Agneray committed
            paths:
    
                - client/node_modules
    
    François Agneray's avatar
    François Agneray committed
            policy: pull-push
        script:
    
    François Agneray's avatar
    François Agneray committed
            - yarn install
    
    
    test:
        image: node:16-slim
        stage: test
        cache: 
            key: ${CI_COMMIT_REF_SLUG}_client
            paths:
                - node_modules
            policy: pull
        script:
    
            - cd client
    
            - npx jest --coverage --coverageReporters lcov 
        artifacts:
            paths:
                - client/coverage
    
    
    François Agneray's avatar
    François Agneray committed
    sonar_scanner:
        image: sonarsource/sonar-scanner-cli:latest
        stage: sonar
        cache: 
    
            key: ${CI_COMMIT_REF_SLUG}_client
    
    François Agneray's avatar
    François Agneray committed
            paths:
    
                - client/node_modules
    
    François Agneray's avatar
    François Agneray committed
            policy: pull
        script:
    
    François Agneray's avatar
    François Agneray committed
            - sonar-scanner
    
                -Dsonar.projectKey=anis-client
    
    François Agneray's avatar
    François Agneray committed
                -Dsonar.sources=src
                -Dsonar.projectVersion=$VERSION 
                -Dsonar.host.url=$SONARQUBE_URL 
                -Dsonar.login=$SONAR_TOKEN_CLIENT
                -Dsonar.exclusions=**.spec.ts
    
                -Dsonar.typescript.lcov.reportPaths=./coverage/anis-client/lcov.info
    
    François Agneray's avatar
    François Agneray committed
    
    build:
        image: node:16-slim
        stage: build
        cache: 
    
            key: ${CI_COMMIT_REF_SLUG}_client
    
    François Agneray's avatar
    François Agneray committed
            paths:
    
                - client/node_modules
    
    François Agneray's avatar
    François Agneray committed
            policy: pull
        script:
    
    François Agneray's avatar
    François Agneray committed
            - yarn global add @angular/cli@latest
            - ng build
        artifacts:
            paths:
    
                - client/dist
    
    François Agneray's avatar
    François Agneray committed
    
    dockerize:
        image: docker:stable
        stage: dockerize
        cache: {}
        script:
    
    François Agneray's avatar
    François Agneray committed
            - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
            - docker pull $CI_REGISTRY/anis/anis-next/client:latest || true
            - docker build --cache-from $CI_REGISTRY/anis/anis-next/client:latest -t $CI_REGISTRY/anis/anis-next/client:latest .
            - docker push $CI_REGISTRY/anis/anis-next/client:latest