10000 GitHub - kovdan01/custom-ci-cd: Custom CI/CD build pipeline. This is a final project for Otus C++ course: https://otus.ru/lessons/razrabotchik-cpp/
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

kovdan01/custom-ci-cd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Custom CI/CD build pipeline

Disclaimer: this is a final project for Otus C++ course: https://otus.ru/lessons/razrabotchik-cpp/. Homeworks for the course can be found in another repository: https://github.com/kovdan01/otus-cpp/.

A simple build pipeline that allows you to trigger a build on a specified branch of a github repository.

The branch must contain a file .build-config.json with the following structure:

{
    "distrib": "arch",
    "pre-build":
    [
        "pacman -S gcc make cmake --noconfirm"
    ],
    "build":
    [
        "mkdir build",
        "cd build",
        "cmake ..",
        "cmake --build .",
        "cmake --build . --target package"
    ],
    "post-build":
    [
        "curl -T repo-0.0.1-Linux.deb -uuser:$BINTRAY_API_KEY \"https://api.bintray.com/content/user/repo/$CI_CD_BRANCH/1/repo-0.0.1-Linux.deb;deb_distribution=trusty;deb_component=main;deb_architecture=amd64;publish=1\""
    ]
}

distrib describes a linux distribution image to use with docker. Now only Arch Linux is supported.

pre-build describes commands that will be executed before build (for example, package installation).

build describes commands that will be executed during build.

post-build describes commands that will be executed after build (for example, deployment to bintray).

Allowed options for server:

  • port - Server port

Running example:

$ ./ci-cd-server 9000

Allowed options for client:

  • ip - Server ip
  • port - Server port
  • repo - GitHub repository in format user/repo
  • branch - GitHub repository branch (master by default)
  • env - Path to json file containing private environment variables. Example:
{
    "BINTRAY_API_KEY": "your_token"
}

Running example:

$ ./ci-cd-client --ip 127.0.0.1 --port 9000 --repo kovdan01/test-repo --branch master --env tokens.json 

Client output example:

$ ./ci-cd-client --ip 127.0.0.1 --port 9000 --repo kovdan01/test-repo --branch master --env tokens.json                                             

SET PUBLIC ENV VARIABLES                                                                                                                                                                                        

> export CI_CD_BRANCH=master                                                                                                                                                                                    

INIT DOCKER                                                                                                                                                                                                     

> pacman -Sy --noconfirm                                                                                                                                                                                        
:: Synchronizing package databases...                                                                                                                                                                           
downloading core.db...                                                                                                                                                                                          
downloading extra.db...                                                                                                                                                                                         
downloading community.db...                                                                                                                                                                                     
> pacman -S git --noconfirm                                                                                                                                                                                     
resolving dependencies...                                                                                                                                                                                       
looking for conflicting packages...                                                                                                                                                                             

Packages (4) perl-error-0.17029-2  perl-mailtools-2.21-4  perl-timedate-2.33-2  git-2.27.0-1                                                                                                                    

Total Download Size:    6.68 MiB                                                                                                                                                                                
Total Installed Size:  41.49 MiB                                                                                                                                                                                

:: Proceed with installation? [Y/n]                                                                                                                                                                             
:: Retrieving packages...                                                                                                                                                                                       
downloading perl-error-0.17029-2-any.pkg.tar.zst...                                                                                                                                                             
downloading perl-timedate-2.33-2-any.pkg.tar.zst...                                                                                                                                                             
downloading perl-mailtools-2.21-4-any.pkg.tar.zst...                                                                                                                                                            
downloading git-2.27.0-1-x86_64.pkg.tar.zst...                                                                                                                                                                  
checking keyring...                                                                                                                                                                                             
checking package integrity...                                                                                                                                                                                   
loading package files...                                                                                                                                                                                        
checking for file conflicts...                                                                                                                                                                                  
:: Processing package changes...                                                                                                                                                                                
installing perl-error...                                                                                                                                                                                        
installing perl-timedate...                                                                                                                                                                                     
installing perl-mailtools...                                                                                                                                                                                    
installing git...                                                                                                                                                                                               
Optional dependencies for git                                                                                                                                                                                   
    tk: gitk and git gui                                                                                                                                                                                        
    perl-libwww: git svn                                                                                                                                                                                        
    perl-term-readkey: git svn and interactive.singlekey setting                                                                                                                                                
    perl-mime-tools: git send-email                                                                                                                                                                             
    perl-net-smtp-ssl: git send-email TLS support                                                                                                                                                               
    perl-authen-sasl: git send-email TLS support                                                                                                                                                                
    perl-mediawiki-api: git mediawiki support                                                                                                                                                                   
    perl-datetime-format-iso8601: git mediawiki support                                                                                                                                                         
    perl-lwp-protocol-https: git mediawiki https support                                                                                                                                                        
    perl-cgi: gitweb (web interface) support                                                                                                                                                                    
    python: git svn & git p4                                                                                                                                                                                    
    subversion: git svn                                                                                                                                                                                         
    org.freedesktop.secrets: keyring credential helper                                                                                                                                                          
    libsecret: libsecret credential helper [installed]                                                                                                                                                          
