Skip to content

Commit c67718f

Browse files
committed
GHA: add a swift-format build stage for the toolchain
Begin building `swift-format` as part of the toolchain as this is meant to be part of the toolchain distribution on Windows.
1 parent 62f4026 commit c67718f

File tree

1 file changed

+80
-2
lines changed

1 file changed

+80
-2
lines changed

.github/workflows/swift-toolchain.yml

Lines changed: 80 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
swift_crypto_revision: ${{ steps.context.outputs.swift_crypto_revision }}
4444
swift_driver_revision: ${{ steps.context.outputs.swift_driver_revision }}
4545
swift_experimental_string_processing_revision: ${{ steps.context.outputs.swift_experimental_string_processing_revision }}
46+
swift_format_revision: ${{ steps.context.outputs.swift_format_revision }}
4647
swift_installer_scripts_revision: ${{ steps.context.outputs.swift_installer_scripts_revision }}
4748
swift_llbuild_revision: ${{ steps.context.outputs.swift_llbuild_revision }}
4849
swift_package_manager_revision: ${{ steps.context.outputs.swift_package_manager_revision }}
@@ -85,6 +86,7 @@ jobs:
8586
swift_crypto_revision=refs/tags/2.4.0
8687
swift_driver_revision=refs/tags/${{ github.event.inputs.swift_tag }}
8788
swift_experimental_string_processing_revision=refs/tags/${{ github.event.inputs.swift_tag }}
89+
swift_format_revision=refs/tags/${{ github.event.inputs.swift_tag }}
8890
swift_installer_scripts_revision=refs/heads/main
8991
swift_llbuild_revision=refs/tags/${{ github.event.inputs.swift_tag }}
9092
swift_package_manager_revision=refs/tags/${{ github.event.inputs.swift_tag }}
@@ -1873,6 +1875,7 @@ jobs:
18731875
name: installer-amd64
18741876
path: ${{ github.workspace }}/tmp
18751877

1878+
# TODO(compnerd): migrate this to compnerd/gha-setup-swift after the work that @mangini is doing is completed
18761879
- run: |
18771880
function Update-EnvironmentVariables {
18781881
foreach ($level in "Machine", "User") {
@@ -1918,9 +1921,84 @@ jobs:
19181921
- run: swift test -Xswiftc -DENABLE_TESTING
19191922
working-directory: ${{ github.workspace }}/SourceCache/swift-win32
19201923

1924+
swift_format:
1925+
runs-on: windows-latest
1926+
needs: [context, installer]
1927+
1928+
steps:
1929+
- uses: actions/download-artifact@v3
1930+
with:
1931+
name: installer-amd64
1932+
path: ${{ github.workspace }}/tmp
1933+
1934+
# TODO(compnerd) can this be done via a re-usage workflow for swift-format?
1935+
1936+
# TODO(compnerd): migrate this to compnerd/gha-setup-swift after the work that @mangini is doing is completed
1937+
- run: |
1938+
function Update-EnvironmentVariables {
1939+
foreach ($level in "Machine", "User") {
1940+
[Environment]::GetEnvironmentVariables($level).GetEnumerator() | % {
1941+
# For Path variables, append the new values, if they're not already in there
1942+
if ($_.Name -Match 'Path$') {
1943+
$_.Value = ($((Get-Content "Env:$($_.Name)") + ";$($_.Value)") -Split ';' | Select -Unique) -Join ';'
1944+
}
1945+
$_
1946+
} | Set-Content -Path { "Env:$($_.Name)" }
1947+
}
1948+
}
1949+
1950+
try {
1951+
Write-Host "Starting Install installer.exe..."
1952+
$Process = Start-Process -FilePath ${{ github.workspace }}/tmp/installer.exe -ArgumentList ("-q") -Wait -PassThru
1953+
$ExitCode = $Process.ExitCode
1954+
if ($ExitCode -eq 0 -or $ExitCode -eq 3010) {
1955+
Write-Host "Installation successful"
1956+
} else {
1957+
Write-Host "non-zero exit code returned by the installation process: $ExitCode"
1958+
exit $ExitCode
1959+
}
1960+
} catch {
1961+
Write-Host "Failed to install: $($_.Exception.Message)"
1962+
exit 1
1963+
}
1964+
Update-EnvironmentVariables
1965+
1966+
# Reset Path and environment
1967+
echo "$env:Path" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
1968+
Get-ChildItem Env: | % { echo "$($_.Name)=$($_.Value)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append }
1969+
1970+
- uses: actions/checkout@v3
1971+
with:
1972+
repository: apple/swift-format
1973+
ref: ${{ needs.context.outputs.swift_format_revision }}
1974+
path: ${{ github.workspace }}/SourceCache/swift-format
1975+
1976+
- run: swift test
1977+
working-directory: ${{ github.workspace }}/SourceCache/swift-format
1978+
1979+
- run: swift build -c release -Xswiftc -gnone
1980+
working-directory: ${{ github.workspace }}/SourceCache/swift-format
1981+
1982+
- uses: actions/checkout@v3
1983+
with:
1984+
repository: apple/swift-installer-scripts
1985+
ref: ${{ needs.context.outputs.swift_installer_scripts_revision }}
1986+
path: ${{ github.workspace }}/SourceCache/swift-installer-scripts
1987+
1988+
- uses: microsoft/[email protected]
1989+
1990+
- run: msbuild ${{ github.workspace }}/SourceCache/swift-installer-scripts/platforms/Windows/swift-format.wixproj -nologo -restore -p:Configuration=Release -p:SWIFT_FORMAT_BUILD=${{ github.workspace }}\SourceCache\swift-format\.build\release -p:OutputPath=${{ github.workspace }}\artifacts -p:RunWixToolsOutOfProc=true
1991+
1992+
- uses: actions/upload-artifact@v2
1993+
with:
1994+
name: swift-format
1995+
path: |
1996+
${{ github.workspace }}/.build/release/swift-format.exe
1997+
${{ github.workspace }}/artifacts/swift-format.msi
1998+
19211999
snapshot:
19222000
runs-on: ubuntu-latest
1923-
needs: [context, smoke_test]
2001+
needs: [context, swift_format]
19242002

19252003
steps:
19262004
- uses: actions/checkout@v3
@@ -1942,7 +2020,7 @@ jobs:
19422020
19432021
release:
19442022
runs-on: ubuntu-latest
1945-
needs: [smoke_test]
2023+
needs: [smoke_test, swift_format]
19462024

19472025
steps:
19482026
- uses: actions/download-artifact@v3

0 commit comments

Comments
 (0)