Skip to content
Merged
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
54 changes: 37 additions & 17 deletions .github/workflows/ci-test-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ jobs:

- name: Check out code into the Go module directory
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
Expand Down Expand Up @@ -82,23 +85,6 @@ jobs:
timeout-minutes: 30
run: make test-unit

- name: Set sonar artifact name
# For the core library, where the project directory is '.', we'll use "core" as artifact name.
# For the modules, we'll remove the slashes, keeping the name of the module
if: ${{ github.ref_name == 'main' && github.repository_owner == 'testcontainers' && matrix.platform == 'ubuntu-latest' && !inputs.rootless-docker && !inputs.ryuk-disabled }}
run: |
echo "ARTIFACT_NAME=$(basename ${{ inputs.project-directory == '.' && 'core' || inputs.project-directory }})-${{ inputs.go-version }}-${{ matrix.platform }}" >> $GITHUB_ENV

- name: Upload SonarCloud files
if: ${{ github.ref_name == 'main' && github.repository_owner == 'testcontainers' && matrix.platform == 'ubuntu-latest' && !inputs.rootless-docker && !inputs.ryuk-disabled }}
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
with:
name: sonarcloud-${{ env.ARTIFACT_NAME }}
path: |
./sonar-project.properties
${{ inputs.project-directory }}/TEST-unit.xml
${{ inputs.project-directory }}/coverage.out

- name: Run checker
run: |
./scripts/check_environment.sh
Expand All @@ -108,3 +94,37 @@ jobs:
with:
paths: "**/${{ inputs.project-directory }}/TEST-unit*.xml"
if: always()


- name: Set Sonar Cloud environment variables
if: ${{ !inputs.rootless-docker && !inputs.ryuk-disabled && github.ref_name == 'main' && github.repository_owner == 'testcontainers' }}
run: |
echo "PROJECT_VERSION=$(grep 'latest_version' mkdocs.yml | cut -d':' -f2 | tr -d ' ')" >> $GITHUB_ENV
if [ "${{ inputs.project-directory }}" = "." ]; then
echo "PROJECT_KEY=testcontainers_testcontainers-go" >> $GITHUB_ENV
echo "PROJECT_NAME=testcontainers-go" >> $GITHUB_ENV
else
echo "PROJECT_KEY=testcontainers_testcontainers-go_$(echo ${{ inputs.project-directory }} | tr '/' '_')" >> $GITHUB_ENV
echo "PROJECT_NAME=testcontainers-go-$(echo ${{ inputs.project-directory }} | tr '/' '-')" >> $GITHUB_ENV
fi

