Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.10](backport #3108) Sonarqube buildkite integration #3446

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .buildkite/hooks/post-checkout
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ MERGE_BRANCH="pr_merge_${PR_ID}"

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

echo "--- Commit information"
git log --format=%B -n 1
echo "Commit information"
git --no-pager log --format=%B -n 1

# Ensure buildkite groups are rendered
echo ""
27 changes: 27 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,33 @@ env:
VAULT_PATH: "kv/ci-shared/observability-ingest/cloud/gcp"
DOCKER_REGISTRY: "docker.elastic.co"
steps:
- label: "Unit tests"
key: "unit-tests"
command: ".buildkite/scripts/steps/unit-tests.sh"
artifact_paths:
- "build/TEST-**"
- "build/diagnostics/*"
agents:
provider: "gcp"
retry:
manual:
allowed: true

- label: ":sonarqube: Continuous Code Inspection"
env:
VAULT_SONAR_TOKEN_PATH: "kv/ci-shared/platform-ingest/elastic/elastic-agent/sonar-analyze-token"
agents:
image: "docker.elastic.co/cloud-ci/sonarqube/buildkite-scanner:latest"
command:
- "buildkite-agent artifact download build/TEST-go-unit.cov ."
- "buildkite-agent artifact download build/TEST-go-unit.out.json ."
- "/scan-source-code.sh"
depends_on:
- "unit-tests"
retry:
manual:
allowed: true

- label: "Integration tests"
key: "integration-tests"
command: ".buildkite/scripts/steps/integration_tests.sh"
Expand Down
4 changes: 2 additions & 2 deletions .buildkite/scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ mage() {
go version
if ! [ -x "$(type -p mage | sed 's/mage is //g')" ];
then
echo "--- installing mage ${SETUP_MAGE_VERSION}"
echo "installing mage ${SETUP_MAGE_VERSION}"
make mage
fi
pushd "$WORKSPACE"
Expand All @@ -71,7 +71,7 @@ go(){
if ! [ -x "$(type -p go | sed 's/go is //g')" ];
then
getOSOptions
echo "--- installing golang "${GO_VERSION}" for "${AGENT_OS_NAME}/${AGENT_OS_ARCH}" "
echo "installing golang "${GO_VERSION}" for "${AGENT_OS_NAME}/${AGENT_OS_ARCH}" "
local _bin="${WORKSPACE}/bin"
mkdir -p "${_bin}"
retry 5 curl -sL -o "${_bin}/gvm" "https://github.com/andrewkroh/gvm/releases/download/${SETUP_GVM_VERSION}/gvm-${AGENT_OS_NAME}-${AGENT_OS_ARCH}"
Expand Down
7 changes: 7 additions & 0 deletions .buildkite/scripts/steps/unit-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -euxo pipefail

source .buildkite/scripts/common.sh

echo "--- Unit tests"
TEST_COVERAGE=true mage unitTest
55 changes: 0 additions & 55 deletions .github/workflows/build.yml

This file was deleted.

120 changes: 0 additions & 120 deletions .github/workflows/sonarcloud.yml

This file was deleted.

7 changes: 3 additions & 4 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
sonar.organization=elastic-1
sonar.projectKey=elastic_elastic-agent
sonar.host.url=https://sonarcloud.io
sonar.projectKey=elastic_elastic-agent_AYluowg0xMq8P7b4moiZ
sonar.host.url=https://sonar.elastic.dev

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

sonar.sourceEncoding=UTF-8

#Prevent C analysis
# Prevent C analysis
sonar.c.file.suffixes=-
sonar.cpp.file.suffixes=-
sonar.objc.file.suffixes=-