How to choose linux compiler and simplify this azure-pipeline script? - c++

Setup different compilers for cmake;
Colorize build results.
my current pipeline script for linux ('Hosted Ubuntu 1604'):
steps:
- script: 'cp CMakeLists.txt build/'
displayName: 'cp cmakelist'
- script: 'export CC=/usr/local/bin/gcc-7'
displayName: 'set gcc version'
- script: 'export CXX=/usr/local/bin/g++-7'
displayName: 'set g++ version'
- script: 'cmake CMakeLists.txt'
displayName: 'cmake'
- script: 'make AllTest'
displayName: 'Build AllTest'
- script: 'cd lib/all_test'
displayName: 'set all test directory'
- script: './AllTest'
workingDirectory: lib/all_test/
displayName: 'run AllTest'
My problems:
CMake#1 works well in windows, but this command expect the cMakeLists.txt in the build directory
I've listed the available compilers and gcc 7 is available, but even I tried to setup to use it, the cmake uses gcc 5.4, how can I select different compilers e.g gcc 7, clang (in windows I use cmake -G Visual Studio...
I use a standalone test library (rili tests/ c++) , and on the azure servers the test results has no color, how can I colorize my test results?

Related

Using MPI on a Github Action

I'm working on a C++ project which uses MPI and OMP for some parallel stuff. The thing is that I'd like to include a Github Action in the repo which compiles the code and run the tests after each push on master. I have already use Travis CI as a CI tool and it worked perfectly (both compiling and running the tests), but for some reason I cannot configure the action properly. Every time I push to master it appears the following error when the compiling stage reaches a file which uses MPI:
/home/runner//.file.cpp:14:10: fatal error: mpi.h: No such file or directory
14 | #include <mpi.h>
| ^~~~~~~
The action.yml file is as following:
name: CMake
on:
push:
branches:
- master
- develop
pull_request:
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: egor-tensin/setup-gcc#v1
with:
version: 10
platform: x64
- uses: mpi4py/setup-mpi#v1
with:
mpi: 'mpich'
- name: Compile
run: |
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
export CC=cc
export CXX=CC
cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target all -- -j 14
- name: Run Tests
run:
./${{github.workspace}}/bin/tests
I had tried to change the configuration several times using other MPI versions but the problem always appears.

Appveyor runs tests but OpenCover doesn't show coverage

I am building the project and running test cases in appveyor. After successfully executing test cases the coverage data must be uploaded to coveralls.
But in my case no error is thrown but coverage is being recorded.
The details of my project are
.Net Core 1.1.0
Visual Studio 2017
xunit - 2.2.0
OpenCover - 4.6.519
coveralls.net - 0.7.0
My appveyor.yml is as below :
version: 1.0.{build}
os: Visual Studio 2017
skip_tags: true
configuration: Release
environment:
nodejs_version: "0.12"
COVERALLS_REPO_TOKEN:
secure: rstgrtert
cache:
- "%LOCALAPPDATA%\\Yarn"
install:
- npm i -g yarn#0.16.1
- npm i -g typescript typings
- yarn global add typescript typings
- cd ".\Promact.Oauth.Server\src\Promact.Oauth.Server\"
- yarn
- cd..
- cd..
build_script:
- ps: dotnet restore
build:
project: .\Promact.Oauth.Server\Promact.Oauth.Server.sln
verbosity: minimal
test_script:
- cd ".\src\"
- ps: >-
C:\Users\appveyor\.nuget\packages\OpenCover\4.6.519\tools\OpenCover.Console.exe-target:"C:\Program Files\dotnet\dotnet.exe" -targetargs:"test -f netcoreapp1.1 -c Release .\Promact.Oauth.Server.Tests\Promact.Oauth.Server.Tests.csproj" -mergeoutput -hideskipped:File -output:opencover.xml -oldStyle -filter:"+[Promact.Oauth.Server]*Repository -[Promact.Oauth.Server.Tests*]*" -register:user
if(![string]::IsNullOrEmpty($env:COVERALLS_REPO_TOKEN)){
$coveralls = (Resolve-Path "C:\Users\appveyor\.nuget\packages\coveralls.net\0.7.0\tools\csmacnz.coveralls. exe").ToString()
& $coveralls --opencover -i opencover.xml --repoToken
$env:COVERALLS_REPO_TOKEN --commitId $env:APPVEYOR_REPO_COMMIT --commitBranch $env:APPVEYOR_REPO_BRANCH --commitAuthor $env:APPVEYOR_REPO_COMMIT_AUTHOR --commitEmail $env:APPVEYOR_REPO_COMMIT_AUTHOR_EMAIL --commitMessage $env:APPVEYOR_REPO_COMMIT_MESSAGE --jobId $env:APPVEYOR_JOB_ID
}
In appveyor it runs the test and simply shows
Committing...
No results, this could be for a number of reasons. The most common reasons are:
1) missing PDBs for the assemblies that match the filter please review the
output file and refer to the Usage guide (Usage.rtf) about filters.
2) the profiler may not be registered correctly, please refer to the Usage
guide and the -register switch.
Coverage data uploaded to coveralls.
link to the appveyor build

