Skip to content

Commit 2e9a256

Browse files
authored
Sonarqube buildkite integration (#3108)
* Sonarqube buildkite integration * Sonarqube buildkite integration * Fixed git log * Run unit tests on a VM * Execute ut on main branch * Removed sonarcloud github workflow * Added retry to go download * removed CodeCoverage (build.yml) GHA workflow * Run buildkite unit tests on each pull request * Run buildkite unit tests on each pull request * Run buildkite unit tests on each pull request * Run buildkite unit tests on each pull request * Run buildkite unit tests on each pull request * Added a test file for sonar analysis * Added a test file for sonar analysis * cleanup * Merged with main * Added echo to unit tests * Added echo to unit tests * Fix common.sh logging * Try old way on go installation * Removed comments * check: added not covered file to test sonar notifications * removed the test file
1 parent f2eb134 commit 2e9a256

File tree

7 files changed

+41
-183
lines changed

7 files changed

+41
-183
lines changed

.buildkite/hooks/post-checkout

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ MERGE_BRANCH="pr_merge_${PR_ID}"
4646

4747
checkout_merge "${TARGET_BRANCH}" "${PR_COMMIT}" "${MERGE_BRANCH}"
4848

49-
echo "--- Commit information"
50-
git log --format=%B -n 1
49+
echo "Commit information"
50+
git --no-pager log --format=%B -n 1
5151

5252
# Ensure buildkite groups are rendered
5353
echo ""

.buildkite/pipeline.yml

+27
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,33 @@ env:
44
VAULT_PATH: "kv/ci-shared/observability-ingest/cloud/gcp"
55
DOCKER_REGISTRY: "docker.elastic.co"
66
steps:
7+
- label: "Unit tests"
8+
key: "unit-tests"
9+
command: ".buildkite/scripts/steps/unit-tests.sh"
10+
artifact_paths:
11+
- "build/TEST-**"
12+
- "build/diagnostics/*"
13+
agents:
14+
provider: "gcp"
15+
retry:
16+
manual:
17+
allowed: true
18+
19+
- label: ":sonarqube: Continuous Code Inspection"
20+
env:
21+
VAULT_SONAR_TOKEN_PATH: "kv/ci-shared/platform-ingest/elastic/elastic-agent/sonar-analyze-token"
22+
agents:
23+
image: "docker.elastic.co/cloud-ci/sonarqube/buildkite-scanner:latest"
24+
command:
25+
- "buildkite-agent artifact download build/TEST-go-unit.cov ."
26+
- "buildkite-agent artifact download build/TEST-go-unit.out.json ."
27+
- "/scan-source-code.sh"
28+
depends_on:
29+
- "unit-tests"
30+
retry:
31+
manual:
32+
allowed: true
33+
734
- label: "Integration tests"
835
key: "integration-tests"
936
command: ".buildkite/scripts/steps/integration_tests.sh"

.buildkite/scripts/common.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ mage() {
5555
go version
5656
if ! [ -x "$(type -p mage | sed 's/mage is //g')" ];
5757
then
58-
echo "--- installing mage ${SETUP_MAGE_VERSION}"
58+
echo "installing mage ${SETUP_MAGE_VERSION}"
5959
make mage
6060
fi
6161
pushd "$WORKSPACE"
@@ -71,7 +71,7 @@ go(){
7171
if ! [ -x "$(type -p go | sed 's/go is //g')" ];
7272
then
7373
getOSOptions
74-
echo "--- installing golang "${GO_VERSION}" for "${AGENT_OS_NAME}/${AGENT_OS_ARCH}" "
74+
echo "installing golang "${GO_VERSION}" for "${AGENT_OS_NAME}/${AGENT_OS_ARCH}" "
7575
local _bin="${WORKSPACE}/bin"
7676
mkdir -p "${_bin}"
7777
retry 5 curl -sL -o "${_bin}/gvm" "https://github.com/andrewkroh/gvm/releases/download/${SETUP_GVM_VERSION}/gvm-${AGENT_OS_NAME}-${AGENT_OS_ARCH}"
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
set -euxo pipefail
3+
4+
source .buildkite/scripts/common.sh
5+
6+
echo "--- Unit tests"
7+
TEST_COVERAGE=true mage unitTest

.github/workflows/build.yml

-55
This file was deleted.

.github/workflows/sonarcloud.yml

-120
This file was deleted.

sonar-project.properties

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
sonar.organization=elastic-1
2-
sonar.projectKey=elastic_elastic-agent
3-
sonar.host.url=https://sonarcloud.io
1+
sonar.projectKey=elastic_elastic-agent_AYluowg0xMq8P7b4moiZ
2+
sonar.host.url=https://sonar.elastic.dev
43

54
sonar.sources=.
65
sonar.exclusions=**/*_test.go, .git/**, dev-tools/**, /magefile.go, changelog/**, _meta/**, deploy/**, docs/**, img/**, specs/**, pkg/testing/**
@@ -13,7 +12,7 @@ sonar.go.exclusions=**/vendor/**,**/*_mock.go
1312

1413
sonar.sourceEncoding=UTF-8
1514

16-
#Prevent C analysis
15+
# Prevent C analysis
1716
sonar.c.file.suffixes=-
1817
sonar.cpp.file.suffixes=-
1918
sonar.objc.file.suffixes=-

0 commit comments

Comments
 (0)