Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Clean all yaml in the pipelines of warnings and errors and add a workflow to validate the yaml used. #21345

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
49 changes: 49 additions & 0 deletions .github/workflows/yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# yamllint disable rule:line-length rule:document-start rule:truthy
name: PR yamllint check
on: pull_request

# This action only need a single permission in order to autoformat the code.
mandel-macaque marked this conversation as resolved.
Show resolved Hide resolved
permissions:
contents: read
pull-requests: write

jobs:
rebase:
name: yamllint check
runs-on: ubuntu-latest

steps:
- name: 'Checkout'
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
mandel-macaque marked this conversation as resolved.
Show resolved Hide resolved

- name: Install yamllint
run: pip install yamllint

- name: Lint YAML pipeline files
id: lint-pipeline
working-directory: ./eng/pipelines
run: |
RESULT=$(yamllint ./eng/pipelines --f github)
if [ -n "$RESULT" ]; then
echo "YAML Lint found issues"
echo "$RESULT"
echo "::set-output name=result::$RESULT"
exit 1
fi

# only post a comment if the linting fails
- name: Post comment
uses: unsplash/[email protected]
if: failure()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
msg: |
[yaml-lint] YamlLint found issues in the pipeline files.
${{ steps.lint-pipeline.outputs.result }}
check_for_duplicate_msg: true
delete_prev_regex_msg: "YamlLint found issues in the pipeline files."
duplicate_msg_pattern: "YamlLint found issues in the pipeline files."
1 change: 1 addition & 0 deletions eng/pipelines/common/apiscan.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# yamllint disable rule:line-length rule:document-start
parameters:
poolName: MAUI-1ESPT
vmImage: '1ESPT-Windows2022'
Expand Down
105 changes: 53 additions & 52 deletions eng/pipelines/common/device-tests-steps.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# yamllint disable rule:line-length rule:document-start
parameters:
platform: '' # [ android, ios, catalyst, windows ]
path: '' # path to csproj
device: '' # the xharness device to use
apiversion: '' # the iOS device api version to use
cakeArgs: '' # additional cake args
platform: '' # [ android, ios, catalyst, windows ]
path: '' # path to csproj
device: '' # the xharness device to use
apiversion: '' # the iOS device api version to use
cakeArgs: '' # additional cake args
provisionatorChannel: 'latest'
agentPoolAccessToken: ''
artifactName: 'nuget'
Expand All @@ -14,13 +15,13 @@ parameters:

steps:
- ${{ if eq(parameters.platform, 'ios')}}:
- bash: |
chmod +x $(System.DefaultWorkingDirectory)/eng/scripts/clean-bot.sh
chmod +x $(System.DefaultWorkingDirectory)/eng/scripts/clean-simulator-runtime.sh
$(System.DefaultWorkingDirectory)/eng/scripts/clean-bot.sh
displayName: 'Clean bot'
continueOnError: true
timeoutInMinutes: 60
- bash: |
chmod +x $(System.DefaultWorkingDirectory)/eng/scripts/clean-bot.sh
chmod +x $(System.DefaultWorkingDirectory)/eng/scripts/clean-simulator-runtime.sh
$(System.DefaultWorkingDirectory)/eng/scripts/clean-bot.sh
displayName: 'Clean bot'
continueOnError: true
timeoutInMinutes: 60
- template: provision.yml
parameters:
${{ if eq(parameters.platform, 'windows')}}:
Expand All @@ -46,27 +47,27 @@ steps:

- ${{ if eq(parameters.useArtifacts, true) }}:

- task: DownloadBuildArtifacts@0
displayName: 'Download Packages'
inputs:
artifactName: ${{ parameters.artifactName }}
itemPattern: ${{ parameters.artifactItemPattern }}
downloadPath: $(System.DefaultWorkingDirectory)/artifacts
- task: DownloadBuildArtifacts@0
displayName: 'Download Packages'
inputs:
artifactName: ${{ parameters.artifactName }}
itemPattern: ${{ parameters.artifactItemPattern }}
downloadPath: $(System.DefaultWorkingDirectory)/artifacts

- pwsh: Move-Item -Path artifacts\${{ parameters.artifactName }}\*.nupkg -Destination artifacts -Force
displayName: Move the downloaded artifacts
- pwsh: Move-Item -Path artifacts\${{ parameters.artifactName }}\*.nupkg -Destination artifacts -Force
displayName: Move the downloaded artifacts