:: Running post-transaction hooks...                                                                                                                                                                            
(1/4) Creating system user accounts...                                                                                                                                                                          
Creating group git with gid 977.                                                                                                                                                                                
Creating user git (git daemon user) with uid 977 and gid 977.                                                                                                                                                   
(2/4) Reloading system manager configuration...                                                                                                                                                                 
  Skipped: Current root is not booted.                                                                                                                                                                          
(3/4) Arming ConditionNeedsUpdate...                                                                                                                                                                            
(4/4) Warn about old perl modules                                                                                                                                                                               
WARNING: '/usr/lib/perl5/5.32' contains data from at least 3 packages which will NOT be used by the installed perl interpreter.                                                                                 
 -> Run the following command to get a list of affected packages: pacman -Qqo '/usr/lib/perl5/5.32'                                                                                                             

PRE-BUILD ACTIONS                                                                                                                                                                                               

> pacman -S gcc make cmake --noconfirm                                                                                                                                                                          
resolving dependencies...                                                                                                                                                                                       
looking for conflicting packages...                                                                                                                                                                             

Packages (19) binutils-2.34-5  elfutils-0.180-1  gc-8.0.4-4  guile-2.2.6-2  icu-67.1-1  jsoncpp-1.9.2-1  libelf-0.180-1  libmicrohttpd-0.9.70-3  libmpc-1.1.0-2  libnsl-1.2.0-2  libtool-2.4.6+42+gb88cebd5-13  libuv-1.38.0-1  libxml2-2.9.10-2  rhash-1.3.9-2  shared-mime-info-2.0+1+g6bf9e4f-2  texinfo-6.7-3  cmake-3.17.3-1  gcc-10.1.0-2  make-4.3-3                                                                     

Total Download Size:    68.33 MiB                                                                                                                                                                               
Total Installed Size:  336.47 MiB                                                                                                                                                                               
Net Upgrade Size:      333.66 MiB                                                                                                                                                                               

