Skip to content

Commit

Permalink
SCCPPGHA-6 Support Running on Linux ARM64
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Jabbour <[email protected]>
  • Loading branch information
friedbyalice and michael-jabbour-sonarsource committed Jun 20, 2024
1 parent 5c3c391 commit 8faa7c8
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 21 deletions.
28 changes: 25 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ jobs:
SONAR_SCANNER_SHA_LINUX: 'DOWNLOAD-SHA-LINUX'
SONAR_SCANNER_URL_MACOSX: 'https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-vX.Y.Z.MMMM-macosx.zip'
SONAR_SCANNER_SHA_MACOSX: 'DOWNLOAD-SHA-MACOSX'
SONAR_SCANNER_URL_UNIVERSAL: 'https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-vX.Y.Z.MMMM.zip'
SONAR_SCANNER_SHA_UNIVERSAL: 'DOWNLOAD-SHA'
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -143,7 +145,7 @@ jobs:
grep "build-wrapper-dir=install-directory/build-wrapper-win-x86" output
grep "build-wrapper-bin=install-directory/build-wrapper-win-x86/build-wrapper-win-x86-64.exe" output
- name: Linux
- name: Linux_X64
shell: bash
env:
OS: 'Linux'
Expand All @@ -163,6 +165,26 @@ jobs:
grep "build-wrapper-dir=install-directory/build-wrapper-linux-x86" output
grep "build-wrapper-bin=install-directory/build-wrapper-linux-x86/build-wrapper-linux-x86-64" output
- name: Linux_ARM64
shell: bash
env:
OS: 'Linux'
ARCH: 'ARM64'
run: |
./scripts/configure_paths.sh > output
grep -v "::error::" output
echo "- Check sonar-scanner:"
grep "sonar-scanner-url=https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-vX.Y.Z.MMMM.zip" output
grep "sonar-scanner-sha=DOWNLOAD-SHA" output
grep "sonar-scanner-dir=install-directory/sonar-scanner-vX.Y.Z.MMMM" output
grep "sonar-scanner-bin=install-directory/sonar-scanner-vX.Y.Z.MMMM/bin/sonar-scanner" output
echo "- Check build-wrapper:"
grep "build-wrapper-url=http://sonar-host.com/static/cpp/build-wrapper-linux-aarch64.zip" output
grep "build-wrapper-dir=install-directory/build-wrapper-linux-aarch64" output
grep "build-wrapper-bin=install-directory/build-wrapper-linux-aarch64/build-wrapper-linux-aarch64" output
- name: macOSX_X64
shell: bash
env:
Expand Down Expand Up @@ -352,14 +374,14 @@ jobs:
- name: sonar-scanner is installed and in PATH
run: |
sonar-scanner --help | grep "INFO: usage: sonar-scanner "
sonar-scanner --help | grep "usage: sonar-scanner "
- name: sonar-scanner-binary output is correct
shell: bash
env:
BINARY: ${{ steps.run-action.outputs.sonar-scanner-binary }}
run: |
"$BINARY" --help | grep "INFO: usage: sonar-scanner "
"$BINARY" --help | grep "usage: sonar-scanner "
# build-wrapper does not have --help or equivalent option.
# Pass to few arguments and ignore error code
Expand Down
10 changes: 10 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ runs:
shell: bash
run: brew install coreutils

# installing jre is required because the non self-contained sonar-scanner-cli is used on Linux ARM64
- name: Install JRE for linux arm64
uses: actions/setup-java@v4
if: runner.os == 'Linux' && runner.arch == 'ARM64'
with:
distribution: 'temurin'
java-version: '17'

- name: Verify and create installation path
shell: bash
env:
Expand All @@ -56,6 +64,8 @@ runs:
SONAR_SCANNER_SHA_LINUX: ${{ steps.sonar-scanner-version.outputs.sonar-scanner-sha-linux }}
SONAR_SCANNER_URL_MACOSX: ${{ steps.sonar-scanner-version.outputs.sonar-scanner-url-macosx }}
SONAR_SCANNER_SHA_MACOSX: ${{ steps.sonar-scanner-version.outputs.sonar-scanner-sha-macosx }}
SONAR_SCANNER_URL_UNIVERSAL: ${{ steps.sonar-scanner-version.outputs.sonar-scanner-url-universal }}
SONAR_SCANNER_SHA_UNIVERSAL: ${{ steps.sonar-scanner-version.outputs.sonar-scanner-sha-universal }}
run: ${GITHUB_ACTION_PATH}/scripts/configure_paths.sh >> $GITHUB_OUTPUT

- name: Cache sonar-scanner installation
Expand Down
29 changes: 20 additions & 9 deletions scripts/configure_paths.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,40 @@
#!/bin/bash

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

