zoukankan      html  css  js  c++  java
  • 使用gitlab runner 进行CI(三):使用cppcheck做c++的静态检查

    前两节我们讲了如何配置gitlab runner。本节主要讲gitlab ci的一些基本概念,并通过配置使用cppcheck进行静态检查来进行实践。

    gitlab ci的配置

    gitlab ci通过项目内的.gitlab-ci.yml进行配置。语言是YAML。

    几个基本概念

    pipeline: 流水线,也就是整个CI检查的过程
    job: 工作项,可以取任意名字,可以建立任意个工作项,工作项是流水线的一个过程。
    stage: 每个工作项可以属于一个stage,类似于分组
    script: script是工作项中执行具体检查的shell 命令
    before_script: 所有工作项执行前会执行的命令,一般用于配置环境。

    example:

    before_script:
    ##设置环境变量
      - export PATH=$PATH 
    
    ## 定义有哪些stages 
    stages:
      - analysis
      - build
      - test
      - deploy
    
    ##job名称
    cppcheck:
      stage: analysis
      ##具体命令
      script: 
       - source ~/.bashrc
       - echo hello_ci
      tags:
      ## 执行此项job的runner,设置见本系列第二节
        - cppcheck 
    

    使用CI进行代码检查demo

    1.建立一个测试项目,并为其设置runner
    2.创建.gitlab-ci.yml文件,并将上文example内容拷贝至该文件
    3.提交修改
    此时,在项目的CI/CD-》Pipelines页面(或Job),我们就可以看到pipeline的运行情况:
    image
    其中Status指示是否成功,点击Stages可进入相应Stage运行的详细情况:
    image
    可以看到是依次执行了before_script和job中的script命令。并最终成功了。

    todo: 补充cppcheck部分

  • 相关阅读:
    array and ram
    char as int
    pointer of 2d array and address
    Install SAP HANA EXPRESS on Google Cloud Platform
    Ubuntu remount hard drive
    Compile OpenSSL with Visual Studio 2019
    Install Jupyter notebook and tensorflow on Ubuntu 18.04
    Build OpenCV text(OCR) module on windows with Visual Studio 2019
    Reinstall VirtualBox 6.0 on Ubuntu 18.04
    Pitfall in std::vector<cv::Mat>
  • 原文地址:https://www.cnblogs.com/haoliuhust/p/14110991.html
Copyright © 2011-2022 走看看