Skip to content

Commit f96f320

Browse files
SONARJAVA-5850 Migrate Windows Build from Cirrus to GitHub action (#5346)
1 parent 01cd69a commit f96f320

File tree

6 files changed

+74
-30
lines changed

6 files changed

+74
-30
lines changed

.cirrus.yml

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,32 @@ build_task:
8989
- regular_mvn_build_deploy_analyze -Dmaven.test.skip=true -Dsonar.skip=true -pl '!java-checks-test-sources/default,!java-checks-test-sources/aws,!java-checks-test-sources/spring-web-4.0'
9090
cleanup_before_cache_script: cleanup_maven_repository
9191

92+
sonar_shadow_scan_and_issue_replication_task:
93+
<<: *COMMON_BUILD_DEFINITION
94+
depends_on:
95+
- build
96+
# Only run when triggered by the cirrus-ci cron job named "nightly"
97+
only_if: $CIRRUS_CRON == "nightly"
98+
env:
99+
SONAR_PROJECT_KEY: "org.sonarsource.java:java"
100+
SHADOW_ORGANIZATION: "sonarsource"
101+
SHADOW_PROJECT_KEY: "SonarSource_sonar-java"
102+
# to replicate issue states from next
103+
SONAR_TOKEN: VAULT[development/kv/data/next data.token]
104+
SONAR_HOST_URL: https://next.sonarqube.com/sonarqube
105+
matrix:
106+
- name: "sonarcloud.io"
107+
SHADOW_SONAR_TOKEN: VAULT[development/kv/data/sonarcloud data.token]
108+
SHADOW_SONAR_HOST_URL: "https://sonarcloud.io"
109+
- name: "sonarqube.us"
110+
SHADOW_SONAR_TOKEN: VAULT[development/kv/data/sonarqube-us data.token]
111+
SHADOW_SONAR_HOST_URL: "https://sonarqube.us"
112+
build_and_shadow_scan_script:
113+
- *log_develocity_url_script
114+
- source cirrus-env BUILD
115+
- ./shadow-scan-and-issue-replication.sh -Dsonar.analysisCache.enabled=true -Dsonar.sca.exclusions="**/test/files/**, **/test/resources/**, its/plugin/projects/**, java-checks-test-sources/**, its/sources/**,"
116+
cleanup_before_cache_script: cleanup_maven_repository
117+
92118
# Migrated to GHA.
93119
test_analyze_task:
94120
<<: *COMMON_BUILD_DEFINITION
@@ -103,28 +129,7 @@ test_analyze_task:
103129
- ./check-license-compliance.sh
104130
cleanup_before_cache_script: cleanup_maven_repository
105131

106-
ws_scan_task:
107-
<<: *ONLY_SONARSOURCE_QA
108-
eks_container:
109-
<<: *CONTAINER_WITH_DOCKER_DEFINITION
110-
cpu: 4
111-
memory: 4G
112-
# run only on master and long-term branches
113-
only_if: $CIRRUS_USER_COLLABORATOR == 'true' && ($CIRRUS_BRANCH == "master" || $CIRRUS_BRANCH =~ "branch-.*" || $CIRRUS_BRANCH =~ "mend-.*")
114-
env:
115-
WS_APIKEY: VAULT[development/kv/data/mend data.apikey]
116-
maven_cache:
117-
folder: ${CIRRUS_WORKING_DIR}/.m2/repository
118-
whitesource_script:
119-
- source cirrus-env QA
120-
- source set_maven_build_version $BUILD_NUMBER
121-
- mvn clean install --batch-mode -Dmaven.test.skip=true -pl '!java-checks-test-sources,!java-checks-test-sources/default,!java-checks-test-sources/aws,!java-checks-test-sources/spring-3.2,!java-checks-test-sources/spring-web-4.0'
122-
- source ws_scan.sh
123-
allow_failures: "true"
124-
always:
125-
ws_artifacts:
126-
path: "whitesource/**/*"
127-
132+
# Migrated to GHA.
128133
qa_os_win_task:
129134
ec2_instance:
130135
image: base-windows-jdk21-v*
@@ -288,13 +293,13 @@ autoscan_task:
288293
promote_task:
289294
depends_on:
290295
- build
296+
- sonar_shadow_scan_and_issue_replication
291297
- test_analyze
292298
- qa_os_win
293299
- sanity
294300
- ruling
295301
- ruling_win
296302
- plugin_qa
297-
- ws_scan
298303
- autoscan
299304
<<: *ONLY_SONARSOURCE_QA
300305
eks_container:

.github/workflows/build.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,3 +271,42 @@ jobs:
271271
-Dmaven.test.redirectTestOutputToFile=false
272272
-Dparallel=methods
273273
-DuseUnlimitedThreads=true
274+
275+
qa-os-win:
276+
name: Build and Unit Test on Windows
277+
# No dependency on build step, because we do not need the build number.
278+
runs-on: github-windows-latest-m
279+
permissions:
280+
id-token: write # Required for Vault OIDC authentication
281+
contents: write # Required for repository access and tagging
282+
steps:
283+
- name: Config Git
284+
run: git config --global core.autocrlf input
285+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
286+
- uses: jdx/mise-action@5ac50f778e26fac95da98d50503682459e86d566 # v3.2.0
287+
with:
288+
version: 2025.7.12
289+
- name: Run Maven
290+
run: mvn clean verify --batch-mode
291+
292+
promote:
293+
needs:
294+
- build
295+
- ruling-qa
296+
- plugin-qa
297+
- sanity
298+
- test-analyze
299+
- autoscan
300+
- qa-os-win
301+
if: ${{ needs.build.outputs.deployed }}
302+
runs-on: github-ubuntu-latest-s # Public repo uses custom GitHub-hosted runners
303+
name: Promote
304+
permissions:
305+
id-token: write
306+
contents: write
307+
env:
308+
BUILD_NUMBER: ${{ needs.build.outputs.build-number }}
309+
steps:
310+
- uses: SonarSource/ci-github-actions/promote@v1
311+
with:
312+
promote-pull-request: true

java-checks-test-sources/pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@
4343
<fileSeparator>/</fileSeparator>
4444
<pathSeparator>:${line.separator}</pathSeparator>
4545
<includeScope>test</includeScope>
46-
<!-- $$ to not evaluate M2_REPO now, this will become ${M2_REPO} in the output file -->
47-
<localRepoProperty>$${M2_REPO}</localRepoProperty>
46+
<localRepoProperty>M2_REPO</localRepoProperty>
4847
<outputEncoding>UTF-8</outputEncoding>
4948
<outputFile>${project.build.directory}/test-classpath.txt</outputFile>
5049
</configuration>

java-checks-test-sources/test-classpath-reader/src/main/java/org/sonar/java/test/classpath/TestClasspathUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,12 @@ public static List<File> loadFromFile(String classpathTextFilePath) {
158158
String mavenRepository = findMavenLocalRepository(System::getenv, System::getProperty);
159159
try {
160160
String content = Files.readString(toPath(classpathTextFilePath), UTF_8);
161-
Arrays.stream(content.split(":"))
161+
// Split on ":", but not when it follows Windows drive letter (e.g. "C:\").
162+
Arrays.stream(content.split("(?<![A-Z]):"))
162163
.map(String::trim)
163164
.filter(line -> !line.isBlank())
164165
.map(TestClasspathUtils::fixSeparator)
165-
.map(line -> line.replace("${M2_REPO}", mavenRepository))
166+
.map(line -> line.replace("M2_REPO", mavenRepository))
166167
.map(Paths::get)
167168
.forEach(dependencyPath -> {
168169
if (!Files.exists(dependencyPath)) {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
${M2_REPO}/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar:
1+
M2_REPO/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar:
22

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
${M2_REPO}/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar:
2-
${M2_REPO}/org/bad/luck/missing-artifact/666/missing-artifact-666.jar:
1+
M2_REPO/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar:
2+
M2_REPO/org/bad/luck/missing-artifact/666/missing-artifact-666.jar:

0 commit comments

Comments
 (0)