Skip to content

Commit

Permalink
Merge branch 'main' into bs/fix-CHEF-8031
Browse files Browse the repository at this point in the history
  • Loading branch information
balasubramanian-s committed Mar 27, 2024
2 parents d546ca1 + 0f55383 commit b8ec2f6
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 28 deletions.
37 changes: 36 additions & 1 deletion .expeditor/buildkite/coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,45 @@ bundle --version
echo "--- system environment"
env

echo "--- installing vault"
export VAULT_VERSION=1.13.0
export VAULT_HOME=$HOME/vault
curl --create-dirs -sSLo $VAULT_HOME/vault.zip https://releases.hashicorp.com/vault/$VAULT_VERSION/vault_${VAULT_VERSION}_linux_amd64.zip
unzip -o $VAULT_HOME/vault.zip -d $VAULT_HOME

if [ -n "${CI_ENABLE_COVERAGE:-}" ]; then
echo "--- fetching Sonar token from vault"
export SONAR_TOKEN=$($VAULT_HOME/vault kv get -field token secret/inspec/train)
fi

echo "--- bundle install"
bundle config set --local without tools integration
bundle install --jobs=7 --retry=3

echo "+++ bundle exec rake"
bundle exec rake
bundle exec rake ${RAKE_TASK:-}
RAKE_EXIT=$?

if [ -n "${CI_ENABLE_COVERAGE:-}" ]; then
echo "--- installing sonarscanner"
export SONAR_SCANNER_VERSION=4.7.0.2747
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
export PATH=$SONAR_SCANNER_HOME/bin:$PATH
export SONAR_SCANNER_OPTS="-server"

# Delete the vendor/ directory. I've tried to exclude it using sonar.exclusions,
# but that appears to get ignored, and we end up analyzing the gemfile install
# which blows our analysis.
echo "--- deleting installed gems"
rm -rf vendor/

# See sonar-project.properties for additional settings
echo "--- running sonarscanner"
sonar-scanner \
-Dsonar.sources=. \
-Dsonar.host.url=https://sonar.progress.com
fi

exit $RAKE_EXIT
2 changes: 1 addition & 1 deletion .expeditor/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ pipelines:
- verify:
description: Pull Request validation tests
public: true

- coverage:
description: Generate test coverage report
trigger: pull_request
35 changes: 13 additions & 22 deletions .expeditor/coverage.pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
---
# TODO: Update pipeline when we introduce the coverage pipeline
expeditor:
defaults:
buildkite:
timeout_in_minutes: 45
retry:
automatic:
limit: 1

steps:
- label: "placeholder-for-coverage-pipeline"

- label: coverage-ruby-3.0.6
command:
- CI_ENABLE_COVERAGE=1 RAKE_TASK=test /workdir/.expeditor/buildkite/coverage.sh
expeditor:
secrets: true
executor:
docker:
commands:
- "echo ## This pipeline does nothing. Implement the coverage pipeline in near future."

# steps:
# - label: coverage
# commands:
# - /workdir/.expeditor/buildkite/coverage.sh
# expeditor:
# secrets:
# COVERALLS_REPO_TOKEN:
# path: secret/coveralls/inspec/train
# field: repo_token
# executor:
# docker:
# environment:
# - CI_ENABLE_COVERAGE=true
# - CI_NAME=Buildkite
# - CI_BUILD_NUMBER=$BUILDKITE_BUILD_NUMBER
# - CI_BUILD_URL=$BUILDKITE_BUILD_URL
# - CI_BRANCH=$BUILDKITE_BRANCH
image: ruby:3.0.6
15 changes: 13 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
<!-- latest_release -->
<!-- latest_release unreleased -->
## Unreleased

#### Merged Pull Requests
- CHEF-7180: Fix configuration values in sonar configuration file [#761](https://github.com/inspec/train/pull/761) ([Vasu1105](https://github.com/Vasu1105))
- Adds missing configuration for coverage pipeline [#760](https://github.com/inspec/train/pull/760) ([Vasu1105](https://github.com/Vasu1105))
<!-- latest_release -->

<!-- release_rollup -->
<!-- release_rollup since=3.11.0 -->
### Changes not yet released to rubygems.org

#### Merged Pull Requests
- CHEF-7180: Fix configuration values in sonar configuration file [#761](https://github.com/inspec/train/pull/761) ([Vasu1105](https://github.com/Vasu1105)) <!-- 3.11.1 -->
- Adds missing configuration for coverage pipeline [#760](https://github.com/inspec/train/pull/760) ([Vasu1105](https://github.com/Vasu1105)) <!-- 3.11.1 -->
- CHEF-7180: Configures sonarqube for code coverage anlaysis [#758](https://github.com/inspec/train/pull/758) ([Vasu1105](https://github.com/Vasu1105)) <!-- 3.11.1 -->
<!-- release_rollup -->

<!-- latest_stable_release -->
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ group :test do
# See test/unit/
gem "train-test-fixture", path: "test/fixtures/plugins/train-test-fixture"
gem "mocha", "~> 2.1"
gem "simplecov", "~> 0.21"
gem "simplecov_json_formatter"
end

if Gem.ruby_version >= Gem::Version.new("2.7.0")
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.11.0
3.11.1
2 changes: 1 addition & 1 deletion lib/train/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# Author:: Dominik Richter (<[email protected]>)

module Train
VERSION = "3.11.0".freeze
VERSION = "3.11.1".freeze
end
17 changes: 17 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# must be unique in a given SonarQube instance
sonar.projectKey=inspec_train_AYvrnSZVG2RNgd1H9han

sonar.projectName=Chef-Inspec-train

# TODO: provide path to test coverage report generated by simplecov or any other code coverage tool
#sonar.ruby.coverage.reportPaths=coverage/coverage.json

# exclude test directories from coverage
sonar.coverage.exclusions=test/*

sonar.exclusions=**/*.java,**/*.js,vendor/*

# skip C-language processor
sonar.c.file.suffixes=-
sonar.cpp.file.suffixes=-
sonar.objc.file.suffixes=-

0 comments on commit b8ec2f6

Please sign in to comment.