Azure Pipeline can't find test results files to publish - unit-testing

The task PublishTestResults#2 doesn't find my test result files. Why not?
I am running Python tests with unittest using xmlrunner to generate output files in JUnit format.
This is the relevant output of the publish task:
2020-01-25T01:12:07.7443604Z ##[debug]pattern: 'testresults/TEST-*.xml'
2020-01-25T01:12:07.7476652Z ##[debug]findPath: './acceptance-tests/OOM-exception/testresults'
2020-01-25T01:12:07.7477167Z ##[debug]statOnly: 'false'
2020-01-25T01:12:07.7478528Z ##[debug]findPath: 'acceptance-tests/OOM-exception/testresults'
2020-01-25T01:12:07.7478992Z ##[debug]findOptions.allowBrokenSymbolicLinks: 'true'
2020-01-25T01:12:07.7479362Z ##[debug]findOptions.followSpecifiedSymbolicLink: 'true'
2020-01-25T01:12:07.7479710Z ##[debug]findOptions.followSymbolicLinks: 'true'
2020-01-25T01:12:07.7482715Z ##[debug] acceptance-tests/OOM-exception/testresults (directory)
2020-01-25T01:12:07.7489267Z ##[debug] acceptance-tests/OOM-exception/testresults/TEST-test_OOM_exceptions.OOM_exceptions-20200125011206.xml (file)
2020-01-25T01:12:07.7489642Z ##[debug]2 results
2020-01-25T01:12:07.7490249Z ##[debug]found 2 paths
2020-01-25T01:12:07.7490606Z ##[debug]applying include pattern
2020-01-25T01:12:07.7491144Z ##[debug]adjustedPattern: './acceptance-tests/OOM-exception/testresults/TEST-*.xml'
2020-01-25T01:12:07.7498261Z ##[debug]0 matches
2020-01-25T01:12:07.7504039Z ##[debug]0 final results
2020-01-25T01:12:07.7504342Z ##[debug]Detected 0 test result files
This output shows that the test file actually exists in the correct location. I have tried various variations of the testResultsFiles parameter including the default **/TEST-*.xml.
By the way, the tests themselves succeed and all tests are actually run.
This is the relevant part from my YAML-pipeline:
- task: UsePythonVersion#0
inputs:
versionSpec: '3.8'
- script: python3 -m pip install --upgrade pip setuptools
- script: pip install -r requirements.txt
workingDirectory: '$(testFilesFolder)'
- script: python3 -m xmlrunner discover --output testresults
continueOnError: true
workingDirectory: '$(testFilesFolder)'
- task: PublishTestResults#2
inputs:
testResultsFormat: 'JUnit' # Options: JUnit, NUnit, VSTest, xUnit, cTest
testResultsFiles: 'testresults/TEST-*.xml'
searchFolder: '$(testFilesFolder)'
failTaskOnFailedTests: true
This is the full output of the task:
2020-01-25T01:12:07.5996494Z ##[debug]Evaluating condition for step: 'PublishTestResults'
2020-01-25T01:12:07.5996980Z ##[debug]Evaluating: SucceededNode()
2020-01-25T01:12:07.5997134Z ##[debug]Evaluating SucceededNode:
2020-01-25T01:12:07.5997333Z ##[debug]=> True
2020-01-25T01:12:07.5997489Z ##[debug]Result: True
2020-01-25T01:12:07.5997666Z ##[section]Starting: PublishTestResults
2020-01-25T01:12:07.6000996Z ==============================================================================
2020-01-25T01:12:07.6001109Z Task : Publish Test Results
2020-01-25T01:12:07.6001211Z Description : Publish test results to Azure Pipelines
2020-01-25T01:12:07.6001273Z Version : 2.162.2
2020-01-25T01:12:07.6001329Z Author : Microsoft Corporation
2020-01-25T01:12:07.6001445Z Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/test/publish-test-results
2020-01-25T01:12:07.6001514Z ==============================================================================
2020-01-25T01:12:07.7287680Z ##[debug]agent.TempDirectory=/home/vsts/work/_temp
2020-01-25T01:12:07.7311778Z ##[debug]loading inputs and endpoints
2020-01-25T01:12:07.7316458Z ##[debug]loading INPUT_TESTRUNNER
2020-01-25T01:12:07.7326771Z ##[debug]loading INPUT_TESTRESULTSFILES
2020-01-25T01:12:07.7328668Z ##[debug]loading INPUT_SEARCHFOLDER
2020-01-25T01:12:07.7329586Z ##[debug]loading INPUT_MERGETESTRESULTS
2020-01-25T01:12:07.7330846Z ##[debug]loading INPUT_FAILTASKONFAILEDTESTS
2020-01-25T01:12:07.7332115Z ##[debug]loading INPUT_PUBLISHRUNATTACHMENTS
2020-01-25T01:12:07.7332777Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2020-01-25T01:12:07.7334111Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2020-01-25T01:12:07.7334752Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2020-01-25T01:12:07.7339261Z ##[debug]loading SECRET_SYSTEM_ACCESSTOKEN
2020-01-25T01:12:07.7340893Z ##[debug]loaded 10
2020-01-25T01:12:07.7358665Z ##[debug]Agent.ProxyUrl=undefined
2020-01-25T01:12:07.7367753Z ##[debug]Agent.CAInfo=undefined
2020-01-25T01:12:07.7368399Z ##[debug]Agent.ClientCert=undefined
2020-01-25T01:12:07.7368766Z ##[debug]Agent.SkipCertValidation=undefined
2020-01-25T01:12:07.7398326Z ##[debug]check path : /home/vsts/work/_tasks/PublishTestResults_0b0f01ed-7dde-43ff-9cbb-e48954daf9b1/2.162.2/task.json
2020-01-25T01:12:07.7398974Z ##[debug]adding resource file: /home/vsts/work/_tasks/PublishTestResults_0b0f01ed-7dde-43ff-9cbb-e48954daf9b1/2.162.2/task.json
2020-01-25T01:12:07.7399510Z ##[debug]system.culture=en-US
2020-01-25T01:12:07.7415772Z ##[debug]testRunner=JUnit
2020-01-25T01:12:07.7421062Z ##[debug]testResultsFiles=testresults/TEST-*.xml
2020-01-25T01:12:07.7422659Z ##[debug]mergeTestResults=false
2020-01-25T01:12:07.7423114Z ##[debug]platform=null
2020-01-25T01:12:07.7423434Z ##[debug]configuration=null
2020-01-25T01:12:07.7423787Z ##[debug]testRunTitle=null
2020-01-25T01:12:07.7424308Z ##[debug]publishRunAttachments=true
2020-01-25T01:12:07.7424851Z ##[debug]failTaskOnFailedTests=true
2020-01-25T01:12:07.7426678Z ##[debug]searchFolder=./acceptance-tests/OOM-exception/
2020-01-25T01:12:07.7427036Z ##[debug]testRunner: JUnit
2020-01-25T01:12:07.7428343Z ##[debug]testResultsFiles: testresults/TEST-*.xml
2020-01-25T01:12:07.7428601Z ##[debug]mergeResults: false
2020-01-25T01:12:07.7428805Z ##[debug]platform: null
2020-01-25T01:12:07.7428998Z ##[debug]config: null
2020-01-25T01:12:07.7429181Z ##[debug]testRunTitle: null
2020-01-25T01:12:07.7429385Z ##[debug]publishRunAttachments: true
2020-01-25T01:12:07.7429576Z ##[debug]failTaskOnFailedTests: true
2020-01-25T01:12:07.7436004Z ##[debug]defaultRoot: './acceptance-tests/OOM-exception/'
2020-01-25T01:12:07.7436605Z ##[debug]findOptions.allowBrokenSymbolicLinks: 'true'
2020-01-25T01:12:07.7437018Z ##[debug]findOptions.followSpecifiedSymbolicLink: 'true'
2020-01-25T01:12:07.7437421Z ##[debug]findOptions.followSymbolicLinks: 'true'
2020-01-25T01:12:07.7437851Z ##[debug]matchOptions.debug: 'false'
2020-01-25T01:12:07.7438389Z ##[debug]matchOptions.nobrace: 'true'
2020-01-25T01:12:07.7439173Z ##[debug]matchOptions.noglobstar: 'false'
2020-01-25T01:12:07.7439555Z ##[debug]matchOptions.dot: 'true'
2020-01-25T01:12:07.7440082Z ##[debug]matchOptions.noext: 'false'
2020-01-25T01:12:07.7440915Z ##[debug]matchOptions.nocase: 'false'
2020-01-25T01:12:07.7441403Z ##[debug]matchOptions.nonull: 'false'
2020-01-25T01:12:07.7441842Z ##[debug]matchOptions.matchBase: 'false'
2020-01-25T01:12:07.7442248Z ##[debug]matchOptions.nocomment: 'false'
2020-01-25T01:12:07.7442699Z ##[debug]matchOptions.nonegate: 'false'
2020-01-25T01:12:07.7443144Z ##[debug]matchOptions.flipNegate: 'false'
2020-01-25T01:12:07.7443604Z ##[debug]pattern: 'testresults/TEST-*.xml'
2020-01-25T01:12:07.7476652Z ##[debug]findPath: './acceptance-tests/OOM-exception/testresults'
2020-01-25T01:12:07.7477167Z ##[debug]statOnly: 'false'
2020-01-25T01:12:07.7478528Z ##[debug]findPath: 'acceptance-tests/OOM-exception/testresults'
2020-01-25T01:12:07.7478992Z ##[debug]findOptions.allowBrokenSymbolicLinks: 'true'
2020-01-25T01:12:07.7479362Z ##[debug]findOptions.followSpecifiedSymbolicLink: 'true'
2020-01-25T01:12:07.7479710Z ##[debug]findOptions.followSymbolicLinks: 'true'
2020-01-25T01:12:07.7482715Z ##[debug] acceptance-tests/OOM-exception/testresults (directory)
2020-01-25T01:12:07.7489267Z ##[debug] acceptance-tests/OOM-exception/testresults/TEST-test_OOM_exceptions.OOM_exceptions-20200125011206.xml (file)
2020-01-25T01:12:07.7489642Z ##[debug]2 results
2020-01-25T01:12:07.7490249Z ##[debug]found 2 paths
2020-01-25T01:12:07.7490606Z ##[debug]applying include pattern
2020-01-25T01:12:07.7491144Z ##[debug]adjustedPattern: './acceptance-tests/OOM-exception/testresults/TEST-*.xml'
2020-01-25T01:12:07.7498261Z ##[debug]0 matches
2020-01-25T01:12:07.7504039Z ##[debug]0 final results
2020-01-25T01:12:07.7504342Z ##[debug]Detected 0 test result files
2020-01-25T01:12:07.7507804Z ##[debug]which 'dotnet'
2020-01-25T01:12:07.7513265Z ##[debug]found: '/usr/bin/dotnet'
2020-01-25T01:12:07.7515323Z ##[debug]which '/usr/bin/dotnet'
2020-01-25T01:12:07.7515798Z ##[debug]found: '/usr/bin/dotnet'
2020-01-25T01:12:07.7516162Z ##[debug]which '/usr/bin/dotnet'
2020-01-25T01:12:07.7516568Z ##[debug]found: '/usr/bin/dotnet'
2020-01-25T01:12:07.7518901Z ##[debug]/usr/bin/dotnet arg: --version
2020-01-25T01:12:07.7523251Z ##[debug]exec tool: /usr/bin/dotnet
2020-01-25T01:12:07.7523631Z ##[debug]arguments:
2020-01-25T01:12:07.7524431Z ##[debug] --version
2020-01-25T01:12:07.7528296Z [command]/usr/bin/dotnet --version
2020-01-25T01:12:11.2588747Z 3.0.101
2020-01-25T01:12:11.2655417Z ##[warning]No test result files matching testresults/TEST-*.xml were found.
2020-01-25T01:12:11.2666650Z ##[debug]Processed: ##vso[task.issue type=warning;]No test result files matching testresults/TEST-*.xml were found.
2020-01-25T01:12:11.2666885Z ##[debug]task result: Succeeded
2020-01-25T01:12:11.2667398Z ##[debug]Processed: ##vso[task.complete result=Succeeded;]
2020-01-25T01:12:11.2667534Z ##[debug]Release.ReleaseUri=undefined
2020-01-25T01:12:11.2667651Z ##[debug]Release.ReleaseId=undefined
2020-01-25T01:12:11.2667757Z ##[debug]Build.BuildUri=vstfs:///Build/Build/80106
2020-01-25T01:12:11.2667875Z ##[debug]Build.Buildid=80106
2020-01-25T01:12:11.3132563Z ##[debug]Processed: ##vso[telemetry.publish area=TestExecution;feature=PublishTestResultsTask]{"builduri":"vstfs:///Build/Build/80106","buildid":"80106","osType":"Linux","testRunner":"JUnit","failTaskOnFailedTests":"true","mergeResultsUserPreference":"false","config":null,"platform":null,"testResultsFilesCount":0,"dotnetVersion":"3.0.101","noResultsFileFound":true,"subFeature":"publishTestResultsTaskConsolidatedCiEvent"}
2020-01-25T01:12:11.3134445Z ##[section]Finishing: PublishTestResults
Edit:
Tried jessehouwing's answer. This didn't help. These are the logs:
2020-01-25T15:45:20.0576358Z ##[debug]searchFolder=./acceptance-tests/OOM-exception/
2020-01-25T15:45:20.0576743Z ##[debug]testRunner: JUnit
2020-01-25T15:45:20.0577183Z ##[debug]testResultsFiles: TEST-*.xml
2020-01-25T15:45:20.0577305Z ##[debug]mergeResults: false
2020-01-25T15:45:20.0577462Z ##[debug]platform: null
2020-01-25T15:45:20.0577563Z ##[debug]config: null
2020-01-25T15:45:20.0577706Z ##[debug]testRunTitle: null
2020-01-25T15:45:20.0577851Z ##[debug]publishRunAttachments: true
2020-01-25T15:45:20.0577958Z ##[debug]failTaskOnFailedTests: true
2020-01-25T15:45:20.0583685Z ##[debug]defaultRoot: './acceptance-tests/OOM-exception/'
2020-01-25T15:45:20.0584023Z ##[debug]findOptions.allowBrokenSymbolicLinks: 'true'
2020-01-25T15:45:20.0586845Z ##[debug]findOptions.followSpecifiedSymbolicLink: 'true'
2020-01-25T15:45:20.0587255Z ##[debug]findOptions.followSymbolicLinks: 'true'
2020-01-25T15:45:20.0587596Z ##[debug]matchOptions.debug: 'false'
2020-01-25T15:45:20.0587832Z ##[debug]matchOptions.nobrace: 'true'
2020-01-25T15:45:20.0588932Z ##[debug]matchOptions.noglobstar: 'false'
2020-01-25T15:45:20.0589501Z ##[debug]matchOptions.dot: 'true'
2020-01-25T15:45:20.0589789Z ##[debug]matchOptions.noext: 'false'
2020-01-25T15:45:20.0590176Z ##[debug]matchOptions.nocase: 'false'
2020-01-25T15:45:20.0590421Z ##[debug]matchOptions.nonull: 'false'
2020-01-25T15:45:20.0590685Z ##[debug]matchOptions.matchBase: 'false'
2020-01-25T15:45:20.0590905Z ##[debug]matchOptions.nocomment: 'false'
2020-01-25T15:45:20.0591171Z ##[debug]matchOptions.nonegate: 'false'
2020-01-25T15:45:20.0591432Z ##[debug]matchOptions.flipNegate: 'false'
2020-01-25T15:45:20.0591690Z ##[debug]pattern: 'TEST-*.xml'
2020-01-25T15:45:20.0631976Z ##[debug]findPath: './acceptance-tests/OOM-exception'
2020-01-25T15:45:20.0632431Z ##[debug]statOnly: 'false'
2020-01-25T15:45:20.0632752Z ##[debug]findPath: 'acceptance-tests/OOM-exception'
2020-01-25T15:45:20.0633054Z ##[debug]findOptions.allowBrokenSymbolicLinks: 'true'
2020-01-25T15:45:20.0633332Z ##[debug]findOptions.followSpecifiedSymbolicLink: 'true'
2020-01-25T15:45:20.0634538Z ##[debug]findOptions.followSymbolicLinks: 'true'
2020-01-25T15:45:20.0634974Z ##[debug] acceptance-tests/OOM-exception (directory)
2020-01-25T15:45:20.0646126Z ##[debug] acceptance-tests/OOM-exception/.dockerignore (file)
2020-01-25T15:45:20.0646726Z ##[debug] acceptance-tests/OOM-exception/.vscode (directory)
2020-01-25T15:45:20.0654441Z ##[debug] acceptance-tests/OOM-exception/.vscode/settings.json (file)
2020-01-25T15:45:20.0655814Z ##[debug] acceptance-tests/OOM-exception/CI (directory)
2020-01-25T15:45:20.0656184Z ##[debug] acceptance-tests/OOM-exception/CI/azure-test-OOM-exception-pipeline.yml (file)
2020-01-25T15:45:20.0657679Z ##[debug] acceptance-tests/OOM-exception/CI/config-ubuntu1804.sh (file)
2020-01-25T15:45:20.0661849Z ##[debug] acceptance-tests/OOM-exception/CI/config-windowsserver2019.ps1 (file)
2020-01-25T15:45:20.0662326Z ##[debug] acceptance-tests/OOM-exception/CI/test-VM-ARM-template-param.json (file)
2020-01-25T15:45:20.0662984Z ##[debug] acceptance-tests/OOM-exception/CI/test-VM-ARM-template.json (file)
2020-01-25T15:45:20.0665752Z ##[debug] acceptance-tests/OOM-exception/__pycache__ (directory)
2020-01-25T15:45:20.0666188Z ##[debug] acceptance-tests/OOM-exception/__pycache__/test_OOM_exceptions.cpython-38.pyc (file)
2020-01-25T15:45:20.0666991Z ##[debug] acceptance-tests/OOM-exception/acceptance_test_agent (directory)
2020-01-25T15:45:20.0667347Z ##[debug] acceptance-tests/OOM-exception/acceptance_test_agent/.vscode (directory)
2020-01-25T15:45:20.0667600Z ##[debug] acceptance-tests/OOM-exception/acceptance_test_agent/.vscode/settings.json (file)
2020-01-25T15:45:20.0668189Z ##[debug] acceptance-tests/OOM-exception/acceptance_test_agent/acceptance-test-agent.py (file)
2020-01-25T15:45:20.0668538Z ##[debug] acceptance-tests/OOM-exception/acceptance_test_agent/command_json_schema.json (file)
2020-01-25T15:45:20.0668786Z ##[debug] acceptance-tests/OOM-exception/acceptance_test_agent/requirements.txt (file)
2020-01-25T15:45:20.0669073Z ##[debug] acceptance-tests/OOM-exception/dc-authenticatieservice.Dockerfile (file)
2020-01-25T15:45:20.0669375Z ##[debug] acceptance-tests/OOM-exception/dc-dsbestellingbeheer.Dockerfile (file)
2020-01-25T15:45:20.0669614Z ##[debug] acceptance-tests/OOM-exception/dc-dsklantbeheer.Dockerfile (file)
2020-01-25T15:45:20.0669916Z ##[debug] acceptance-tests/OOM-exception/dc-frontend.Dockerfile (file)
2020-01-25T15:45:20.0670189Z ##[debug] acceptance-tests/OOM-exception/dc-spa.Dockerfile (file)
2020-01-25T15:45:20.0670429Z ##[debug] acceptance-tests/OOM-exception/docker-compose.override-images.yml (file)
2020-01-25T15:45:20.0670712Z ##[debug] acceptance-tests/OOM-exception/docker-compose.yml (file)
2020-01-25T15:45:20.0670990Z ##[debug] acceptance-tests/OOM-exception/docker_entry_point_sql-datacycle.sh (file)
2020-01-25T15:45:20.0671379Z ##[debug] acceptance-tests/OOM-exception/kantilever-datacycle-eventbus.Dockerfile (file)
2020-01-25T15:45:20.0671646Z ##[debug] acceptance-tests/OOM-exception/requirements.txt (file)
2020-01-25T15:45:20.0672447Z ##[debug] acceptance-tests/OOM-exception/runTest.sh (file)
2020-01-25T15:45:20.0672689Z ##[debug] acceptance-tests/OOM-exception/sql-datacycle.Dockerfile (file)
2020-01-25T15:45:20.0673143Z ##[debug] acceptance-tests/OOM-exception/test_OOM_exceptions.py (file)
2020-01-25T15:45:20.0673465Z ##[debug] acceptance-tests/OOM-exception/testresults (directory)
2020-01-25T15:45:20.0673717Z ##[debug] acceptance-tests/OOM-exception/testresults/TEST-test_OOM_exceptions.OOM_exceptions-20200125154519.xml (file)
2020-01-25T15:45:20.0673883Z ##[debug]33 results
2020-01-25T15:45:20.0674025Z ##[debug]found 33 paths
2020-01-25T15:45:20.0674129Z ##[debug]applying include pattern
2020-01-25T15:45:20.0674514Z ##[debug]adjustedPattern: './acceptance-tests/OOM-exception/TEST-*.xml'
2020-01-25T15:45:20.0678453Z ##[debug]0 matches
2020-01-25T15:45:20.0686188Z ##[debug]0 final results
2020-01-25T15:45:20.0687625Z ##[debug]Detected 0 test result files

