Skip to content

Commit e25edae

Browse files
SCCPPGHA-6 Support Running on Linux ARM64 (#57)
Co-authored-by: Michael Jabbour <117195239+michael-jabbour-sonarsource@users.noreply.github.com>
1 parent 905f4e3 commit e25edae

File tree

5 files changed

+61
-12
lines changed

5 files changed

+61
-12
lines changed

.github/workflows/tests.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ jobs:
118118
SONAR_SCANNER_SHA_LINUX: 'DOWNLOAD-SHA-LINUX'
119119
SONAR_SCANNER_URL_MACOSX: 'https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-vX.Y.Z.MMMM-macosx.zip'
120120
SONAR_SCANNER_SHA_MACOSX: 'DOWNLOAD-SHA-MACOSX'
121+
SONAR_SCANNER_URL_UNIVERSAL: 'https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-vX.Y.Z.MMMM.zip'
122+
SONAR_SCANNER_SHA_UNIVERSAL: 'DOWNLOAD-SHA'
121123
steps:
122124
- uses: actions/checkout@v3
123125
with:
@@ -143,7 +145,7 @@ jobs:
143145
grep "build-wrapper-dir=install-directory/build-wrapper-win-x86" output
144146
grep "build-wrapper-bin=install-directory/build-wrapper-win-x86/build-wrapper-win-x86-64.exe" output
145147
146-
- name: Linux
148+
- name: Linux_X64
147149
shell: bash
148150
env:
149151
OS: 'Linux'
@@ -163,6 +165,26 @@ jobs:
163165
grep "build-wrapper-dir=install-directory/build-wrapper-linux-x86" output
164166
grep "build-wrapper-bin=install-directory/build-wrapper-linux-x86/build-wrapper-linux-x86-64" output
165167
168+
- name: Linux_ARM64
169+
shell: bash
170+
env:
171+
OS: 'Linux'
172+
ARCH: 'ARM64'
173+
run: |
174+
./scripts/configure_paths.sh > output
175+
grep -v "::error::" output
176+
177+
echo "- Check sonar-scanner:"
178+
grep "sonar-scanner-url=https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-vX.Y.Z.MMMM.zip" output
179+
grep "sonar-scanner-sha=DOWNLOAD-SHA" output
180+
grep "sonar-scanner-dir=install-directory/sonar-scanner-vX.Y.Z.MMMM" output
181+
grep "sonar-scanner-bin=install-directory/sonar-scanner-vX.Y.Z.MMMM/bin/sonar-scanner" output
182+
183+
echo "- Check build-wrapper:"
184+
grep "build-wrapper-url=http://sonar-host.com/static/cpp/build-wrapper-linux-aarch64.zip" output
185+
grep "build-wrapper-dir=install-directory/build-wrapper-linux-aarch64" output
186+
grep "build-wrapper-bin=install-directory/build-wrapper-linux-aarch64/build-wrapper-linux-aarch64" output
187+
166188
- name: macOSX_X64
167189
shell: bash
168190
env:

action.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ runs:
3030
shell: bash
3131
run: brew install coreutils
3232

33+
# installing jre is required because the non self-contained sonar-scanner-cli is used on Linux ARM64
34+
- name: Install JRE for linux arm64
35+
uses: actions/setup-java@v4
36+
if: runner.os == 'Linux' && runner.arch == 'ARM64'
37+
with:
38+
distribution: 'temurin'
39+
java-version: '17'
40+
3341
- name: Verify and create installation path
3442
shell: bash
3543
env:
@@ -56,6 +64,8 @@ runs:
5664
SONAR_SCANNER_SHA_LINUX: ${{ steps.sonar-scanner-version.outputs.sonar-scanner-sha-linux }}
5765
SONAR_SCANNER_URL_MACOSX: ${{ steps.sonar-scanner-version.outputs.sonar-scanner-url-macosx }}
5866
SONAR_SCANNER_SHA_MACOSX: ${{ steps.sonar-scanner-version.outputs.sonar-scanner-sha-macosx }}
67+
SONAR_SCANNER_URL_UNIVERSAL: ${{ steps.sonar-scanner-version.outputs.sonar-scanner-url-universal }}
68+
SONAR_SCANNER_SHA_UNIVERSAL: ${{ steps.sonar-scanner-version.outputs.sonar-scanner-sha-universal }}
5969
run: ${GITHUB_ACTION_PATH}/scripts/configure_paths.sh >> $GITHUB_OUTPUT
6070

6171
- name: Cache sonar-scanner installation

scripts/configure_paths.sh

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,40 @@
11
#!/bin/bash
22

3-
if [[ ${ARCH} != "X64" && ! ( ${OS} == "macOS" && ${ARCH} == "ARM64" ) ]]; then
3+
if [[ ${ARCH} != "X64" && ! (${ARCH} == "ARM64" && (${OS} == "macOS" || ${OS} == "Linux")) ]]; then
44
echo "::error::Architecture '${ARCH}' is unsupported by build-wrapper"
55
exit 1
66
fi
77

88
case ${OS} in
99
Windows)
10-
SONAR_SCANNER_SUFFIX="windows"
10+
SONAR_SCANNER_SUFFIX="-windows"
1111
BUILD_WRAPPER_SUFFIX="win-x86"
1212
SONAR_SCANNER_NAME="sonar-scanner.bat"
1313
BUILD_WRAPPER_NAME="build-wrapper-win-x86-64.exe"
1414
SONAR_SCANNER_URL="${SONAR_SCANNER_URL_WINDOWS}"
1515
SONAR_SCANNER_SHA="${SONAR_SCANNER_SHA_WINDOWS}"
1616
;;
1717
Linux)
18-
SONAR_SCANNER_SUFFIX="linux"
19-
BUILD_WRAPPER_SUFFIX="linux-x86"
18+
case ${ARCH} in
19+
X64)
20+
SONAR_SCANNER_SUFFIX="-linux"
21+
BUILD_WRAPPER_SUFFIX="linux-x86"
22+
BUILD_WRAPPER_NAME="build-wrapper-linux-x86-64"
23+
SONAR_SCANNER_URL="${SONAR_SCANNER_URL_LINUX}"
24+
SONAR_SCANNER_SHA="${SONAR_SCANNER_SHA_LINUX}"
25+
;;
26+
ARM64)
27+
SONAR_SCANNER_SUFFIX=""
28+
BUILD_WRAPPER_SUFFIX="linux-aarch64"
29+
BUILD_WRAPPER_NAME="build-wrapper-linux-aarch64"
30+
SONAR_SCANNER_URL="${SONAR_SCANNER_URL_UNIVERSAL}"
31+
SONAR_SCANNER_SHA="${SONAR_SCANNER_SHA_UNIVERSAL}"
32+
;;
33+
esac
2034
SONAR_SCANNER_NAME="sonar-scanner"
21-
BUILD_WRAPPER_NAME="build-wrapper-linux-x86-64"
22-
SONAR_SCANNER_URL="${SONAR_SCANNER_URL_LINUX}"
23-
SONAR_SCANNER_SHA="${SONAR_SCANNER_SHA_LINUX}"
2435
;;
2536
macOS)
26-
SONAR_SCANNER_SUFFIX="macosx"
37+
SONAR_SCANNER_SUFFIX="-macosx"
2738
BUILD_WRAPPER_SUFFIX="macosx-x86"
2839
SONAR_SCANNER_NAME="sonar-scanner"
2940
BUILD_WRAPPER_NAME="build-wrapper-macosx-x86"
@@ -40,7 +51,7 @@ esac
4051
echo "sonar-scanner-url=${SONAR_SCANNER_URL}"
4152
echo "sonar-scanner-sha=${SONAR_SCANNER_SHA}"
4253

