Skip to content

Commit 333e05b

Browse files
committed
feat: add proper error codes for pipeline
1 parent 9a41ddd commit 333e05b

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

.github/workflows/go.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This workflow will build a golang project
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
3+
4+
name: Go
5+
6+
on:
7+
push:
8+
branches: [ "main" ]
9+
tags:
10+
- '*'
11+
pull_request:
12+
branches: [ "main" ]
13+
14+
jobs:
15+
16+
build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Set up Go
21+
uses: actions/setup-go@v4
22+
with:
23+
go-version: '1.22'
24+
- name: Build
25+
run: go build ./
26+
- name: Release
27+
uses: softprops/action-gh-release@v2
28+
if: startsWith(github.ref, 'refs/tags/')
29+
with:
30+
files: sps-buddy

example.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
VERSION : 0.1
44
VAR_INPUT
55
errorActive : Bool;
6+
ErrorActive : Bool;
7+
Error_Active : Bool;
8+
sensor1 : Bool;
69
warningActive : Bool;
710
END_VAR
811

main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ func handleLine(input string) {
3131
fmt.Printf("Success: Variable %s is camel case.\n", parts[0])
3232
} else {
3333
fmt.Printf("Error: Variable %s is not camel case.\n", parts[0])
34+
isErrorDetected = true
3435
}
3536
return
3637
}
3738
}
3839

3940
if inputWithoutWhiteSpaces == "VAR_INPUT" ||
4041
inputWithoutWhiteSpaces == "VAR" ||
42+
inputWithoutWhiteSpaces == "VAR_OUTPUT" ||
4143
inputWithoutWhiteSpaces == "VAR_TEMP" {
4244
parserIsInsideVariableBlock = true
4345
return
@@ -58,6 +60,7 @@ func main() {
5860
file, err := os.Open(fileName)
5961
if err != nil {
6062
fmt.Printf("Error reading file: %s.\n", err.Error())
63+
os.Exit(1)
6164
}
6265

6366
scanner := bufio.NewScanner(file)
@@ -68,8 +71,12 @@ func main() {
6871

6972
if err := scanner.Err(); err != nil {
7073
fmt.Printf("Error scanning file: %s.\n", err.Error())
74+
isErrorDetected = true
7175
}
7276

7377
file.Close()
78+
if isErrorDetected == true {
79+
os.Exit(1)
80+
}
7481
os.Exit(0)
7582
}

0 commit comments

Comments
 (0)