Skip to content

Bump actions/upload-artifact from 6 to 7 #2204

Bump actions/upload-artifact from 6 to 7

Bump actions/upload-artifact from 6 to 7 #2204

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
schedule:
- cron: '45 7 * * FRI'
# 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@v6
with:
ref: '${{ github.event.pull_request.head.sha }}'
fetch-depth: 0
submodules: true
- name: Setup environment variables
id: setup-base-env
run: |
$projectKey = $('${{ github.repository }}' -replace '/', '_')
echo "project-key=$projectKey" >> $env:GITHUB_OUTPUT
echo "branch-name=-Dsonar.branch.name=${{ github.ref_name }}" >> $env:GITHUB_OUTPUT
echo "output-directory=${{ github.workspace }}\${{ env.BUILD_PLATFORM }}\${{ env.BUILD_CONFIGURATION }}" >> $env:GITHUB_OUTPUT
- name: Setup PR environment variables
id: setup-pr-env
env:
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
run: |
echo "project-key=${{ steps.setup-base-env.outputs.project-key }}" >> $env:GITHUB_OUTPUT
echo "pull-request-key=-Dsonar.pullrequest.key=${{ github.event.pull_request.number }}" >> $env:GITHUB_OUTPUT
echo "branch-name=-Dsonar.pullrequest.branch=$env:PR_HEAD_REF" >> $env:GITHUB_OUTPUT
echo "branch-base=-Dsonar.pullrequest.base=$env:PR_BASE_REF" >> $env:GITHUB_OUTPUT
echo "output-directory=${{ steps.setup-base-env.outputs.output-directory }}" >> $env:GITHUB_OUTPUT
shell: pwsh
- name: Merge environment variables
id: setup-env
run: |
if ('${{ github.event_name }}' -eq 'pull_request' -or '${{ github.event_name }}' -eq 'pull_request_target') {
echo "project-key=${{ steps.setup-pr-env.outputs.project-key }}" >> $env:GITHUB_OUTPUT
echo "pull-request-key=${{ steps.setup-pr-env.outputs.pull-request-key }}" >> $env:GITHUB_OUTPUT
echo "branch-name=${{ steps.setup-pr-env.outputs.branch-name }}" >> $env:GITHUB_OUTPUT
echo "branch-base=${{ steps.setup-pr-env.outputs.branch-base }}" >> $env:GITHUB_OUTPUT
echo "output-directory=${{ steps.setup-pr-env.outputs.output-directory }}" >> $env:GITHUB_OUTPUT
} else {
echo "project-key=${{ steps.setup-base-env.outputs.project-key }}" >> $env:GITHUB_OUTPUT
echo "branch-name=${{ steps.setup-base-env.outputs.branch-name }}" >> $env:GITHUB_OUTPUT
echo "output-directory=${{ steps.setup-base-env.outputs.output-directory }}" >> $env:GITHUB_OUTPUT
}
shell: pwsh
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
- name: Install AutoHotKey
run: |
$AutohotkeyDir = "$HOME\autohotkey"
if (!(Test-Path $AutohotkeyDir)) { New-Item -ItemType Directory -Path $AutohotkeyDir }
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri https://github.com/AutoHotkey/AutoHotkey/releases/download/v2.0.19/AutoHotkey_2.0.19.zip -OutFile "AutoHotkey.zip"
Expand-Archive -Path "AutoHotkey.zip" -DestinationPath $AutohotkeyDir -Force
echo "AutoHotKey=$HOME\autohotkey\AutoHotkey32.exe" >> $env:GITHUB_ENV
- name: Install Locale Emulator
run: |
$LEExpandDir = "${{ github.workspace }}\tools\LocaleEmulator"
$LEInitScript = "${{ github.workspace }}\tools\LocaleEmulator\init-locale-emulator.ahk"
Expand-Archive "${{ github.workspace }}\externals\LocaleEmulator\locale-emulator.zip" "${LEExpandDir}"
Start-Process $env:AutoHotKey "${LEInitScript}"
Start-Process "${LEExpandDir}\LEInstaller.exe"
echo "${LEExpandDir}" >> $env:GITHUB_PATH
shell: pwsh
- name: Run the normal MSBuild process
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
if: env.SONAR_TOKEN
run: build-sln.bat ${{ env.BUILD_PLATFORM }} ${{ env.BUILD_CONFIGURATION }}
shell: cmd
- name: Install Build Wrapper
uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v7.0.0
- name: Build with Build-Wrapper
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
if: env.SONAR_TOKEN
run: build-wrapper-win-x86-64.exe
--out-dir bw-output
MsBuild.exe
/p:Platform=${{ env.BUILD_PLATFORM }}
/p:Configuration=${{ env.BUILD_CONFIGURATION }}
/t:ReBuild
- name: Install OpenCppCoverage
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
if: env.SONAR_TOKEN
working-directory: ${{ runner.temp }}
run: |
$Installer = "OpenCppCoverageSetup.exe"
Invoke-WebRequest -Uri "https://github.com/OpenCppCoverage/OpenCppCoverage/releases/download/release-0.9.9.0/OpenCppCoverageSetup-x64-0.9.9.0.exe" -OutFile $Installer
Start-Process -FilePath .\$Installer -ArgumentList "/VERYSILENT", "/SUPPRESSMSGBOXES" -Wait
echo "C:\Program Files\OpenCppCoverage" >> $env:GITHUB_PATH
- name: Run Tests
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
if: env.SONAR_TOKEN
run: |
$env:CMD_TESTS1 = $(Get-ChildItem -Recurse tests1.exe)[0].FullName
OpenCppCoverage.exe `
--export_type cobertura:tests1-coverage.xml `
--modules $env:CMD_TESTS1 `
--sources ${{ github.workspace }} `
--working_dir ${{ steps.setup-env.outputs.output-directory }} `
--cover_children `
-- `
$env:CMD_TESTS1 `
--gtest_output=xml:${{ github.workspace }}\tests1-googletest.xml
- name: Upload test result
uses: EnricoMi/publish-unit-test-result-action/windows@v2
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
if: env.SONAR_TOKEN
with:
files: |
*-googletest.xml
- name: Analyze with SonarQube Scan action
uses: SonarSource/sonarqube-scan-action@v7.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
LC_ALL: ja_JP.UTF-8
if: env.SONAR_TOKEN
with:
args: >
"-Dsonar.organization=${{ github.repository_owner }}"
"-Dsonar.projectKey=${{ steps.setup-env.outputs.project-key }}"
"-Dsonar.host.url=https://sonarcloud.io"
${{ steps.setup-env.outputs.pull-request-key }}
${{ steps.setup-env.outputs.branch-name }}
${{ steps.setup-env.outputs.branch-base }}
"-Dsonar.cfamily.compile-commands=bw-output/compile_commands.json"
"-Dsonar.cfamily.cppunit.reportPath=*-googletest.xml"
"-Dsonar.cfamily.cobertura.reportPaths=tests1-coverage.xml"
"-Dsonar.verbose=true"
- name: Upload Sonar CFamily failure reproducer (if present)
if: ${{ always() && hashFiles('sonar-cfamily-reproducer.tar.xz') != '' }}
uses: actions/upload-artifact@v7
with:
name: sonar-cfamily-reproducer-${{ runner.os }}-${{ github.run_id }}
path: sonar-cfamily-reproducer.tar.xz
if-no-files-found: ignore
retention-days: 14