Skip to content

Commit 5732415

Browse files
Fixing windows and adding jenkins file
1 parent 63131ae commit 5732415

File tree

10 files changed

+399
-25
lines changed

10 files changed

+399
-25
lines changed

Build.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pushd Build || goto :error
88

99
cmake .. || goto :error
1010
cmake --build . --target Embed2C || goto :error
11-
cmake .. || goto :error
11+
cmake .. %* || goto :error
1212
cmake --build . -j 16 || goto :error
1313

1414
popd

Build.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
set -e
33

44
mkdir -p ./Build
55
pushd ./Build
6+
67
cmake ..
78
cmake --build . --target Embed2C
8-
cmake ..
9+
cmake .. "$@"
910
cmake --build . -j 16
1011

1112
popd

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ target_include_directories(runcpp2 PRIVATE "${CMAKE_CURRENT_LIST_DIR}/Include")
105105
target_link_libraries(runcpp2 PRIVATE ssLogger ghc_filesystem System2 ryml::ryml dylib CppOverride)
106106

107107
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
108-
set(STANDARD_COMPILE_FLAGS "/utf-8;/W1")
108+
set(STANDARD_COMPILE_FLAGS "/utf-8;/W1;/DGHC_WIN_DISABLE_WSTRING_STORAGE_TYPE=1")
109109
else()
110110
set(STANDARD_COMPILE_FLAGS "-Wall"
111111
"-Wno-return-local-addr"

Include/runcpp2/BuildsManager.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ namespace runcpp2
2929
bool Initialized;
3030

3131
bool ParseMappings(const std::string& mappingsContent);
32+
std::string ProcessPath(const std::string& path);
3233

3334
public:
3435
BuildsManager(const ghc::filesystem::path& configDirectory);

Include/runcpp2/Data/ProfilesCompilesFiles.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
#define RUNCPP2_DATA_PROFILES_COMPILES_FILES_HPP
33

44
#include "runcpp2/Data/ParseCommon.hpp"
5+
6+
#define NOMINMAX 1
57
#include "ghc/filesystem.hpp"
8+
69
#include "ryml.hpp"
710
#include <unordered_map>
811

Jenkinsfile

Lines changed: 340 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,340 @@
1+
def bash(command, returnOutput=false)
2+
{
3+
return sh(script: """#!/bin/bash
4+
${command}
5+
""",
6+
returnStdout: returnOutput)
7+
}
8+
9+
10+
def SetGithubStatus(githubToken, context, targetUrl, desc, status, repoOwner, repoName, gitHash)
11+
{
12+
bash """
13+
curl -L --fail-with-body \\
14+
-X POST \\
15+
-H "Accept: application/vnd.github+json" \\
16+
-H "Authorization: Bearer ${githubToken}" \\
17+
-H "X-GitHub-Api-Version: 2022-11-28" \\
18+
-d '{
19+
"context": "${context}",
20+
"target_url": "${targetUrl}",
21+
"description": "${desc}",
22+
"state": "${status}"
23+
}' \\
24+
https://api.github.com/repos/${repoOwner}/${repoName}/statuses/${gitHash}
25+
"""
26+
}
27+
28+
def SKIP_PIPELINE = false
29+
def REPO_OWNER = "Neko-Box-Coder"
30+
def REPO_NAME = "runcpp2"
31+
def TARGET_URL = 'https://github.com/Neko-Box-Coder/runcpp2.git'
32+
def STATUS_CONTEXT_URL = "https://ci.nekoboxcoder.dev/job/runcpp2/${BUILD_NUMBER}/pipeline-graph/"
33+
def FAILED_STAGE = "None"
34+
def TARGET_REF = "refs/heads/master"
35+
def STORE_BUILD = false
36+
37+
pipeline
38+
{
39+
agent none
40+
41+
options
42+
{
43+
skipDefaultCheckout()
44+
}
45+
46+
/*
47+
External Variables for webhook payload:
48+
49+
Webhook:
50+
GITHUB_PUSH_REF: $.ref
51+
52+
GITHUB_PR_ACTION: $.action
53+
GITHUB_PR_GIT_URL: $.pull_request.head.repo.clone_url
54+
GITHUB_PR_REF: $.pull_request.head.ref
55+
56+
GITHUB_PR_REPO_OWNER: $.pull_request.user.login
57+
GITHUB_PR_REPO_NAME: $.pull_request.head.repo.name
58+
59+
X-GitHub-Event: (Header)
60+
61+
Param:
62+
TARGET_REF
63+
STORE_BUILD
64+
*/
65+
66+
stages
67+
{
68+
stage('Setup')
69+
{
70+
agent none
71+
steps
72+
{
73+
script
74+
{
75+
echo "env.TARGET_REF: ${env.TARGET_REF}"
76+
echo "env.STORE_BUILD: ${env.STORE_BUILD}"
77+
78+
if(env.TARGET_REF != null)
79+
{
80+
TARGET_REF = env.TARGET_REF
81+
}
82+
83+
if(env.STORE_BUILD != null)
84+
{
85+
STORE_BUILD = env.STORE_BUILD.toBoolean()
86+
}
87+
88+
echo "Displaying Webhook Variables:"
89+
echo "GITHUB_PUSH_REF: ${env.GITHUB_PUSH_REF}"
90+
echo "GITHUB_PR_ACTION: ${env.GITHUB_PR_ACTION}"
91+
echo "GITHUB_PR_GIT_URL: ${env.GITHUB_PR_GIT_URL}"
92+
echo "GITHUB_PR_REF: ${env.GITHUB_PR_REF}"
93+
echo "GITHUB_PR_REPO_OWNER: ${env.GITHUB_PR_REPO_OWNER}"
94+
echo "GITHUB_PR_REPO_NAME: ${env.GITHUB_PR_REPO_NAME}"
95+
96+
echo "X_GitHub_Event: ${env.X_GitHub_Event}"
97+
98+
//Trigger pipeline on push to master
99+
if(env.X_GitHub_Event == 'push')
100+
{
101+
if(env.GITHUB_PUSH_REF != 'refs/heads/master')
102+
{
103+
echo "Setting SKIP_PIPELINE for push to true"
104+
error('Receiving non master push')
105+
SKIP_PIPELINE = true
106+
echo "SKIP_PIPELINE: ${SKIP_PIPELINE}"
107+
}
108+
}
109+
//Trigger pipeline with approval on PR
110+
else if(env.X_GitHub_Event == 'pull_request')
111+
{
112+
if( env.GITHUB_PR_ACTION != 'synchronize' &&
113+
env.GITHUB_PR_ACTION != 'opened')
114+
{
115+
error('Receiving non relevant PR action')
116+
SKIP_PIPELINE = true
117+
}
118+
else
119+
{
120+
timeout(time: 30, unit: 'MINUTES')
121+
{
122+
input 'Approval this job?'
123+
}
124+
}
125+
126+
TARGET_REF = env.GITHUB_PR_REF
127+
TARGET_URL = env.GITHUB_PR_GIT_URL
128+
REPO_OWNER = env.GITHUB_PR_REPO_OWNER
129+
REPO_NAME = env.GITHUB_PR_REPO_NAME
130+
}
131+
//Invalid github event
132+
else if(env.X_GitHub_Event != null)
133+
{
134+
error("Invalid github event: ${env.X_GitHub_Event}")
135+
}
136+
137+
echo "TARGET_REF: ${TARGET_REF}"
138+
echo "env.TARGET_REF: ${env.TARGET_REF}"
139+
echo "TARGET_URL: ${TARGET_URL}"
140+
echo "REPO_OWNER: ${REPO_OWNER}"
141+
echo "REPO_NAME: ${REPO_NAME}"
142+
echo "SKIP_PIPELINE: ${SKIP_PIPELINE}"
143+
echo "STATUS_CONTEXT_URL: ${STATUS_CONTEXT_URL}"
144+
echo "STORE_BUILD: ${STORE_BUILD}"
145+
}
146+
}
147+
}
148+
149+
stage('Checkout')
150+
{
151+
agent { label 'linux' }
152+
when { expression { SKIP_PIPELINE == false } }
153+
steps
154+
{
155+
cleanWs()
156+
script
157+
{
158+
checkout(
159+
[
160+
$class: 'GitSCM',
161+
branches: [[name: TARGET_REF]],
162+
doGenerateSubmoduleConfigurations: true,
163+
extensions: scm.extensions +
164+
[[
165+
$class: 'SubmoduleOption',
166+
parentCredentials: true,
167+
recursiveSubmodules: true
168+
]],
169+
userRemoteConfigs: [[url: TARGET_URL]]
170+
]
171+
)
172+
173+
GIT_HASH = bash("echo \$(git rev-parse --verify HEAD)", true)
174+
echo "GITHASH: ${GIT_HASH}"
175+
176+
if(!STORE_BUILD)
177+
{
178+
withCredentials([string(credentialsId: 'github-token', variable: 'GITHUB_TOKEN')])
179+
{
180+
SetGithubStatus('$GITHUB_TOKEN',
181+
"Build ${BUILD_NUMBER}",
182+
STATUS_CONTEXT_URL,
183+
"Stage ${env.STAGE_NAME} started",
184+
"pending",
185+
REPO_OWNER,
186+
REPO_NAME,
187+
GIT_HASH)
188+
}
189+
}
190+
191+
stash 'source'
192+
}
193+
}
194+
post { failure { script { FAILED_STAGE = env.STAGE_NAME } } }
195+
}
196+
197+
stage('Build')
198+
{
199+
when { expression { SKIP_PIPELINE == false } }
200+
parallel
201+
{
202+
stage('Linux Build')
203+
{
204+
agent { label 'linux' }
205+
steps
206+
{
207+
cleanWs()
208+
bash "ls -lah"
209+
unstash 'source'
210+
bash "ls -lah"
211+
bash('chmod +x ./Build.sh')
212+
bash './Build.sh -DRUNCPP2_BUILD_TESTS=ON'
213+
stash 'linux_build'
214+
}
215+
post { failure { script { FAILED_STAGE = env.STAGE_NAME } } }
216+
}
217+
stage('Windows Build')
218+
{
219+
agent { label 'windows' }
220+
steps
221+
{
222+
cleanWs()
223+
bat 'dir'
224+
unstash 'source'
225+
bat 'dir'
226+
bat 'Build.bat -DRUNCPP2_BUILD_TESTS=ON'
227+
stash 'windows_build'
228+
}
229+
post { failure { script { FAILED_STAGE = env.STAGE_NAME } } }
230+
}
231+
}
232+
233+
//NOTE: We use Debug builds for now even for release.
234+
}
235+
236+
stage('Test')
237+
{
238+
when { expression { SKIP_PIPELINE == false } }
239+
parallel
240+
{
241+
stage('Linux Test')
242+
{
243+
agent { label 'linux' }
244+
steps
245+
{
246+
cleanWs()
247+
bash "ls -lah"
248+
unstash 'linux_build'
249+
bash "ls -lah"
250+
bash './Build/BuildsManagerTest'
251+
}
252+
post { failure { script { FAILED_STAGE = env.STAGE_NAME } } }
253+
}
254+
stage('Windows Test')
255+
{
256+
agent { label 'windows' }
257+
steps
258+
{
259+
cleanWs()
260+
bat 'dir'
261+
unstash 'windows_build'
262+
bat 'dir'
263+
bat '.\\Build\\Debug\\BuildsManagerTest.exe'
264+
}
265+
post { failure { script { FAILED_STAGE = env.STAGE_NAME } } }
266+
}
267+
}
268+
}
269+
270+
stage('Notify')
271+
{
272+
agent { label 'linux' }
273+
when { expression { SKIP_PIPELINE == false && STORE_BUILD == false } }
274+
steps
275+
{
276+
cleanWs()
277+
withCredentials([string(credentialsId: 'github-token', variable: 'GITHUB_TOKEN')])
278+
{
279+
SetGithubStatus('$GITHUB_TOKEN',
280+
"Build ${BUILD_NUMBER}",
281+
STATUS_CONTEXT_URL,
282+
"Pipeline passed",
283+
"success",
284+
REPO_OWNER,
285+
REPO_NAME,
286+
GIT_HASH)
287+
}
288+
}
289+
}
290+
291+
stage('Release')
292+
{
293+
agent { label 'linux' }
294+
when { expression { SKIP_PIPELINE == false && STORE_BUILD == true } }
295+
steps
296+
{
297+
cleanWs()
298+
dir('WindowsBuild') { unstash 'windows_build' }
299+
dir('LinuxBuild') { unstash 'linux_build' }
300+
301+
archiveArtifacts artifacts: 'LinuxBuild/Build/runcpp2',
302+
defaultExcludes: false,
303+
fingerprint: true,
304+
onlyIfSuccessful: true
305+
306+
archiveArtifacts artifacts: 'WindowsBuild/Build/Debug/runcpp2.exe',
307+
defaultExcludes: false,
308+
fingerprint: true,
309+
onlyIfSuccessful: true
310+
}
311+
}
312+
} //stages
313+
314+
post
315+
{
316+
failure
317+
{
318+
node('linux')
319+
{
320+
script
321+
{
322+
if(!STORE_BUILD)
323+
{
324+
withCredentials([string(credentialsId: 'github-token', variable: 'GITHUB_TOKEN')])
325+
{
326+
SetGithubStatus('$GITHUB_TOKEN',
327+
"Build ${BUILD_NUMBER}",
328+
STATUS_CONTEXT_URL,
329+
"Stage ${FAILED_STAGE} failed",
330+
"failure",
331+
REPO_OWNER,
332+
REPO_NAME,
333+
GIT_HASH)
334+
}
335+
}
336+
}
337+
}
338+
}
339+
}
340+
} //pipeline

0 commit comments

Comments
 (0)