Skip to content

Commit

Permalink
SCCPPGHA-6 Support Running on Linux ARM64 (#57)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Jabbour <[email protected]>
  • Loading branch information
1 parent 905f4e3 commit e25edae
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 12 deletions.
24 changes: 23 additions & 1 deletion .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
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"
case ${ARCH} in
X64)
SONAR_SCANNER_SUFFIX="-linux"
BUILD_WRAPPER_SUFFIX="linux-x86"
BUILD_WRAPPER_NAME="build-wrapper-linux-x86-64"
SONAR_SCANNER_URL="${SONAR_SCANNER_URL_LINUX}"
SONAR_SCANNER_SHA="${SONAR_SCANNER_SHA_LINUX}"
;;
ARM64)
SONAR_SCANNER_SUFFIX=""
BUILD_WRAPPER_SUFFIX="linux-aarch64"
BUILD_WRAPPER_NAME="build-wrapper-linux-aarch64"
SONAR_SCANNER_URL="${SONAR_SCANNER_URL_UNIVERSAL}"
SONAR_SCANNER_SHA="${SONAR_SCANNER_SHA_UNIVERSAL}"
;;
esac
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}"
;;
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
2 changes: 2 additions & 0 deletions sonar-scanner-version
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ sonar-scanner-url-linux=https://binaries.sonarsource.com/Distribution/sonar-scan
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 e25edae

Please sign in to comment.