I tested with xmlrunner and published the test result with publish test result task. It worked fine.
The above error says No test result files matching testresults/TEST-*.xml were found. The $(testFilesFolder) variable defined in your yaml pipeline probably is wrong. You can have try using the predefined variables (eg. $(system.defaultworkingdirectory)/acceptance-tests/OOM-exception) to point to the locations on the agent.
Below is my test project structure:
Below is my yaml pipeline:
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UsePythonVersion#0
inputs:
versionSpec: '3.8'
displayName: 'Use Python 3.8'
- script: |
python3 -m pip install --upgrade pip
pip install -r requirements.txt
displayName: 'Install dependencies'
- script: |
python3 -m xmlrunner discover --output testresults
continueOnError: true
workingDirectory: '$(system.defaultworkingdirectory)/acceptancetest/testfolder'
displayName: 'pytest'
- task: PublishTestResults#2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: 'testresults/TEST-*.xml'
searchFolder: '$(system.defaultworkingdirectory)/acceptancetest/testfolder'
failTaskOnFailedTests: true

Related

Clang-tidy change check options for clang-analyzer-optin.cplusplus.UninitializedObject

I am trying to change the Pedantic option in clang-analyzer-optin.cplusplus.UninitializedObject by create a .clang-tidy file
optin-cplusplus-uninitializedobject
here is the YAML version of .clang-tidy config-file:
Checks: >
cppcoreguidelines-*,
WarningsAsErrors: "*"
CheckOptions:
- { key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor, value: true }
- { key: clang-analyzer-optin.cplusplus.UninitializedObject.Pedantic, value: true }
when trying to -dump-config option I can see that the clang-analyzer-* check is used:
---
Checks: "clang-diagnostic-*,clang-analyzer-*,cppcoreguidelines-*,\\n"
WarningsAsErrors: '*'
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: none
CheckOptions:
modernize-replace-auto-ptr.IncludeStyle: llvm
cppcoreguidelines-no-malloc.Reallocations: '::realloc'
cppcoreguidelines-owning-memory.LegacyResourceConsumers: '::free;::realloc;::freopen;::fclose'
cppcoreguidelines-avoid-magic-numbers.IgnoreAllFloatingPointValues: 'false'
cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions: 'false'
cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField: 'false'
cert-dcl16-c.NewSuffixes: 'L;LL;LU;LLU'
cppcoreguidelines-macro-usage.CheckCapsOnly: 'false'
modernize-loop-convert.MaxCopySize: '16'
cppcoreguidelines-pro-bounds-constant-array-index.GslHeader: ''
cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors: 'false'
cppcoreguidelines-narrowing-conversions.IgnoreConversionFromTypes: ''
cert-str34-c.DiagnoseSignedUnsignedCharComparisons: 'false'
cert-err33-c.CheckedFunctions: '::aligned_alloc;::asctime_s;::at_quick_exit;::atexit;::bsearch;::bsearch_s;::btowc;::c16rtomb;::c32rtomb;::calloc;::clock;::cnd_broadcast;::cnd_init;::cnd_signal;::cnd_timedwait;::cnd_wait;::ctime_s;::fclose;::fflush;::fgetc;::fgetpos;::fgets;::fgetwc;::fopen;::fopen_s;::fprintf;::fprintf_s;::fputc;::fputs;::fputwc;::fputws;::fread;::freopen;::freopen_s;::fscanf;::fscanf_s;::fseek;::fsetpos;::ftell;::fwprintf;::fwprintf_s;::fwrite;::fwscanf;::fwscanf_s;::getc;::getchar;::getenv;::getenv_s;::gets_s;::getwc;::getwchar;::gmtime;::gmtime_s;::localtime;::localtime_s;::malloc;::mbrtoc16;::mbrtoc32;::mbsrtowcs;::mbsrtowcs_s;::mbstowcs;::mbstowcs_s;::memchr;::mktime;::mtx_init;::mtx_lock;::mtx_timedlock;::mtx_trylock;::mtx_unlock;::printf_s;::putc;::putwc;::raise;::realloc;::remove;::rename;::scanf;::scanf_s;::setlocale;::setvbuf;::signal;::snprintf;::snprintf_s;::sprintf;::sprintf_s;::sscanf;::sscanf_s;::strchr;::strerror_s;::strftime;::strpbrk;::strrchr;::strstr;::strtod;::strtof;::strtoimax;::strtok;::strtok_s;::strtol;::strtold;::strtoll;::strtoul;::strtoull;::strtoumax;::strxfrm;::swprintf;::swprintf_s;::swscanf;::swscanf_s;::thrd_create;::thrd_detach;::thrd_join;::thrd_sleep;::time;::timespec_get;::tmpfile;::tmpfile_s;::tmpnam;::tmpnam_s;::tss_create;::tss_get;::tss_set;::ungetc;::ungetwc;::vfprintf;::vfprintf_s;::vfscanf;::vfscanf_s;::vfwprintf;::vfwprintf_s;::vfwscanf;::vfwscanf_s;::vprintf_s;::vscanf;::vscanf_s;::vsnprintf;::vsnprintf_s;::vsprintf;::vsprintf_s;::vsscanf;::vsscanf_s;::vswprintf;::vswprintf_s;::vswscanf;::vswscanf_s;::vwprintf_s;::vwscanf;::vwscanf_s;::wcrtomb;::wcschr;::wcsftime;::wcspbrk;::wcsrchr;::wcsrtombs;::wcsrtombs_s;::wcsstr;::wcstod;::wcstof;::wcstoimax;::wcstok;::wcstok_s;::wcstol;::wcstold;::wcstoll;::wcstombs;::wcstombs_s;::wcstoul;::wcstoull;::wcstoumax;::wcsxfrm;::wctob;::wctrans;::wctype;::wmemchr;::wprintf_s;::wscanf;::wscanf_s;'
cppcoreguidelines-explicit-virtual-functions.AllowOverrideAndFinal: 'false'
google-readability-braces-around-statements.ShortStatementLines: '1'
cppcoreguidelines-pro-type-member-init.IgnoreArrays: 'false'
cppcoreguidelines-avoid-magic-numbers.IgnoredFloatingPointValues: '1.0;100.0;'
cppcoreguidelines-macro-usage.IgnoreCommandLineMacros: 'true'
cppcoreguidelines-pro-bounds-constant-array-index.IncludeStyle: llvm
cppcoreguidelines-narrowing-conversions.WarnWithinTemplateInstantiation: 'false'
cppcoreguidelines-owning-memory.LegacyResourceProducers: '::malloc;::aligned_alloc;::realloc;::calloc;::fopen;::freopen;::tmpfile'
cppcoreguidelines-narrowing-conversions.WarnOnFloatingPointNarrowingConversion: 'true'
cppcoreguidelines-narrowing-conversions.WarnOnEquivalentBitWidth: 'true'
cppcoreguidelines-avoid-magic-numbers.IgnoredIntegerValues: '1;2;3;4;'
cppcoreguidelines-non-private-member-variables-in-classes.IgnorePublicMemberVariables: 'false'
modernize-loop-convert.MinConfidence: reasonable
cppcoreguidelines-avoid-magic-numbers.IgnorePowersOf2IntegerValues: 'false'
cppcoreguidelines-special-member-functions.AllowMissingMoveFunctionsWhenCopyIsDeleted: 'false'
google-readability-namespace-comments.ShortNamespaceLines: '10'
google-readability-namespace-comments.SpacesBeforeComments: '2'
cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic: 'true'
cppcoreguidelines-avoid-magic-numbers.IgnoreBitFieldsWidths: 'true'
cppcoreguidelines-no-malloc.Allocations: '::malloc;::calloc'
cppcoreguidelines-narrowing-conversions.WarnOnIntegerNarrowingConversion: 'true'
cppcoreguidelines-narrowing-conversions.WarnOnIntegerToFloatingPointNarrowingConversion: 'true'
cppcoreguidelines-prefer-member-initializer.UseAssignment: 'false'
cppcoreguidelines-explicit-virtual-functions.FinalSpelling: final
llvm-qualified-auto.AddConstToQualified: 'false'
modernize-loop-convert.NamingStyle: CamelCase
cppcoreguidelines-pro-type-member-init.UseAssignment: 'false'
cppcoreguidelines-init-variables.MathHeader: '\<math.h\>'
google-readability-function-size.StatementThreshold: '800'
llvm-else-after-return.WarnOnConditionVariables: 'false'
cppcoreguidelines-init-variables.IncludeStyle: llvm
modernize-pass-by-value.IncludeStyle: llvm
cppcoreguidelines-explicit-virtual-functions.OverrideSpelling: override
cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor: 'true'
modernize-use-nullptr.NullMacros: 'NULL'
cppcoreguidelines-no-malloc.Deallocations: '::free'
cppcoreguidelines-macro-usage.AllowedRegexp: '^DEBUG\_\*'
cppcoreguidelines-narrowing-conversions.PedanticMode: 'false'
llvm-else-after-return.WarnOnUnfixable: 'false'
...
when executing -verify-config:
command-line option '-config': warning: unknown check option 'clang-analyzer-optin.cplusplus.UninitializedObject.Pedantic' [-verify-config]
How to change Pedantic option to true in .clang-tidy file?the description in optin-cplusplus-uninitializedobject is not clear for me