"ERROR: Unexpected action: build" when building a project with Swift 3 and Cocoapods on Travis-CI

Evening/morning/afternoon all,
Been hitting my head over this for a bit now and couldn't find anything online about this so my best bet is here.
When Travis-CI builds my project I get the following error:
xctool -workspace Project.xcworkspace -scheme ProjectTests build test
ERROR: Unexpected action: build
and here is my config:
language: objective-c
xcode_workspace: Project.xcworkspace
xcode_scheme: ProjectTests
osx_image: xcode8.2
Perhaps I missed something in the tutorial? I got a little lost on the pods dependency section but I believe I did it right. This happens with a new scheme (ProjectTests) created and with the original scheme (Project). I added the dependencies for the ProjectTests scheme in the Build phase like it said but still no dice. Any ideas?
Figured it out (at least in my situation) xctool wasn't working so I used xcodebuild instead and it worked. Here is what I put in:
script:
- xcodebuild clean build -sdk iphonesimulator -workspace Project.xcworkspace -scheme ProjectTests CODE_SIGNING_REQUIRED=NO
App (build + run)
language: objective-c
osx_image: xcode8.3
script: xcodebuild clean && xcodebuild build -sdk iphonesimulator10.1 -project yourproject.xcodeproj -scheme yourscheme CODE_SIGNING_REQUIRED=NO
Framework (build only)
language: objective-c
osx_image: xcode8.3
script: xcodebuild clean && xcodebuild build -project yourproject.xcodeproj -scheme yourscheme
Use && to daisy chain commands and only build if clean succeeds.
The reason for the problem is that xctool deprecated the support for "build"
https://github.com/facebook/xctool
Note: Support for building projects with xctool is deprecated and will not be updated to support future versions of Xcode. We suggest moving to xcodebuild (with xcpretty) for simple needs, or xcbuild for more involved requirements. xctool will continue to support testing (see above).
// Step-1: Check your SDK version
$ xcodebuild -showsdks
// Step-2: The following .travis.yml file works for me
language: objective-c
osx_image: xcode9.3
script: xcodebuild clean && xcodebuild build -sdk iphonesimulator11.3 -project MovingHelper.xcodeproj -scheme MovingHelper CODE_SIGNING_REQUIRED=NO

Using an alternate compiler for Travis-CI R project builds

