Skip to content

リポジトリをブランディングする #1117

リポジトリをブランディングする

リポジトリをブランディングする #1117

Workflow file for this run

name: SonarCloud
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
workflow_dispatch:
push:
paths-ignore:
- '**/*.md'
- .gitignore
- .editorconfig
pull_request_target:
types: [opened, synchronize]
paths-ignore:
- '**/*.md'
- .gitignore
- .editorconfig
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
sonar:
name: Scan
runs-on: windows-latest
env:
BUILD_PLATFORM: x64
BUILD_CONFIGURATION: Debug
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: '${{ github.event.pull_request.head.sha }}'
- name: Setup environment variables
run: |
echo "SONAR_USER_HOME=${{ github.workspace }}" >> $env:GITHUB_ENV
if ('${{ env.GITHUB_BASE_REF }}' -ne '')
{
echo "BASE_SHA=$(git show -s --format=%H ${{ env.GITHUB_BASE_REF }})" >> $env:GITHUB_ENV
}
echo "NUM_VSVERSION=$($(vswhere -latest -property catalog_productDisplayVersion) -replace '^(\d+)\..+$', '$1')" >> $env:GITHUB_ENV
echo "SCANNER_CLI_VERSION=$(Get-Content tools\SCANNER_CLI_VERSION)" >> $env:GITHUB_ENV
New-Item -Path .sonar -ItemType Directory
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1
- name: Setup Python3
uses: actions/setup-python@v4
with:
python-version: '3.x'
cache: 'pip' # caching pip dependencies
- run: pip install -r requirements.txt
- name: Install OpenCppCoverage with XmlExporter
working-directory: ${{ runner.temp }}
run: |
choco install OpenCppCoverage -y
Invoke-WebRequest -OutFile XmlExporter-x64.zip https://github.com/berryzplus/XmlExporter/releases/download/v1.0.0/XmlExporter-x64.zip
7z e XmlExporter-x64.zip
Move-Item -Path XmlExporter.dll -Destination "C:\Program Files\OpenCppCoverage\Plugins\Exporter\xml.dll"
echo "C:\Program Files\OpenCppCoverage" >> $env:GITHUB_PATH
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
- name: Cache Sonar Analysis
uses: actions/cache@v3
with:
path: |
.sonar\cache
key:
sonar-cache-${{ env.SCANNER_CLI_VERSION }}-${{ github.sha }}
restore-keys:
sonar-cache-${{ env.SCANNER_CLI_VERSION }}-${{ env.BASE_SHA }}
- name: Make BuildDependencies
working-directory: ${{ github.workspace }}
run: .\tools\BuildDependencies.bat
- name: Build with Build-Wrapper
run: .\tools\Build-SakuraEditorWithBuildWrapper.ps1
- name: Run Tests
run: .\tools\Run-Tests.ps1
- name: Fetch SonarScanner
run: .\tools\Fetch-SonarScanner.ps1
- name: Analyze with SonarScanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
if: env.SONAR_TOKEN
run: |
if ('${{ github.event_name }}' -eq 'pull_request_target')
{
$env:GITHUB_EVENT_NAME = 'pull_request'
$env:GITHUB_SHA = $(git show -s --format=%H)
$env:GITHUB_REF = 'refs/pull/${{ github.event.number }}/merge'
}
$GitHubRepository = "${{ github.repository }}"
$GitHubOrganization = $($GitHubRepository.Split('/')[0])
$GitHubProjectName = $($GitHubRepository.Split('/')[1])
echo "sonar.organization=$GitHubOrganization" >> ${{ github.workspace }}\.sonar\scanner\conf\sonar-scanner.properties
echo "sonar.projectKey=$GitHubProjectName" >> ${{ github.workspace }}\.sonar\scanner\conf\sonar-scanner.properties
echo "sonar.host.url=https://sonarcloud.io" >> ${{ github.workspace }}\.sonar\scanner\conf\sonar-scanner.properties
.\.sonar\scanner\bin\sonar-scanner.bat