Problem with Github Actions IF expression syntax

I need to check if steps.get_acc.outputs.acc < 1 but right now the steps.get_acc.outputs.acc is a string how to make it an integer?
cml.yaml
name: MOPS
on: [push]
jobs:
run:
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout#v2
- uses: iterative/setup-cml#v1
- uses: actions/setup-python#v2
with:
python-version: '3.x'
- name: cml
id: get_acc
shell: pwsh
env:
repo_token: ${{ secrets.GITHUB_TOKEN }}
run: |
pip3 install -r requirements.txt
python train.py
$firstLine = Get-Content -Path 'metrics.txt' -TotalCount 1
$digits = $firstline.Split(':')[-1]
$acc = [int]$digits
Write-Output "::set-output name=acc::$acc"
- name: Check acc
if: ${{steps.get_acc.outputs.acc <1 }}
uses: actions/github-script#v3
with:
script: |
core.setFailed('Accuracy dropped')
The Github Documentation for output explained that:
The value that the output parameter will be mapped to can be set to a string or an expression with context. For example, you can use the steps context to set the value of an output to the output value of a step.
Taking a look at the Literals Github documentation, we can note that:
As part of an expression, we can use boolean, null, number, or string data types. Boolean literals are not case sensitive, so we can use true or True.
Therefore, it all depends on the way you set the output variable.
Example to set a number as output:
outputs:
random-number:
description: "Random number"
value: ${{ steps.random-number-generator.outputs.random-id }}
runs:
using: "composite"
steps:
- id: random-number-generator
run: echo "::set-output name=random-id::$(echo $RANDOM)"
shell: bash
EDIT:
Moreover the syntax you used for the if condition isn't correct, you need to remove the ${{ }} to make it work.
Example with if condition:
job:
runs-on: ubuntu-latest
steps:
- name: step-1
id: xyz
run: echo "::set-output name=acc::$(echo $RANDOM)"
- name: step-2
if: steps.xyz.outputs.acc < 1
run: |
echo "Number lower than 1"
echo "${{ steps.xyz.outputs.acc }}"
- name: step-3
if: steps.xyz.outputs.acc > 1
run: |
echo "Number higher than 1"
echo "${{ steps.xyz.outputs.acc }}"
It looks like you have been given an answer on how to handle it as an integer, but given that you are setting the output via code. Why not just evaluate the integer in your code and then set a true/false boolean value or a Y/N string? If all you need to do is use the value as an If condition why bother to set the integer value? You could just evaluate it and set the condition at the source.