Travis-CI's official R project build support on Ubuntu uses (at the time of this question) gcc version 4.6.
CRAN uses gcc 4.9 and some packages that build fine on CRAN will not build on Travis with gcc 4.6.
How does one change the default gcc compiler for R project/package builds to more closely mirror CRAN builds?
I really wanted to be able to use Travis to test my ndjson package but the C++ library I'm using won't compile under gcc 4.6.
The ndjson package is on CRAN and the CRAN builds are fine (except for r-oldrel on Windows which doesn't bother me a bit), so I needed a way to change the compiler that R uses on Travis.
I'm using gcc 5 in the example below, but you can use any version available in the toolchain test builds. Ideally, one should mimic CRAN's gcc version and this may be something the Travis folks might consider making default for R builds.
The .travis.yml starts off the same:
language: r
warnings_are_errors: true
sudo: required
env:
global:
- CRAN: http://cran.rstudio.com
I added a matrix build configuration to add the new package source as well as specify the package(s) that needed to be installed. I left it in a matrix configuration since I'm going to try to (eventually) add clang.
matrix:
include:
- os: linux
compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-5']
env:
- COMPILER=g++-5
- CC=gcc=5
- CXX=g++-5
Next, I made sure the auto default compiler is set to this newer gcc and also made doubly sure that R would use it by creating a local Makevars:
before_install:
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 100
- mkdir -p ~/.R
- echo "VkVSPS01CkNDPWdjYyQoVkVSKSAtc3RkPWMxMSAKQ1hYPWcrKyQoVkVSKQpTSExJQl9DWFhMRD1nKyskKFZFUikKRkM9Z2ZvcnRyYW4KRjc3PWdmb3J0cmFuCg==" | base64 -d > ~/.R/Makevars
- cat ~/.R/Makevars
The base64 string equates to:
VER=-5
CC=gcc$(VER) -std=c11
CXX=g++$(VER)
SHLIB_CXXLD=g++$(VER)
FC=gfortran
F77=gfortran
and is just (IMO) cleaner this way.
In theory, all I would have had to do is create the Makevars (i.e. not have to change the default gcc with update-alternatives) but it turned out that Travis used the Makevars gcc setting when installing the dependencies but not for the actual package build itself. So, the update-alternatives is necessary. I also had to add the -std=c11 to ensure a few of the dependencies compiled (the build errored w/o it).
After these modifications to the .travis.yml configuration, ndjson built fine.
Just to give an alternate approach, I use a custom shell script in one of my packages sourcetools. My goal there was to ensure the package would build using the (now ancient) gcc-4.4 compiler. In .travis.yml, I have:
language: r
cache: packages
sudo: false
warnings_are_errors: true
before_install:
- source travis/before-install.sh
addons:
apt:
packages:
- gcc-4.4
- g++-4.4
- clang
r:
- oldrel
- release
- devel
env:
- COMPILER=gcc-4.4
- COMPILER=gcc
- COMPILER=clang
And in travis/before-install.sh, I have:
#!/usr/bin/env sh
mkdir -p ~/.R
if [ "${COMPILER}" = "gcc-4.4" ]; then
echo "CC=gcc-4.4 -std=gnu99" >> ~/.R/Makevars
echo "CXX=g++-4.4" >> ~/.R/Makevars
echo "CXX1X=g++-4.4 -std=c++0x" >> ~/.R/Makevars
fi
if [ "${COMPILER}" = "gcc" ]; then
echo "CC=gcc -std=gnu99" >> ~/.R/Makevars
echo "CXX=g++" >> ~/.R/Makevars
echo "CXX1X=g++ -std=c++0x" >> ~/.R/Makevars
fi
if [ "${COMPILER}" = "clang" ]; then
echo "CC=clang -std=gnu99" >> ~/.R/Makevars
echo "CXX=clang++" >> ~/.R/Makevars
echo "CXX1X=clang++ -std=c++0x" >> ~/.R/Makevars
fi
The end result is basically the same, but IMHO it's somewhat cleaner to separate the 'setup' logic into its own script that's driven entirely off of environment variables. It also makes it easier to construct the R matrix builds, since Travis automatically combines the permutations of r and env here (no need to do it 'by hand').
I imagine the before-install.sh script I use could be cleaned up / made more general, but I haven't had the need to do that yet.

Travis for C++ always ignore script for customize testing

I've been experimenting this and spend more than 25 commit with only small change in .travis.yml but travis always do either:
./configure: if I put the language: cpp in the first line. travis will ignore everything written in .travis.yml and will go straight ./configure && make && make test
language: cpp
addons:
apt:
sources:
- ubuntu-sdk-team
addons:
apt:
packages:
- ubuntu-sdk
before_script: ls
script: qmake demo/QtGoodiesDemo/QtGoodiesDemo.pro && make
sudo: false
rake: if I reorder the placement of language: cpp or remove it. this point, travis succeeded install the dependency (apt addons executed)
addons:
apt:
sources:
- ubuntu-sdk-team
addons:
apt:
packages:
- ubuntu-sdk
before_script: ls
script: qmake demo/QtGoodiesDemo/QtGoodiesDemo.pro && make
language: cpp
sudo: false
I have read the documentation and using what it told just lead me to the point (1) problem.
I've searched but nobody got this problem, I wonder how people do this.
(This is the link)
Attempt 1
using nested apt source still gets me to problem(1) and ignore the custom script (https://travis-ci.org/imakin/QtGoodies/builds/85143452). Note that in problem 2 when rake is called, it succeeded in installing ubuntu-sdk for the Qt dependencies
language: cpp
sudo: false
addons:
apt:
sources:
- ubuntu-sdk-team
packages:
- ubuntu-sdk
before_script: ls
script: qmake demo/QtGoodiesDemo/QtGoodiesDemo.pro && make
Attempt 2
So then I try to play it and added configure file. Having it all rwxrwxrwx permission too. and pushed it. But travis still execute to problem (1) again. No Qt Installing, even failed to run the configure telling it has no permission to execute it. I can't do anything to chmod it in testing process though as before_script is ignored too. This one occurred in https://travis-ci.org/imakin/QtGoodies/builds/85146543
I think your .travis.yml file is invalid and prevents it to be parsed properly, hence you default to the Ruby language.
Can you try merging both addons.apt sections like so:
addons:
apt:
sources:
- ubuntu-sdk-team
packages:
- ubuntu-sdk
Hope this helps!
Update: it turns out the .travis.yml file started with a hidden character that prevented Travis CI from parsing it properly.