Skip to content
Snippets Groups Projects
.gitlab-ci.yml 2 KiB
Newer Older
  • Learn to ignore specific revisions
  • François Agneray's avatar
    François Agneray committed
    stages:
      - install_dependencies
      - test
      - sonar
      - dockerize
    
    variables:
    
    François Agneray's avatar
    François Agneray committed
        VERSION: "3.7"
    
    François Agneray's avatar
    François Agneray committed
        SONARQUBE_URL: https://sonarqube.lam.fr
    
    install_dependencies:
        image: jakzal/phpqa:php8.0
        stage: install_dependencies
        script:
    
    François Agneray's avatar
    François Agneray committed
            - composer install --ignore-platform-reqs
        cache:
    
            key: ${CI_COMMIT_REF_SLUG}_server
    
    François Agneray's avatar
    François Agneray committed
            paths:
    
                - server/vendor
    
    François Agneray's avatar
    François Agneray committed
            policy: pull-push
    
    test:
        image: jakzal/phpqa:php8.0
        stage: test
        cache: 
    
            key: ${CI_COMMIT_REF_SLUG}_server
    
    François Agneray's avatar
    François Agneray committed
            paths:
    
                - server/vendor
    
    François Agneray's avatar
    François Agneray committed
            policy: pull
        script:
    
    François Agneray's avatar
    François Agneray committed
            - phpdbg 
                -qrr ./vendor/bin/phpunit 
                --bootstrap ./tests/bootstrap.php 
                --whitelist src 
                --coverage-clover ./coverage/clover.xml 
                --log-junit ./coverage/junit-logfile.xml 
                --coverage-text --colors=never ./tests
    
    François Agneray's avatar
    François Agneray committed
        artifacts:
            paths:
    
                - server/coverage
    
    François Agneray's avatar
    François Agneray committed
    
    sonar_scanner:
        image: sonarsource/sonar-scanner-cli:latest
        stage: sonar
        script:
    
    François Agneray's avatar
    François Agneray committed
            - sonar-scanner 
    
                -Dsonar.projectKey=anis-server 
    
    François Agneray's avatar
    François Agneray committed
                -Dsonar.sources=src 
                -Dsonar.projectVersion=$VERSION 
                -Dsonar.host.url=$SONARQUBE_URL 
                -Dsonar.login=$SONAR_TOKEN_SERVER 
                -Dsonar.php.tests.reportPath=./coverage/junit-logfile.xml 
                -Dsonar.php.coverage.reportPaths=./coverage/clover.xml
    
    François Agneray's avatar
    François Agneray committed
    
    dockerize:
        image: docker:stable
        stage: dockerize
        cache: 
    
            key: ${CI_COMMIT_REF_SLUG}_server
    
    François Agneray's avatar
    François Agneray committed
            paths:
    
                - server/vendor
    
    François Agneray's avatar
    François Agneray committed
            policy: pull
        dependencies: []
        script:
    
    François Agneray's avatar
    François Agneray committed
            - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    
    François Agneray's avatar
    François Agneray committed
            - docker pull $CI_REGISTRY/anis/anis-next/server:latest || true
            - docker build --cache-from $CI_REGISTRY/anis/anis-next/server:latest -t $CI_REGISTRY/anis/anis-next/server:latest .
            - docker push $CI_REGISTRY/anis/anis-next/server:latest