- name: SonarQube Scan
if: ${{ !inputs.rootless-docker && !inputs.ryuk-disabled && github.ref_name == 'main' && github.repository_owner == 'testcontainers' }}
uses: SonarSource/sonarqube-scan-action@0303d6b62e310685c0e34d0b9cde218036885c4d # v5.0.0
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: "${{ inputs.project-directory == '.' && 'testcontainers-go' || inputs.project-directory }}"
args: >
-Dsonar.organization=testcontainers
-Dsonar.projectKey=${{ env.PROJECT_KEY }}
-Dsonar.projectName=${{ env.PROJECT_NAME }}
-Dsonar.projectVersion=${{ env.PROJECT_VERSION }}
-Dsonar.project.monorepo.enabled=true
-Dsonar.sources=.
-Dsonar.exclusions=**/*_test.go,**/vendor/**,**/testdata/**
-Dsonar.tests=.
-Dsonar.test.inclusions=**/*_test.go
-Dsonar.test.exclusions=**/vendor/**
-Dsonar.go.coverage.reportPaths=coverage.out
-Dsonar.go.tests.reportPaths=TEST-unit.xml
30 changes: 3 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ jobs:
matrix:
go-version: [1.23.x, 1.24.x]
module: ${{ fromJSON(needs.detect-modules.outputs.modules) }}
permissions:
contents: read # for actions/checkout to fetch code
pull-requests: read # for sonarsource/sonarcloud-github-action to determine which PR to decorate
uses: ./.github/workflows/ci-test-go.yml
with:
go-version: ${{ matrix.go-version }}
Expand Down Expand Up @@ -124,30 +127,3 @@ jobs:
run: exit 1

- run: echo "All tests completed successfully!"

sonarcloud:
permissions:
contents: read # for actions/checkout to fetch code
pull-requests: read # for sonarsource/sonarcloud-github-action to determine which PR to decorate
if: ${{ github.ref_name == 'main' && github.repository_owner == 'testcontainers' && needs.detect-modules.outputs.modules_count > 0 }}
needs:
- detect-modules
- test
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0

- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
pattern: sonarcloud-*
merge-multiple: true

- name: Analyze with SonarCloud
uses: sonarsource/sonarcloud-github-action@02ef91109b2d589e757aefcfb2854c2783fd7b19 # v4.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
21 changes: 0 additions & 21 deletions modulegen/_template/sonar-project.properties.tmpl

This file was deleted.

2 changes: 1 addition & 1 deletion modulegen/cmd/modules/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var NewCmd = &cobra.Command{
var RefreshModulesCmd = &cobra.Command{
Use: "refresh",
Short: "Refresh the module and example files",
Long: "Refresh the module and example files, including the dependabot config, mkdocs config, sonar properties, vscode settings and makefiles for all the modules and examples",
Long: "Refresh the module and example files, including the dependabot config, mkdocs config, vscode settings and makefiles for all the modules and examples",
RunE: func(_ *cobra.Command, _ []string) error {
ctx, err := context.GetRootContext()
if err != nil {
Expand Down
5 changes: 0 additions & 5 deletions modulegen/internal/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,6 @@ func (ctx Context) MkdocsConfigFile() string {
return filepath.Join(ctx.RootDir, "mkdocs.yml")
}

// SonarProjectFile returns, from the root directory, the relative path to the sonar project file, "/sonar-project.properties".
func (ctx Context) SonarProjectFile() string {
return filepath.Join(ctx.RootDir, "sonar-project.properties")
}

// VSCodeWorkspaceFile returns, from the root directory, the relative path to the vscode workspace file, "/.vscode/.testcontainers-go.code-workspace".
func (ctx Context) VSCodeWorkspaceFile() string {
return filepath.Join(ctx.RootDir, ".vscode", ".testcontainers-go.code-workspace")
Expand Down
3 changes: 0 additions & 3 deletions modulegen/internal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/testcontainers/testcontainers-go/modulegen/internal/make"
"github.com/testcontainers/testcontainers-go/modulegen/internal/mkdocs"
"github.com/testcontainers/testcontainers-go/modulegen/internal/module"
"github.com/testcontainers/testcontainers-go/modulegen/internal/sonar"
"github.com/testcontainers/testcontainers-go/modulegen/internal/tools"
"github.com/testcontainers/testcontainers-go/modulegen/internal/vscode"
)
Expand Down Expand Up @@ -72,7 +71,6 @@ func Refresh(ctx context.Context) error {
mkdocs.Generator{}, // update examples in mkdocs
dependabot.Generator{}, // update examples in dependabot
vscode.Generator{}, // update vscode workspace
sonar.Generator{}, // update sonar-project.properties
}

for _, generator := range generators {
Expand Down Expand Up @@ -122,7 +120,6 @@ func GenerateFiles(ctx context.Context, tcModule context.TestcontainersModule) e
// module generation
projectGenerators := []ProjectGenerator{
vscode.Generator{}, // update vscode workspace
sonar.Generator{}, // update sonar-project.properties
}

examples, err := ctx.GetExamples()
Expand Down
31 changes: 0 additions & 31 deletions modulegen/internal/sonar/main.go

This file was deleted.

41 changes: 0 additions & 41 deletions modulegen/internal/sonar/types.go

This file was deleted.

7 changes: 0 additions & 7 deletions modulegen/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,13 +580,6 @@ func copyInitialProject(t *testing.T) testProject {
err = os.WriteFile(tmpCtx.GoModFile(), goModFile, 0o777)
require.NoError(t, err)

// sonar-project.properties
sonarProjectFile, err := os.ReadFile(ctx.SonarProjectFile())
require.NoError(t, err)

err = os.WriteFile(tmpCtx.SonarProjectFile(), sonarProjectFile, 0o777)
require.NoError(t, err)

// .vscode/testcontainers-go.code-workspace
err = os.MkdirAll(filepath.Dir(tmpCtx.VSCodeWorkspaceFile()), 0o777)
require.NoError(t, err)
Expand Down
6 changes: 3 additions & 3 deletions scripts/changed-modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ set -euxo pipefail
# The output should be: no modules.
#
# 14. A excluded file and a file from the core module are modified:
# ALL_CHANGED_FILES="mkdocs.yml sonar-project.properties go.mod" ./scripts/changed-modules.sh
# ALL_CHANGED_FILES="mkdocs.yml go.mod" ./scripts/changed-modules.sh
# The output should be: all modules.
#
# 15. Only excluded files are modified:
# ALL_CHANGED_FILES="mkdocs.yml sonar-project.properties" ./scripts/changed-modules.sh
# ALL_CHANGED_FILES="mkdocs.yml" ./scripts/changed-modules.sh
# The output should be: no modules.
#
# There is room for improvement in this script. For example, it could detect if the changes applied to the docs or the .github dirs, and then do not include any module in the list.
Expand All @@ -74,7 +74,7 @@ readonly ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
readonly excluded_modules=(".devcontainer" ".vscode" "docs")

# define an array of files that won't be included in the list
readonly excluded_files=("mkdocs.yml" ".github/dependabot.yml" "sonar-project.properties")
readonly excluded_files=("mkdocs.yml" ".github/dependabot.yml")

# define an array of modules that won't be part of the build
readonly no_build_modules=("modules/k6")
Expand Down
10 changes: 0 additions & 10 deletions scripts/pre-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ readonly DRY_RUN="${DRY_RUN:-true}"
readonly CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
readonly ROOT_DIR="$(dirname "$CURRENT_DIR")"
readonly MKDOCS_FILE="${ROOT_DIR}/mkdocs.yml"
readonly SONARCLOUD_FILE="${ROOT_DIR}/sonar-project.properties"
readonly VERSION_FILE="${ROOT_DIR}/internal/version.go"

readonly REPOSITORY="github.com/testcontainers/testcontainers-go"
Expand Down Expand Up @@ -42,15 +41,6 @@ function bumpVersion() {
mv ${MKDOCS_FILE}.tmp ${MKDOCS_FILE}
fi

# Bump version in the sonarcloud properties file
if [[ "${DRY_RUN}" == "true" ]]; then
echo "sed \"s/sonar\.projectVersion=.*/sonar\.projectVersion=${versionToBump}/g\" ${SONARCLOUD_FILE} > ${SONARCLOUD_FILE}.tmp"
echo "mv ${SONARCLOUD_FILE}.tmp ${SONARCLOUD_FILE}"
else
sed "s/sonar\.projectVersion=.*/sonar\.projectVersion=${versionToBump}/g" ${SONARCLOUD_FILE} > ${SONARCLOUD_FILE}.tmp
mv ${SONARCLOUD_FILE}.tmp ${SONARCLOUD_FILE}
fi

# Bump version across all modules, in their go.mod files
for directory in "${DIRECTORIES[@]}"
do
Expand Down
2 changes: 0 additions & 2 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ readonly DRY_RUN="${DRY_RUN:-true}"
readonly CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
readonly ROOT_DIR="$(dirname "$CURRENT_DIR")"
readonly MKDOCS_FILE="${ROOT_DIR}/mkdocs.yml"
readonly SONARCLOUD_FILE="${ROOT_DIR}/sonar-project.properties"
readonly VERSION_FILE="${ROOT_DIR}/internal/version.go"

readonly REPOSITORY="github.com/testcontainers/testcontainers-go"
Expand Down Expand Up @@ -126,7 +125,6 @@ function gitCommitVersion() {

gitFn add "${VERSION_FILE}"
gitFn add "${MKDOCS_FILE}"
gitFn add "${SONARCLOUD_FILE}"
gitFn add "docs/**/*.md"
gitFn add "examples/**/go.*"
gitFn add "modules/**/go.*"
Expand Down
21 changes: 0 additions & 21 deletions sonar-project.properties

This file was deleted.

Loading