case ${OS} in
Windows)
SONAR_SCANNER_SUFFIX="windows"
SONAR_SCANNER_SUFFIX="-windows"
BUILD_WRAPPER_SUFFIX="win-x86"
SONAR_SCANNER_NAME="sonar-scanner.bat"
BUILD_WRAPPER_NAME="build-wrapper-win-x86-64.exe"
SONAR_SCANNER_URL="${SONAR_SCANNER_URL_WINDOWS}"
SONAR_SCANNER_SHA="${SONAR_SCANNER_SHA_WINDOWS}"
;;
Linux)
SONAR_SCANNER_SUFFIX="linux"
BUILD_WRAPPER_SUFFIX="linux-x86"
SONAR_SCANNER_NAME="sonar-scanner"
BUILD_WRAPPER_NAME="build-wrapper-linux-x86-64"
SONAR_SCANNER_URL="${SONAR_SCANNER_URL_LINUX}"
SONAR_SCANNER_SHA="${SONAR_SCANNER_SHA_LINUX}"
case ${ARCH} in
X64)
SONAR_SCANNER_SUFFIX="-linux"
SONAR_SCANNER_URL="${SONAR_SCANNER_URL_LINUX}"
SONAR_SCANNER_SHA="${SONAR_SCANNER_SHA_LINUX}"
BUILD_WRAPPER_SUFFIX="linux-x86"
BUILD_WRAPPER_NAME="build-wrapper-linux-x86-64"
;;
ARM64)
SONAR_SCANNER_SUFFIX=""
SONAR_SCANNER_URL="${SONAR_SCANNER_URL_UNIVERSAL}"
SONAR_SCANNER_SHA="${SONAR_SCANNER_SHA_UNIVERSAL}"
BUILD_WRAPPER_SUFFIX="linux-aarch64"
BUILD_WRAPPER_NAME="build-wrapper-linux-aarch64"
;;
esac
;;
macOS)
SONAR_SCANNER_SUFFIX="macosx"
SONAR_SCANNER_SUFFIX="-macosx"
BUILD_WRAPPER_SUFFIX="macosx-x86"
SONAR_SCANNER_NAME="sonar-scanner"
BUILD_WRAPPER_NAME="build-wrapper-macosx-x86"
Expand All @@ -40,7 +51,7 @@ esac
echo "sonar-scanner-url=${SONAR_SCANNER_URL}"
echo "sonar-scanner-sha=${SONAR_SCANNER_SHA}"

SONAR_SCANNER_DIR="${INSTALL_PATH}/sonar-scanner-${SONAR_SCANNER_VERSION}-${SONAR_SCANNER_SUFFIX}"
SONAR_SCANNER_DIR="${INSTALL_PATH}/sonar-scanner-${SONAR_SCANNER_VERSION}${SONAR_SCANNER_SUFFIX}"
echo "sonar-scanner-dir=${SONAR_SCANNER_DIR}"
echo "sonar-scanner-bin=${SONAR_SCANNER_DIR}/bin/${SONAR_SCANNER_NAME}"

Expand Down
8 changes: 6 additions & 2 deletions scripts/fetch_latest_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ check_status "Failed to fetch latest sonar-scanner version from GitHub API"

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

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

Expand Down
16 changes: 9 additions & 7 deletions sonar-scanner-version
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
sonar-scanner-version=5.0.1.3006
sonar-scanner-url-windows=https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-windows.zip
sonar-scanner-sha-windows=bf8b7b30bd5614aaf244fe5aed3e9f7246b080b8ae3534693533fe3aac9c5594
sonar-scanner-url-linux=https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-linux.zip
sonar-scanner-sha-linux=350dbdb517c10fcb3ce70425db95c415b313cad7296c407d416d88f3d50121f8
sonar-scanner-url-macosx=https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-macosx.zip
sonar-scanner-sha-macosx=ba129044005494f039b41afaad2d949881604e69c6ebe814f4e218c7904a9d2d
sonar-scanner-version=6.0.0.4432
sonar-scanner-url-windows=https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.0.0.4432-windows.zip
sonar-scanner-sha-windows=4773dbafd2ce335c0ccaefd3606742bf59658987b5e3c6aa99e51d7ef57a8f33
sonar-scanner-url-linux=https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.0.0.4432-linux.zip
sonar-scanner-sha-linux=f4c08ec679eeae34a7a1a5df87ee546c287f4683d1dd86afa0aae50e808e0002
sonar-scanner-url-macosx=https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.0.0.4432-macosx.zip
sonar-scanner-sha-macosx=1a492fe70cbb5587ee90344c03a3d18f259dfc9d00a9e1bef946277e89148987
sonar-scanner-url-universal=https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.0.0.4432.zip
sonar-scanner-sha-universal=965a18c438a213aa2167b51c793116987bc2a9df9ad245c8e02d3ab3e54022e7

0 comments on commit 8faa7c8

Please sign in to comment.