-
Notifications
You must be signed in to change notification settings - Fork 856
101 lines (89 loc) · 4.04 KB
/
ci.yml
File metadata and controls
101 lines (89 loc) · 4.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: CI
on:
pull_request:
branches:
- main
- 'release/**'
push:
branches:
- main
- 'release/**'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
prepare_for_ci:
runs-on: ubuntu-latest
name: Prepare for CI
if: ${{ github.repository_owner == 'microsoft' }}
outputs:
skip_workflow: ${{ (steps.check_for_changes.outputs.no_changes == 'true' || steps.check_for_changes.outputs.only_changed == 'true') && 'true' || 'false' }}
VERSION_SUFFIX_OVERRIDE: ${{ steps.compute_version_suffix.outputs.VERSION_SUFFIX_OVERRIDE }}
EXTENSION_VERSION_OVERRIDE: ${{ steps.compute_version_suffix.outputs.EXTENSION_VERSION_OVERRIDE }}
steps:
- name: Checkout code
if: ${{ github.event_name == 'pull_request' }}
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Check for any changes that require CI
id: check_for_changes
if: ${{ github.event_name == 'pull_request' }}
uses: ./.github/actions/check-changed-files
with:
patterns_file: eng/testing/github-ci-trigger-patterns.txt
- id: compute_version_suffix
name: Compute version suffix for PRs
if: ${{ github.event_name == 'pull_request' }}
shell: pwsh
env:
# Use the pull request head SHA instead of GITHUB_SHA (which can be a merge commit)
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PR_NUMBER: ${{ github.event.number }}
run: |
Write-Host "Determining VERSION_SUFFIX_OVERRIDE (PR only step)..."
if ([string]::IsNullOrWhiteSpace($Env:PR_HEAD_SHA)) {
Write-Error "PR_HEAD_SHA not set; cannot compute version suffix."
exit 1
}
$SHORT_SHA = $Env:PR_HEAD_SHA.Substring(0,8)
$VERSION_SUFFIX = "/p:VersionSuffix=pr.$($Env:PR_NUMBER).g$SHORT_SHA"
Write-Host "Computed VERSION_SUFFIX_OVERRIDE=$VERSION_SUFFIX"
"VERSION_SUFFIX_OVERRIDE=$VERSION_SUFFIX" | Out-File -FilePath $Env:GITHUB_OUTPUT -Append -Encoding utf8
$EXTENSION_VERSION = "99.0.$($Env:PR_NUMBER)"
Write-Host "Computed EXTENSION_VERSION_OVERRIDE=$EXTENSION_VERSION"
"EXTENSION_VERSION_OVERRIDE=$EXTENSION_VERSION" | Out-File -FilePath $Env:GITHUB_OUTPUT -Append -Encoding utf8
tests:
uses: ./.github/workflows/tests.yml
name: Tests
needs: [prepare_for_ci]
if: ${{ github.repository_owner == 'microsoft' && needs.prepare_for_ci.outputs.skip_workflow != 'true' }}
with:
versionOverrideArg: ${{ needs.prepare_for_ci.outputs.VERSION_SUFFIX_OVERRIDE }}
extensionVersionOverride: ${{ needs.prepare_for_ci.outputs.EXTENSION_VERSION_OVERRIDE }}
# This job is used for branch protection. It fails if any of the dependent jobs failed
results:
if: ${{ always() && github.repository_owner == 'microsoft' }}
runs-on: ubuntu-latest
name: Final Results
needs: [prepare_for_ci, tests]
steps:
- name: Fail if any of the dependent jobs failed
# Don't fail if the workflow is being skipped.
# Check skip_workflow on all declared dependencies. Workflows without
# skip_workflow outputs (e.g., tests, build_cli_archives) evaluate to
# empty string, so the check still works ('!= true' is true for empty).
#
# For others 'skipped' can be when a transitive dependency fails and the dependent job gets
# 'skipped'. For example, one of setup_* jobs failing and the Integration test jobs getting
# 'skipped'
if: >-
${{ always() &&
needs.prepare_for_ci.outputs.skip_workflow != 'true' &&
needs.tests.outputs.skip_workflow != 'true' &&
(contains(needs.*.result, 'failure') ||
contains(needs.*.result, 'cancelled') ||
contains(needs.*.result, 'skipped')) }}
run: |
echo "One or more dependent jobs failed."
exit 1