:: Proceed with installation? [Y/n]                                                                                                                                                                             
:: Retrieving packages...                                                                                                                                                                                       
downloading libmicrohttpd-0.9.70-3-x86_64.pkg.tar.zst...                                                                                                                                                        
downloading libelf-0.180-1-x86_64.pkg.tar.zst...                                                                                                                                                                
downloading elfutils-0.180-1-x86_64.pkg.tar.zst...                                                                                                                                                              
downloading binutils-2.34-5-x86_64.pkg.tar.zst...                                                                                                                                                               
downloading libmpc-1.1.0-2-x86_64.pkg.tar.xz...                                                                                                                                                                 
downloading gcc-10.1.0-2-x86_64.pkg.tar.zst...                                                                                                                                                                  
downloading libtool-2.4.6+42+gb88cebd5-13-x86_64.pkg.tar.zst...                                                                                                                                                 
downloading texinfo-6.7-3-x86_64.pkg.tar.zst...                                                                                                                                                                 
downloading make-4.3-3-x86_64.pkg.tar.zst...                                                                                                                                                                    
downloading icu-67.1-1-x86_64.pkg.tar.zst...                                                                                                                                                                    
downloading libnsl-1.2.0-2-x86_64.pkg.tar.xz...                                                                                                                                                                 
downloading gc-8.0.4-4-x86_64.pkg.tar.zst...                                                                                                                                                                    
downloading guile-2.2.6-2-x86_64.pkg.tar.zst...                                                                                                                                                                 
downloading libxml2-2.9.10-2-x86_64.pkg.tar.zst...                                                                                                                                                              
downloading shared-mime-info-2.0+1+g6bf9e4f-2-x86_64.pkg.tar.zst...                                                                                                                                             
downloading jsoncpp-1.9.2-1-x86_64.pkg.tar.zst...                                                                                                                                                               
downloading libuv-1.38.0-1-x86_64.pkg.tar.zst...                                                                                                                                                                
downloading rhash-1.3.9-2-x86_64.pkg.tar.zst...                                                                                                                                                                 
downloading cmake-3.17.3-1-x86_64.pkg.tar.zst...                                                                                                                                                                
checking keyring...                                                                                                                                                                                             
checking package integrity...                                                                                                                                                                                   
loading package files...                                                                                                                                                                                        
checking for file conflicts...                                                                                                                                                                                  
:: Processing package changes...                                                                                                                                                                                
installing libmicrohttpd...                                                                                                                                                                                     
upgrading libelf...                                                                                                                                                                                             
installing elfutils...                                                                                                                                                                                          
installing binutils...                                                                                                                                                                                          
installing libmpc...                                                                                                                                                                                            
installing gcc...                                                                                                                                                                                               
Optional dependencies for gcc                                                                                                                                                                                   
    lib32-gcc-libs: for generating code for 32-bit ABI                                                                                                                                                          
installing libtool...                                                                                                                                                                                           
installing texinfo...                                                                                                                                                                                           
installing gc...                                                                                                                                                                                                
installing guile...                                                                                                                                                                                             
installing make...                                                                                                                                                                                              
installing icu...                                                                                                                                                                                               
installing libxml2...                                                                                                                                                                                           
installing shared-mime-info...                                                                                                                                                                                  
installing jsoncpp...                                                                                                                                                                                           
Optional dependencies for jsoncpp                                                                                                                                                                               
    jsoncpp-doc: documentation                                                                                                                                                                                  
installing libnsl...                                                                                                                                                                                            
installing libuv...                                                                                                                                                                                             
installing rhash...                                                                                                                                                                                             
installing cmake...
Optional dependencies for cmake
    qt5-base: cmake-gui
:: Running post-transaction hooks...
(1/2) Arming ConditionNeedsUpdate...
(2/2) Updating the MIME type database...

GETTING SOURCES

> git clone --single-branch --branch master https://github.com/kovdan01/test-repo.git repo
> cd repo

BUILD ACTIONS

> mkdir build
> cd build
> cmake ..
-- The CXX compiler identification is GNU 10.1.0
-- Check for working CXX compiler: /usr/sbin/c++
-- Check for working CXX compiler: /usr/sbin/c++ - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /repo/build
> cmake --build .
Scanning dependencies of target test-repo
[ 50%] Building CXX object CMakeFiles/test-repo.dir/main.cpp.o
[100%] Linking CXX executable test-repo
[100%] Built target test-repo
> cmake --build . --target package
[100%] Built target test-repo
Run CPack packaging tool...
CPack: Create package using DEB
CPack: Install projects
CPack: - Run preinstall target for: test-repo
CPack: - Install project: test-repo []
CPack: Create package
-- CPackDeb: Can not find dpkg in your path, default to i386.
-- CPACK_DEBIAN_PACKAGE_DEPENDS not set, the package will have no dependencies.
CPack: - package: /repo/build/test-repo-0.0.1-Linux.deb generated.

POST-BUILD ACTIONS

> curl -T test-repo-0.0.1-Linux.deb -ukovdan01:$BINTRAY_API_KEY "https://api.bintray.com/content/kovdan01/test-repo/$CI_CD_BRANCH/2/test-repo-0.0.2-Linux.deb;deb_distribution=trusty;deb_component=main;deb_architecture=amd64;publish=1"
{"message":"success"}

About

Custom CI/CD build pipeline. This is a final project for Otus C++ course: https://otus.ru/lessons/razrabotchik-cpp/

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0