Copy Files to: $(Build.ArtifactStagingDirectory) -Input required: TargetFolder

I am new to YAML and build pipelines. I am receiving the following error, can anyone advice what's wrong with the target folder.
Unhandled: Input required: TargetFolder
[warning]Directory 'D:\a\1\a' is empty. Nothing will be added to build
artifact 'drop'.
Below is my YAML file:
# Build app using Azure Pipelines
pool:
vmImage: 'vs2017-win2016'
steps:
- script: echo hello world
- task: NodeTool#0
inputs:
versionSpec: '8.x'
- task: CopyFiles#1
displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
inputs:
SourceFolder: '$(build.sourcesdirectory)'
Contents:
\C:\VSCodeGit\CollMod.Web\Web.config\
TartgetFolder: '$(Build.ArtifactStagingDirectory)'
condition: succeededOrFailed()
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
condition: succeededOrFailed()
I think it's the contents field that looks to be invalid here.
The docs at https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/copy-files?view=vsts&tabs=yaml and further documentation on https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/file-matching-patterns?view=vsts which both give some great examples.
If you're unsure set the contents to **/* which will copy absolutely everything in the $(build.sourcesdirectory), but it will give you a feel for the shape of the directory structure so that you can change **/* into something more selective and scoped for the file(s) you want to copy.
The Source folder should be : Build.SourcesDirectory instead of '$(build.sourcesdirectory)'
This is from : https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml#build-variables

