mirror of
https://github.com/dotnet/skills.git
synced 2026-09-20 09:49:54 +08:00
194 lines
7.0 KiB
YAML
194 lines
7.0 KiB
YAML
name: skill-validator
|
|
|
|
on:
|
|
pull_request:
|
|
schedule:
|
|
- cron: '0 8 * * *' # daily at 08:00 UTC
|
|
workflow_dispatch:
|
|
inputs:
|
|
create_release:
|
|
description: 'Create a nightly release after building'
|
|
type: boolean
|
|
default: false
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.run_id }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
RETENTION_DAYS: ${{ (github.event_name == 'schedule' || inputs.create_release) && 90 || 5 }}
|
|
AGNOSTIC_RID: linux-x64
|
|
|
|
jobs:
|
|
discover:
|
|
if: github.event_name == 'pull_request'
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
has_changes: ${{ steps.check.outputs.has_changes }}
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Check for relevant changes
|
|
id: check
|
|
shell: pwsh
|
|
run: |
|
|
$base = "${{ github.event.pull_request.base.sha }}"
|
|
$head = "${{ github.event.pull_request.head.sha }}"
|
|
$mergeBase = git merge-base $base $head
|
|
$changed = git diff --name-only $mergeBase $head |
|
|
Where-Object { $_ -match '^(eng/skill-validator/|\.github/workflows/skill-validator\.yml$)' -and $_ -ne 'eng/skill-validator/InvestigatingResults.md' } |
|
|
Select-Object -First 1
|
|
if ($changed) {
|
|
echo "has_changes=true" >> $env:GITHUB_OUTPUT
|
|
} else {
|
|
echo "has_changes=false" >> $env:GITHUB_OUTPUT
|
|
}
|
|
|
|
build:
|
|
needs: discover
|
|
# Don't run scheduled builds on forked repositories — forks that enable
|
|
# Actions would otherwise consume the fork owner's minutes indefinitely.
|
|
# For PRs, skip when no relevant files changed (discover job).
|
|
if: >-
|
|
always() &&
|
|
!(github.event_name == 'schedule' && github.event.repository.fork) &&
|
|
(needs.discover.result == 'skipped' || needs.discover.outputs.has_changes == 'true')
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- os: ubuntu-latest
|
|
rid: linux-x64
|
|
- os: ubuntu-24.04-arm
|
|
rid: linux-arm64
|
|
- os: windows-latest
|
|
rid: win-x64
|
|
- os: windows-11-arm
|
|
rid: win-arm64
|
|
- os: macos-latest
|
|
rid: osx-arm64
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
|
with:
|
|
persist-credentials: false
|
|
- uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5
|
|
with:
|
|
global-json-file: global.json
|
|
|
|
- name: Build
|
|
run: dotnet build eng/skill-validator/SkillValidator.slnx /bl:artifacts/logs/build.binlog
|
|
|
|
- name: Test
|
|
run: dotnet test --solution eng/skill-validator/SkillValidator.slnx --no-build /bl:artifacts/logs/test.binlog
|
|
|
|
- name: Pack RID-specific NuGet package
|
|
run: dotnet pack eng/skill-validator/src/SkillValidator.csproj --use-current-runtime /bl:artifacts/logs/pack-rid.binlog
|
|
|
|
- name: Upload RID-specific NuGet package
|
|
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
|
|
with:
|
|
name: skill-validator-${{ matrix.rid }}
|
|
path: artifacts/package/release/Microsoft.DotNet.SkillValidator.${{ matrix.rid }}.*.nupkg
|
|
archive: false
|
|
retention-days: ${{ env.RETENTION_DAYS }}
|
|
if-no-files-found: error
|
|
|
|
- name: Create tar.gz archive
|
|
shell: bash
|
|
run: |
|
|
mkdir -p artifacts/assets
|
|
tar -czf artifacts/assets/skill-validator-${{ matrix.rid }}.tar.gz -C artifacts/publish/SkillValidator/release .
|
|
|
|
- name: Upload tar.gz archive
|
|
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
|
|
with:
|
|
name: skill-validator-${{ matrix.rid }}.tar.gz
|
|
path: artifacts/assets/skill-validator-${{ matrix.rid }}.tar.gz
|
|
archive: false
|
|
retention-days: ${{ env.RETENTION_DAYS }}
|
|
if-no-files-found: error
|
|
|
|
- name: Pack RID-agnostic NuGet package
|
|
if: matrix.rid == env.AGNOSTIC_RID
|
|
run: dotnet pack eng/skill-validator/src/SkillValidator.csproj /bl:artifacts/logs/pack-agnostic.binlog
|
|
|
|
- name: Upload RID-agnostic NuGet package
|
|
if: matrix.rid == env.AGNOSTIC_RID
|
|
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
|
|
with:
|
|
archive: false
|
|
name: skill-validator
|
|
path: |
|
|
artifacts/package/release/Microsoft.DotNet.SkillValidator.*.nupkg
|
|
!artifacts/package/release/Microsoft.DotNet.SkillValidator.${{ env.AGNOSTIC_RID }}.*.nupkg
|
|
retention-days: ${{ env.RETENTION_DAYS }}
|
|
if-no-files-found: error
|
|
|
|
- name: Upload binlogs
|
|
if: always()
|
|
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
|
|
with:
|
|
name: binlogs-${{ matrix.rid }}
|
|
path: artifacts/logs/*.binlog
|
|
retention-days: ${{ env.RETENTION_DAYS }}
|
|
if-no-files-found: ignore
|
|
|
|
release:
|
|
if: >-
|
|
always() &&
|
|
needs.build.result == 'success' &&
|
|
(github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' && inputs.create_release))
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
|
with:
|
|
persist-credentials: true
|
|
|
|
- name: Download all artifacts
|
|
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
|
|
with:
|
|
path: release-assets
|
|
merge-multiple: true
|
|
|
|
- name: Create or update nightly release
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
tag="skill-validator-nightly"
|
|
gh release delete "$tag" --yes || true
|
|
git tag -f "$tag"
|
|
git push -f origin "$tag"
|
|
gh release create "$tag" release-assets/*.nupkg release-assets/*.tar.gz \
|
|
--title "SkillValidator Nightly" \
|
|
--notes "Automated nightly build from \`main\` ($(date -u +%Y-%m-%d))." \
|
|
--prerelease
|
|
|
|
# Require this job in the GitHub ruleset. It always runs on PRs and
|
|
# succeeds when no relevant files changed or the build passed.
|
|
skill-validator-status:
|
|
needs: [discover, build]
|
|
if: always() && github.event_name == 'pull_request'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check result
|
|
run: |
|
|
if [[ "${{ needs.discover.result }}" != "success" ]]; then
|
|
echo "::error::Discovery failed (${{ needs.discover.result }})"
|
|
exit 1
|
|
elif [[ "${{ needs.discover.outputs.has_changes }}" != "true" ]]; then
|
|
echo "No skill-validator changes — skipping build"
|
|
elif [[ "${{ needs.build.result }}" != "success" ]]; then
|
|
echo "::error::Build failed (${{ needs.build.result }})"
|
|
exit 1
|
|
else
|
|
echo "Build and tests passed"
|
|
fi
|