Skip to content

Commit

Permalink
SQSCANGHA-40 Restore permission fix for files in the project basedir
Browse files Browse the repository at this point in the history
  • Loading branch information
henryju authored and csaba-feher-sonarsource committed Jul 2, 2024
1 parent 540792c commit aecaf43
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 5 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,40 @@ jobs:
- name: Assert
run: |
./test/assertFileContains ./output.properties "sonar.verbose=true"
runAnalysisWithCacheTest:
runs-on: ubuntu-latest
services:
sonarqube:
image: sonarqube:lts-community
ports:
- 9000:9000
volumes:
- sonarqube_data:/opt/sonarqube/data
- sonarqube_logs:/opt/sonarqube/logs
- sonarqube_extensions:/opt/sonarqube/extensions
options: >-
--health-cmd "grep -Fq \"SonarQube is operational\" /opt/sonarqube/logs/sonar.log"
--health-interval 10s
--health-timeout 5s
--health-retries 10
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: SonarQube Cache
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.sonar/cache
key: ${{ runner.os }}-sonar
- name: Run action on sample project
id: runTest
uses: ./
env:
SONAR_HOST_URL: http://sonarqube:9000
SONAR_USER_HOME: ${{ github.workspace }}/.sonar
with:
args: -Dsonar.login=admin -Dsonar.password=admin
projectBaseDir: ./test/example-project
- name: Assert
run: |
./test/assertFileExists ./test/example-project/.scannerwork/report-task.txt
10 changes: 5 additions & 5 deletions cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

set -e

if [ ! -d "${INPUT_PROJECTBASEDIR%/}/.scannerwork" ]; then
echo ".scannerwork directory not found; nothing to clean up."
exit
fi
# Reset all files permissions to the default Runner user and group to allow the follow up steps (mainly cache) to access all files.

# Assume that the first (non-hidden) file in the project directory is one from the project, and not one written by the scanner
_tmp_file=$(ls "${INPUT_PROJECTBASEDIR%/}/" | head -1)
echo "Reading permissions from $_tmp_file"
PERM=$(stat -c "%u:%g" "${INPUT_PROJECTBASEDIR%/}/$_tmp_file")

chown -R $PERM "${INPUT_PROJECTBASEDIR%/}/.scannerwork/"
echo "Applying permissions $PERM to all files in the project base directory"
chown -R $PERM "${INPUT_PROJECTBASEDIR%/}/"

0 comments on commit aecaf43

Please sign in to comment.