From 02cae0ceb02bad20ba4ee58fbcb6c5d9bf019cd4 Mon Sep 17 00:00:00 2001 From: Marco Antognini <89914223+marco-antognini-sonarsource@users.noreply.github.com> Date: Tue, 8 Mar 2022 11:31:27 +0100 Subject: [PATCH] Fix SonarQube warning about missing reference for analysis (#796) --- .cirrus.yml | 4 ++++ ci/fetch_branches.sh | 7 +++++++ 2 files changed, 11 insertions(+) create mode 100644 ci/fetch_branches.sh diff --git a/.cirrus.yml b/.cirrus.yml index 87a90b66a0..91fb9a7729 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -11,6 +11,8 @@ env: CIRRUS_CLONE_DEPTH: 0 # Use bash (instead of sh on linux or cmd.exe on windows) CIRRUS_SHELL: bash + BASE_BRANCH: ${CIRRUS_BASE_BRANCH} + DEFAULT_BRANCH: ${CIRRUS_DEFAULT_BRANCH} container_definition: &CONTAINER_DEFINITION @@ -40,6 +42,7 @@ tooling_tests_task: - pipenv install - pipenv run pip install pytest pytest-cov tests_script: + - bash ci/fetch_branches.sh - cd rspec-tools - pipenv run pytest --cov=rspec_tools --cov-report=xml <<: *SETUP_SONAR_SCANNER @@ -65,6 +68,7 @@ frontend_tests_task: - cd frontend - npm install tests_script: + - bash ci/fetch_branches.sh - cd frontend - npm run build - npm test -- --detectOpenHandles --coverage . diff --git a/ci/fetch_branches.sh b/ci/fetch_branches.sh new file mode 100644 index 0000000000..69146d0908 --- /dev/null +++ b/ci/fetch_branches.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -euo pipefail + +# When neither BASE_BRANCH nor DEFAULT_BRANCH are defined, fall back to "master". +BRANCH="${BASE_BRANCH:-${DEFAULT_BRANCH:-master}}" +git fetch --force origin "refs/heads/${BRANCH}:refs/remotes/origin/${BRANCH}"