43-
SONAR_SCANNER_DIR="${INSTALL_PATH}/sonar-scanner-${SONAR_SCANNER_VERSION}-${SONAR_SCANNER_SUFFIX}"
54+
SONAR_SCANNER_DIR="${INSTALL_PATH}/sonar-scanner-${SONAR_SCANNER_VERSION}${SONAR_SCANNER_SUFFIX}"
4455
echo "sonar-scanner-dir=${SONAR_SCANNER_DIR}"
4556
echo "sonar-scanner-bin=${SONAR_SCANNER_DIR}/bin/${SONAR_SCANNER_NAME}"
4657

scripts/fetch_latest_version.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ check_status "Failed to fetch latest sonar-scanner version from GitHub API"
88

99
echo "sonar-scanner-version=${SONAR_SCANNER_VERSION}"
1010

11-
for OS in windows linux macosx; do
12-
SONAR_SCANNER_URL="https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_VERSION}-${OS}.zip"
11+
for OS in windows linux macosx universal; do
12+
if [[ ${OS} == "universal" ]]; then
13+
SONAR_SCANNER_URL="https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_VERSION}.zip"
14+
else
15+
SONAR_SCANNER_URL="https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_VERSION}-${OS}.zip"
16+
fi
1317
SONAR_SCANNER_SHA=$(curl -sSL "${SONAR_SCANNER_URL}.sha256")
1418
check_status "Failed to download ${OS} sonar-scanner checksum from '${SONAR_SCANNER_URL}'"
1519

sonar-scanner-version

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ sonar-scanner-url-linux=https://binaries.sonarsource.com/Distribution/sonar-scan
55
sonar-scanner-sha-linux=f4c08ec679eeae34a7a1a5df87ee546c287f4683d1dd86afa0aae50e808e0002
66
sonar-scanner-url-macosx=https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.0.0.4432-macosx.zip
77
sonar-scanner-sha-macosx=1a492fe70cbb5587ee90344c03a3d18f259dfc9d00a9e1bef946277e89148987
8+
sonar-scanner-url-universal=https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.0.0.4432.zip
9+
sonar-scanner-sha-universal=965a18c438a213aa2167b51c793116987bc2a9df9ad245c8e02d3ab3e54022e7

0 commit comments

Comments
 (0)