Keep public/uploads folder of the last version with capistrano deploy

I am using Rails 4 with Capistrano to deploy on an Ubuntu 14.04 server and my users are able to upload files which are stored in /public/uploads. This folder should always be kept for new versions and should never get files from the git repository.
After reading a few guides I followed those steps:
Adding this to my deploy.rb:
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
set :linked_dirs, fetch(:linked_dirs) + %w{public/uploads}
Adding this to my /.gitignore:
# Ignore uploads
/public/uploads
Deleting the folder in my current git repository:
git rm -r --cached public/uploads
Now if I run cap deploy:setup I get this error:
Stage not set, please call something such as `cap production deploy`, where production is a stage you have defined.
If I define the stage production the deploy begins but I aborts very early:
cap aborted!
Don't know how to build task 'deploy:setup' (see --tasks)
And if I use my regular command to deploy cap production deploy everything works but the public/uploads/ folder will be renewed as before those changes.
Not sure if I am just missing the setup command or if I made mistakes in setting this up. My deploy.rb looks like this:
# Change these
server 'ip', port: port, roles: [:web, :app, :db], primary: true
set :repo_url, 'git#github.com:blabla/bla.git'
set :application, 'blub'
set :user, 'blib'
set :puma_threads, [4, 16]
set :puma_workers, 0
set :pty, true
set :use_sudo, false
set :stage, :production
set :deploy_via, :remote_cache
set :deploy_to, "/home/#{fetch(:user)}/apps/#{fetch(:application)}"
set :puma_bind, "unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock"
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
set :puma_access_log, "#{release_path}/log/puma.error.log"
set :puma_error_log, "#{release_path}/log/puma.access.log"
set :ssh_options, { forward_agent: true, user: fetch(:user), keys: %w(~/.ssh/id_rsa.pub) }
set :puma_preload_app, true
set :puma_worker_timeout, nil
set :puma_init_active_record, true # Change to false when not using ActiveRecord
## Defaults:
# set :scm, :git
# set :branch, :master
# set :format, :pretty
# set :log_level, :debug
# set :keep_releases, 5
## Linked Files & Directories (Default None):
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
set :linked_dirs, fetch(:linked_dirs) + %w{public/uploads}
#set :linked_files, %w{config/database.yml}
namespace :puma do
desc 'Create Directories for Puma Pids and Socket'
task :make_dirs do
on roles(:app) do
execute "mkdir #{shared_path}/tmp/sockets -p"
execute "mkdir #{shared_path}/tmp/pids -p"
end
end
before :start, :make_dirs
end
namespace :deploy do
desc "Make sure local git is in sync with remote."
task :check_revision do
on roles(:app) do
unless `git rev-parse HEAD` == `git rev-parse origin/master`
puts "WARNING: HEAD is not the same as origin/master"
puts "Run `git push` to sync changes."
exit
end
end
end
desc 'Initial Deploy'
task :initial do
on roles(:app) do
before 'deploy:restart', 'puma:start'
invoke 'deploy'
end
end
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
invoke 'puma:restart'
end
end
before :starting, :check_revision
after :finishing, :compile_assets
after :finishing, :cleanup
after :finishing, :restart
end
namespace :sake do
desc "Run a task on a remote server."
# run like: cap staging sake:invoke task="a_certain_task"
task :invoke do
on roles(:all) do |h|
execute "cd #{fetch(:deploy_to)}/current && bundle exec rake #{ENV['task']} RAILS_ENV=#{fetch(:rails_env)}"
end
end
end
# ps aux | grep puma # Get puma pid
# kill -s SIGUSR2 pid # Restart puma
# kill -s SIGTERM pid # Stop puma