- pwsh: ./build.ps1 --target=dotnet-local-workloads --verbosity=diagnostic
displayName: 'Install .NET (Local Workloads)'
retryCountOnTaskFailure: 2
workingDirectory: ${{ parameters.checkoutDirectory }}
env:
DOTNET_TOKEN: $(dotnetbuilds-internal-container-read-token)
PRIVATE_BUILD: $(PrivateBuild)
- pwsh: ./build.ps1 --target=dotnet-local-workloads --verbosity=diagnostic
displayName: 'Install .NET (Local Workloads)'
retryCountOnTaskFailure: 2
workingDirectory: ${{ parameters.checkoutDirectory }}
env:
DOTNET_TOKEN: $(dotnetbuilds-internal-container-read-token)
PRIVATE_BUILD: $(PrivateBuild)

- ${{ else }}:
- pwsh: ./build.ps1 --target=dotnet-buildtasks --configuration="Release"
displayName: 'Build the MSBuild Tasks'
- pwsh: ./build.ps1 --target=dotnet-buildtasks --configuration="Release"
displayName: 'Build the MSBuild Tasks'

- pwsh: |
$platformName = 'Windows'
Expand All @@ -80,12 +81,12 @@ steps:
displayName: 'Set Platform.Name'

- ${{ if eq(parameters.platform, 'ios')}}:
- bash: |
if [ -f "$HOME/Library/Logs/CoreSimulator/*" ]; then rm -r $HOME/Library/Logs/CoreSimulator/*; fi
if [ -f "$HOME/Library/Logs/DiagnosticReports/*" ]; then rm -r $HOME/Library/Logs/DiagnosticReports/*; fi
displayName: Delete Old Simulator Logs
condition: always()
continueOnError: true
- bash: |
if [ -f "$HOME/Library/Logs/CoreSimulator/*" ]; then rm -r $HOME/Library/Logs/CoreSimulator/*; fi
if [ -f "$HOME/Library/Logs/DiagnosticReports/*" ]; then rm -r $HOME/Library/Logs/DiagnosticReports/*; fi
displayName: Delete Old Simulator Logs
condition: always()
continueOnError: true

- pwsh: |
./build.ps1 -Script eng/devices/${{ parameters.platform }}.cake --project="${{ parameters.path }}" --device=${{ parameters.device }} --apiversion=${{ parameters.apiversion }} --packageid=${{ parameters.windowsPackageId }} --results="$(TestResultsDirectory)" --binlog="$(LogDirectory)" ${{ parameters.cakeArgs }}
Expand All @@ -103,22 +104,22 @@ steps:
retryCountOnTaskFailure: 1

- ${{ if eq(parameters.platform, 'ios')}}:
- bash: |
suffix=$(date +%Y%m%d%H%M%S)
zip -9r "$(LogDirectory)/CoreSimulatorLog_${suffix}.zip" "$HOME/Library/Logs/CoreSimulator/"
zip -9r "$(LogDirectory)/DiagnosticReports_${suffix}.zip" "$HOME/Library/Logs/DiagnosticReports/"
displayName: Zip Simulator Logs
condition: always()
continueOnError: true
- bash: |
suffix=$(date +%Y%m%d%H%M%S)
zip -9r "$(LogDirectory)/CoreSimulatorLog_${suffix}.zip" "$HOME/Library/Logs/CoreSimulator/"
zip -9r "$(LogDirectory)/DiagnosticReports_${suffix}.zip" "$HOME/Library/Logs/DiagnosticReports/"
displayName: Zip Simulator Logs
condition: always()
continueOnError: true


- ${{ if eq(parameters.platform, 'ios')}}:
- bash: |
zip -9r "$(LogDirectory)/CoreSimulatorLog.zip" "$HOME/Library/Logs/CoreSimulator/"
zip -9r "$(LogDirectory)/DiagnosticReports.zip" "$HOME/Library/Logs/DiagnosticReports/"
displayName: Zip Simulator Logs
condition: always()
continueOnError: true
- bash: |
zip -9r "$(LogDirectory)/CoreSimulatorLog.zip" "$HOME/Library/Logs/CoreSimulator/"
zip -9r "$(LogDirectory)/DiagnosticReports.zip" "$HOME/Library/Logs/DiagnosticReports/"
displayName: Zip Simulator Logs
condition: always()
continueOnError: true

- task: PublishTestResults@2
displayName: Publish the $(Agent.JobName) test results
Expand All @@ -135,7 +136,7 @@ steps:
artifactName: '$(Agent.JobName) (attempt $(System.JobAttempt))'

- ${{ if eq(parameters.rebootAgent, true) }}:
# This must always be placed as the last step in the job
- template: agent-rebooter/mac.v1.yml@yaml-templates
parameters:
AgentPoolAccessToken: ${{ parameters.agentPoolAccessToken }}
# This must always be placed as the last step in the job
- template: agent-rebooter/mac.v1.yml@yaml-templates
parameters:
AgentPoolAccessToken: ${{ parameters.agentPoolAccessToken }}
Loading
Loading