Skip to content

Commit 9df9678

Browse files
committed
Fixes #19354: Add ci checks on rudder-agent repo
1 parent de75a05 commit 9df9678

File tree

6 files changed

+83
-12
lines changed

6 files changed

+83
-12
lines changed

Jenkinsfile

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
@Library('slack-notification')
2+
import org.gradiant.jenkins.slack.SlackNotifier
3+
4+
pipeline {
5+
agent none
6+
7+
stages {
8+
stage('Tests') {
9+
parallel {
10+
stage('shell') {
11+
agent { label 'script' }
12+
steps {
13+
sh script: 'typos', label: 'check typos'
14+
sh script: './qa-test --shell', label: 'shell scripts lint'
15+
}
16+
post {
17+
always {
18+
// linters results
19+
recordIssues enabledForFailure: true, failOnError: true, sourceCodeEncoding: 'UTF-8',
20+
tool: checkStyle(pattern: '.shellcheck/*.log', reportEncoding: 'UTF-8', name: 'Shell scripts')
21+
22+
script {
23+
new SlackNotifier().notifyResult("shell-team")
24+
}
25+
}
26+
}
27+
}
28+
stage('man') {
29+
agent { label 'script' }
30+
steps {
31+
dir("man") {
32+
sh script: 'make', label: 'man page'
33+
}
34+
}
35+
post {
36+
always {
37+
script {
38+
new SlackNotifier().notifyResult("shell-team")
39+
}
40+
}
41+
}
42+
}
43+
}
44+
}
45+
}
46+
}

qa-test

+32-7
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,36 @@
22

33
set -ex
44

5-
# Shellcheck
6-
find * -type f -exec bash -c "head -n1 {} | grep -Eq '^#!(.*/|.*env +)(sh|bash|ksh)'" \; -print |
7-
while IFS="" read -r file
8-
do
9-
# with recent shellcheck, "-S error" replaces this hack
10-
shellcheck -f gcc "$file" | grep " error: " && exit 1 || true
11-
done
5+
test_shell()
6+
{
7+
mkdir -p .shellcheck
8+
find . -path ./.git -prune -o -type f -exec grep -Eq '^#!(.*/|.*env +)(sh|bash|ksh)' {} \; -print |
9+
while IFS="" read -r file
10+
do
11+
# collect all warnings
12+
shellcheck --format=checkstyle "$file" > .shellcheck/$(basename ${file}).log || true
13+
# fail on >=error
14+
shellcheck --severity error "$file"
15+
done
16+
}
1217

18+
# fails on error and ignores other levels
19+
test_shell_error()
20+
{
21+
# Shellcheck
22+
find . -path ./.git -prune -o -type f -exec grep -Eq '^#!(.*/|.*env +)(sh|bash|ksh)' {} \; -print |
23+
while IFS="" read -r file
24+
do
25+
# with recent shellcheck, "-S error" replaces this hack
26+
# kept as this runs on machines running rudder-dev
27+
shellcheck --format gcc "$file" | grep " error: " && exit 1 || true
28+
done
29+
}
30+
31+
if [ "$1" = "--shell" ]; then
32+
test_shell
33+
exit 0
34+
else
35+
# quick tests to be launched during merge
36+
test_shell_error
37+
fi

share/commands/agent-inventory

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
bootstrap_check
3333

34-
# We cannnot start an inventory in bootstrap policies
34+
# We cannot start an inventory in bootstrap policies
3535
if cmp -s "/var/rudder/cfengine-community/inputs/failsafe.cf" "/opt/rudder/share/bootstrap-promises/failsafe.cf"
3636
then
3737
>&2 echo "Agent is currently in bootstrap policies, cannot run an inventory. Please download initial policies from the server with command \"rudder agent update\" first. If problem persists, use \"rudder agent check\" for diagnostic"

share/commands/remote-run

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ while getopts "iIvdqwrRcTD:j:g:at:u:C:eE" opt; do
140140
esac
141141
done
142142

143-
# to read remaing arguments with $*
143+
# to read remaining arguments with $*
144144
shift `expr ${OPTIND} - 1`
145145

146146
# Define node list method

share/commands/server-directive-migrate-package

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ print_result() {
3434
if [ "${STATUS}" == "success" ]
3535
then
3636
NEW_DIRECTIVE_ID=$(filtered_api_call "${API_URL}/api/latest/directives" "${TOKEN}" "GET" "" "${DISPLAY_COMMAND}" | jq -r " .data.directives[] | select(.displayName==\"${DISPLAY_NAME}_migrated\") | .id")
37-
printf "[${GREEN}SUCCESS${NORMAL}] Directive created. You can execute the following command to change all occurence of the old directive to the new one in your rules:\n"
37+
printf "[${GREEN}SUCCESS${NORMAL}] Directive created. You can execute the following command to change all occurrence of the old directive to the new one in your rules:\n"
3838
printf "${WHITE}rudder server directive-replace -o ${OLD_DIRECTIVE_ID} -n ${NEW_DIRECTIVE_ID}${NORMAL}\n"
3939
elif [ "${STATUS}" == "error" ]
4040
then

share/commands/server-directive-replace

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
2-
# @description replace a directive occurence in all the Rudder rules by another directive.
3-
# @man replace a directive occurence in all the Rudder rules by another directive.
2+
# @description replace a directive occurrence in all the Rudder rules by another directive.
3+
# @man replace a directive occurrence in all the Rudder rules by another directive.
44
# @man +
55
# @man *Arguments*:
66
# @man +

0 commit comments

Comments
 (0)