adding an fstab option using Ansible

I am trying to add nodev to my /etc/fstab file. I am using the Ansible command below but with no luck. My issue lies with the regular expression, I'm not a pro at regex.
- name: Add nodev to /etc/fstab
lineinfile:
dest=/etc/fstab
backup=yes
backrefs=yes
state=present
regexp='(^/dev[\w/_-]+(\s+(?!nodev)[\w,]+)*)'
line='\1,nodev'
One of the lines from /etc/fstab that I am trying to add nodev is:
/dev/mapper/ex_sys-ex_home /home /ext4 rw,exec,auto,nouser,sync 1 2
While this may not be the most elegant answer, it worked for me.
- name: Ensure fstab uses nodev
mount:
name: "{{ item.mount }}"
src: "{{ item.device }}"
fstype: "{{ item.fstype }}"
opts: "{{ item.options }},nodev"
state: present
with_items: ansible_mounts
when: item.options.find(",") >= 0 and item.options.find("nodev") == -1
Inspired by Joe's answer I made this version which will add a single option to a specific line in /etc/fstab if it isn't there already. This will also keep any other options the line already had.
main.yml
- import_tasks: fstab-opt-present.yml point=/home opt=nodev
fstab-opt-present.yml
- name: '/etc/fstab: Set opt "{{ opt }}" for mount point {{ point }}'
lineinfile:
path: /etc/fstab
backup: yes
backrefs: yes
regexp: '^(\S+\s+{{ point }}\s+\S+\s+)(?!(?:\S*,)?{{ opt }}(?:,\S*)?\s+)(\S+)(\s+.+)$'
line: '\1{{ opt }},\2\3'
register: fstab
- name: 'If {{ point }} changed, remount'
command: 'mount {{ point }} -o remount'
when: fstab.changed
https://regex101.com/ is a really helpful tool for building and testing these kind of regexps. Just enable the "multiline" option there and open the "Substitution" panel and you can even paste in your /etc/fstab and see which lines your regex will match and what it will do to them. Just remember to use real values instead of the Ansible variables {{ point }} etc. when testing there
We've developed a 3rd-party ansible module to add, set or remove mount options. Check it out!
- mountopts:
name: /
option: nodev
https://github.com/Uberspace/ansible-mountopts
I wanted to state that there seems to be a new ansible module which covers all this much more easily:
https://docs.ansible.com/ansible/latest/modules/mount_module.html
Tested & works fine
- name: Set nodev option
replace:
path: /etc/fstab
backup: yes
regexp: '^(\S+\s+)(\/\S+)(\s+)((?:ext4|xfs)\s+)(?!(?:\S*,)?nodev(?:,\S*)?\s+)(\S+)(\s+.+)$'
replace: '\1\2 \4 \5,nodev \6'
It excludes adding nodev to /(root), sets only to ext4 and xfs filesystem. doesn't add to temp filesystems.
Note: while you test regexp101, make sure to select python
Landed here looking for an answer, wound up rolling my own for my use case:
main.yml
- include: fstab-opts.yml point=/tmp opts=noexec,nodev,nosuid,noatime
- include: fstab-opts.yml point=/backup opts=noatime
fstab-opts.yml
---
- name: 'Ensure {{ point }} flags'
lineinfile:
path: /etc/fstab
# uses "(not-spaces spaces /tmp spaces )(not-spaces)(the rest)" pattern to match column content and capture args
regexp: '^([^ ]+[ ]+\{{ point }}[ ]+[^ ]+[ ]+)([^ ]+)(.*)'
line: '\1{{ opts }}\3'
backrefs: yes
register: fstab
- name: 'If {{ point }} changed, remount'
command: mount -o remount {{ point }}
when: fstab.changed
i have added the noexec,nodev,nosuid option in /etc/fstab for the /var/tmp mount point.
Requirement is:
Ensure noexec option set on /var/tmp partition
Ensure nodev option set on /var/tmp partition
Ensure nosuid option set on /var/tmp partition
if required install ansible.posix.mount module using below command .
# ansible-galaxy collection install ansible.posix
Playbook:
---
- name: "STEP 1: Get /var/tmp mounted SRC device"
shell: mount | grep -E '\s/var/tmp\s' | awk '{print $1}'
register: "vartmpsrc"
- debug:
msg: "Validated the /var/tmp mount output: {{ vartmpsrc.stdout }}"
- name: "Add mount noexec,nodev,nosuid options for /var/tmp"
mount:
path: "/var/tmp"
src: "{{ vartmpsrc.stdout }}"
fstype: "tmpfs"
opts: "nosuid,nodev,noexec"
state: "present"
when: vartmpsrc.stdout == "/var/tmp"
- name: Remount /var/tmp mounted volume with mount options noexec,nodev,nosuid
ansible.posix.mount:
path: /var/tmp
state: remounted
when: vartmpsrc.stdout == "/var/tmp"
- name: 'STEP 2: Validate noexec,nodev,nosuid option set on /var/tmp partition'
shell: mount | grep -E '\s/var/tmp\s' | grep -v {{ item }}
loop:
- noexec
- nodev
- nosuid
register: vartmp_exists
ignore_errors: yes
when: vartmpsrc.stdout == "/var/tmp"