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.
Related
I'm trying to set up a github actions script for a project of mine. The project is private at the moment since I want it in an RC state before the first release. As it is close to ready, I intended to set up an automated build now, but I'm seeing some strange behavior. The project is a simple c# library, and so the .yml file is quite simple:
name: .NET Core Desktop
on: [push, pull_request]
jobs:
build:
strategy:
matrix:
configuration: [Debug, Release]
runs-on: windows-latest
env:
Solution_Name: Replacement.sln # Replace with your solution name, i.e. MyWpfApp.sln.
Test_Project_Path: UnitTest.csproj # Replace with the path to your test project, i.e. MyWpfApp.Tests\MyWpfApp.Tests.csproj.
steps:
- name: Checkout
uses: actions/checkout#v3
with:
fetch-depth: 0
# Run build
- name: Run build
run: ./build.cmd --target pack --configuration ${{ matrix.configuration }}
Sometimes, one of the builds (Debug or Release, or both) fail with an entry such as
Terminate batch job (Y/N)?
Error: The operation was canceled.
in the log. I certainly did not cancel the build in any way. This may happen after like 3 minutes.
Am I running into the github build time limit (how would I know)? Or is there something else wrong I'm missing?
Currently have a linker error in an Azure Devops test pipeline:
##[error]lib\static\x64\vulkan-1.lib(0,0): Error LNK1107: invalid or corrupt file: cannot read at 0x82
lib\static\x64\vulkan-1.lib : fatal error LNK1107: invalid or corrupt file: cannot read at 0x82 [d:\a\1\s\Rhea\Rhea.vcxproj]
Done Building Project "d:\a\1\s\Rhea\Rhea.vcxproj" (default targets) -- FAILED.
This only happens when attempting to build on MSVC on the build machine. GCC on the build machine works fine and local machines using MSVC are able to compile just fine.
This is the testpipeline.yml:
trigger:
- master
strategy:
matrix:
x64-Debug:
configuration: 'debug'
architecture: 'x64'
x64-Release:
configuration: 'release'
architecture: 'x64'
pool:
vmImage: 'windows-2019'
steps:
- checkout: self
submodules: true
- bash: chmod -R 755 ./
displayName: "Elevate Bash"
#Windows
- bash: ./vendor/premake/win/premake5.exe vs2019 --standalone
displayName: "Premake Windows"
condition: eq( variables['Agent.OS'], 'Windows_NT' )
#Compile with visual studio
- task: VSBuild#1
inputs:
solution: 'RheaDev.sln'
configuration: $(configuration)
msbuildArchitecture: $(architecture)
displayName: "Build Project"
Marked with GitLFS and the pipeline wasn't so the files were incorrect.
My code is written in C++
GitLab CI Compiler: MSVC2017_x64
My project is being compiled with a GitLab pipeline on a Windows server. I want to be able to compile parts of this project two times and somehow change something in the code, before it is compiled so that I will have two versions of the same application but with different predefined settings.
Something simple like the compiler setting a #define in a header or cpp file would be great.
Using this same technique, I'd also like to hard wire the build number (pipeline ID) into the application.
I've already tried the /D or -D parameter but it doesn't set a #define.
The solution needs to work no matter what the user's setup is so something like environment variables won't work.
This is my .gitlab-ci.yml file (the application is ultimately built with the qmake and nmake calls):
stages:
- build
- test
variables:
GIT_SUBMODULE_STRATEGY: recursive
build:
stage: build
only:
- master
tags:
- windows
- qt
script:
- call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
- call "C:\Qt\5.9.1\msvc2017_64\bin\qtenv2.bat"
- set CL=/MP16
- set PATH="C:\Program Files (x86)\Inno Setup 5";%PATH%
- cd %CI_PROJECT_DIR%\(...)\Application
- qmake CONFIG+=release
- nmake
- cd %CI_PROJECT_DIR%\(...)\3rdParty\Windows
- copy (...)\Application.exe .
- copy (...)\Application.ico .
- windeployqt .
- iscc InnoScript.iss
artifacts:
name: "%CI_COMMIT_REF_NAME%"
expire_in: 1 month
paths:
- (...)\3rdParty\Windows\Application.exe
And this is how I would want it to be (with the -D mode=xy's):
stages:
- build
- test
variables:
GIT_SUBMODULE_STRATEGY: recursive
build:
stage: build
only:
- master
tags:
- windows
- qt
script:
- call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
- call "C:\Qt\5.9.1\msvc2017_64\bin\qtenv2.bat"
- set CL=/MP16
- set PATH="C:\Program Files (x86)\Inno Setup 5";%PATH%
- cd %CI_PROJECT_DIR%\(...)\Application
- qmake CONFIG+=release
- nmake -D mode=prod
- qmake CONFIG+=release
- nmake -D mode=stage
- cd %CI_PROJECT_DIR%\(...)\3rdParty\Windows
- copy (...)\Application.exe .
- copy (...)\Application.ico .
- windeployqt .
- iscc InnoScript.iss
artifacts:
name: "%CI_COMMIT_REF_NAME%"
expire_in: 1 month
paths:
- (...)\3rdParty\Windows\Application.exe
How do I modify my code by only using the GitLab CI or is there another, better way?
I've just found out how to do it.
Before, I was trying to add the -D argument to the nmake call when instead, I needed to add a DEFINES+=MY_VAR='foo bar' to the qmake call.
After doing this and deleting the build- folder to get rid of the outdated Makefile.Debug and Makefile.Release files I got it to work correctly.
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?
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.