mirror of
https://github.com/SonarSource/sonarqube-scan-action.git
synced 2025-12-15 18:46:31 +00:00
INF-2546 Node.js upgrade; add yarn/jest (#1)
* EN-17254 - added "TODO" comment to "Dockerfile". * EN-17254 - updated dockerfile: added code that install yarn package manager. * EN-17254 - added "yarn test ..." command before sonar scanner execution to "entrypoint.sh" in order to generate coverage report. * INF-2546 Add step to upgrade Node.js to latest LTS release * INF-2546 Add step to upgrade Node.js to latest LTS release * INF-2546 Add step to upgrade nodejs; add step to execute yarn; bug fix for converting line endings to linux style * INF-2546 Remove debug command * INF-2546 Bug fix for https://github.com/nodejs/node/issues/41058 * INF-2546 Bug fix for https://github.com/nodejs/node/issues/41058 * INF-2546 Bug fix for https://github.com/nodejs/node/issues/41058 * INF-2546 Fix conditional for running yarn * INF-2546 Bug fix for https://github.com/nodejs/node/issues/41058 * INF-2546 Bug fix for https://github.com/nodejs/node/issues/41058 * INF-2546 Bug fix for https://github.com/nodejs/node/issues/41058 * INF-2546 Bug fix for https://github.com/nodejs/node/issues/41058 * INF-2546 Bug fix for https://github.com/nodejs/node/issues/41058 * INF-2546 Bug fix for https://github.com/nodejs/node/issues/41058 * INF-2546 Add jest dependency * INF-2546 Add jest dependency * INF-2546 Reorganized commands * INF-2546 Bug fix * INF-2546 Bug fix * INF-2546 Add jest dependency * INF-2546 Move all yarn/jest-related functions to entrypoint.sh to improve image build time * INF-2546 Add jest-sonar-reporter dependency * INF-2546 Move yarn back to Dockerfile; rename RUN_YARN to RUN_JEST Co-authored-by: Dmitry Moiseenko <dmoiseenko@ingenio.com> Co-authored-by: Brett Anspach <banspach@ingenio.com>
This commit is contained in:
parent
e41a03056e
commit
f4f56f1d9c
2 changed files with 39 additions and 12 deletions
45
Dockerfile
45
Dockerfile
|
|
@ -1,3 +1,7 @@
|
|||
# HACK: Fix for "Error relocating /usr/bin/node: _ZSt28__throw_bad_array_new_lengthv: symbol not found" - https://github.com/nodejs/node/issues/41058#issuecomment-997348999
|
||||
FROM alpine:3.16 as libstdc-donor
|
||||
RUN apk add --update --no-cache --repository https://dl-cdn.alpinelinux.org/alpine/edge/main libstdc++
|
||||
|
||||
FROM sonarsource/sonar-scanner-cli:4.7
|
||||
|
||||
LABEL version="1.1.0" \
|
||||
|
|
@ -9,27 +13,35 @@ LABEL version="1.1.0" \
|
|||
com.github.actions.icon="check" \
|
||||
com.github.actions.color="green"
|
||||
|
||||
# Add Ingenio certificate to java keystore
|
||||
COPY wildcard_corp_ingenio_com.pem .
|
||||
RUN keytool -keystore /etc/ssl/certs/java/cacerts -storepass changeit -noprompt -trustcacerts -importcert -alias sonarqube -file wildcard_corp_ingenio_com.pem
|
||||
|
||||
# Update repository sources
|
||||
RUN apk update
|
||||
|
||||
# Install Python 3
|
||||
RUN apk add --no-cache \
|
||||
RUN apk add --update --no-cache \
|
||||
build-base \
|
||||
python3 \
|
||||
py3-pip
|
||||
|
||||
RUN python3 -m pip install --upgrade pip
|
||||
|
||||
# Install Ansible linter
|
||||
# TODO: Install Ansible linter
|
||||
#RUN pip3 install ansible-lint
|
||||
|
||||
# Upgrade Node.js
|
||||
RUN apk add --update --no-cache --repository https://dl-cdn.alpinelinux.org/alpine/edge/main \
|
||||
nodejs \
|
||||
npm
|
||||
RUN apk upgrade --no-cache --repository https://dl-cdn.alpinelinux.org/alpine/edge/main \
|
||||
nodejs \
|
||||
npm
|
||||
|
||||
# HACK: Fix for "Error relocating /usr/bin/node: _ZSt28__throw_bad_array_new_lengthv: symbol not found" - https://github.com/nodejs/node/issues/41058#issuecomment-997348999
|
||||
COPY --from=libstdc-donor /usr/lib/libstdc++.so.6.0.29 /usr/lib/libstdc++.so.6.0.29
|
||||
RUN rm /usr/lib/libstdc++.so.6 && ln -s /usr/lib/libstdc++.so.6.0.29 /usr/lib/libstdc++.so.6
|
||||
|
||||
# Install yarn
|
||||
RUN apk add --update --no-cache \
|
||||
yarn
|
||||
|
||||
# Install PowerShell
|
||||
# https://docs.microsoft.com/en-us/powershell/scripting/install/install-alpine?view=powershell-7.2#installation-steps
|
||||
RUN apk add --no-cache \
|
||||
RUN apk add --update --no-cache \
|
||||
ca-certificates \
|
||||
less \
|
||||
ncurses-terminfo-base \
|
||||
|
|
@ -44,7 +56,7 @@ RUN apk add --no-cache \
|
|||
icu-libs \
|
||||
curl
|
||||
|
||||
RUN apk -X https://dl-cdn.alpinelinux.org/alpine/edge/main add --no-cache \
|
||||
RUN apk add --update --no-cache --repository https://dl-cdn.alpinelinux.org/alpine/edge/main \
|
||||
lttng-ust
|
||||
|
||||
RUN wget -O powershell.tar.gz https://github.com/PowerShell/PowerShell/releases/download/v7.2.3/powershell-7.2.3-linux-alpine-x64.tar.gz; \
|
||||
|
|
@ -57,6 +69,15 @@ RUN wget -O powershell.tar.gz https://github.com/PowerShell/PowerShell/releases/
|
|||
SHELL ["pwsh", "-Command"]
|
||||
RUN Set-PSRepository PSGallery -InstallationPolicy Trusted -Verbose; Install-Module PSScriptAnalyzer -Repository PSGallery -Scope AllUsers -Verbose
|
||||
|
||||
# Add Ingenio certificate to java keystore
|
||||
COPY wildcard_corp_ingenio_com.pem .
|
||||
RUN keytool -keystore /etc/ssl/certs/java/cacerts -storepass changeit -noprompt -trustcacerts -importcert -alias sonarqube -file wildcard_corp_ingenio_com.pem
|
||||
|
||||
# Fix line endings for entrypoint.sh
|
||||
RUN apk add --no-cache \
|
||||
dos2unix
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN dos2unix /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
|
|
|||
|
|
@ -25,6 +25,12 @@ fi
|
|||
|
||||
unset JAVA_HOME
|
||||
|
||||
if [[ "${RUN_JEST}" == "true" ]]; then
|
||||
npm install -g jest-cli jest-sonar-reporter
|
||||
yarn add jest jest-environment-jsdom
|
||||
yarn test --coverage --coverageDirectory='coverage'
|
||||
fi
|
||||
|
||||
sonar-scanner -Dsonar.projectBaseDir=${INPUT_PROJECTBASEDIR} ${INPUT_ARGS}
|
||||
|
||||
_tmp_file=$(ls "${INPUT_PROJECTBASEDIR}/" | head -1)
|
||||
|
|
|
|||
Loading…
Reference in a new issue