From a82ffbd9db224bcf630b8b0db56b71b72a522c62 Mon Sep 17 00:00:00 2001 From: Kaido Kert Date: Sun, 6 Aug 2023 16:02:19 -0700 Subject: [PATCH] Add XB1 builders and runner b/266878119 --- .github/config/win32.json | 1 + .github/config/xb1.json | 17 +++++++++++ .github/workflows/main_win.yaml | 7 +++-- .github/workflows/xb1.yaml | 32 ++++++++++++++++++++ docker-compose-windows.yml | 34 ++++++++++++++++++++++ docker/windows/runner/Dockerfile | 7 +++-- docker/windows/xb1/Dockerfile | 50 ++++++++++++++++++++++++++++++++ 7 files changed, 143 insertions(+), 5 deletions(-) create mode 100644 .github/config/xb1.json create mode 100644 .github/workflows/xb1.yaml create mode 100644 docker/windows/xb1/Dockerfile diff --git a/.github/config/win32.json b/.github/config/win32.json index 9de9f00102345..4ffbc7cbb3e3a 100644 --- a/.github/config/win32.json +++ b/.github/config/win32.json @@ -1,6 +1,7 @@ { "docker_service": "build-win-win32", "docker_runner_service": "runner-win-win32", + "runner_tag": "win32", "platforms": [ "win32" ], diff --git a/.github/config/xb1.json b/.github/config/xb1.json new file mode 100644 index 0000000000000..39918cb8d5d58 --- /dev/null +++ b/.github/config/xb1.json @@ -0,0 +1,17 @@ +{ + "docker_service": "build-xb1", + "__comment" : "TODO: Deploy a runner and change this", + "docker_runner_service": "runner-xb1", + "runner_tag": "xb1", + "platforms": [ + "xb1" + ], + "includes": [ + { + "name":"xb1", + "platform":"xb1", + "target_platform":"xb1", + "extra_gn_arguments":"is_clang=false" + } + ] +} diff --git a/.github/workflows/main_win.yaml b/.github/workflows/main_win.yaml index ea1a301a2cb38..30a8c1dc3ece9 100644 --- a/.github/workflows/main_win.yaml +++ b/.github/workflows/main_win.yaml @@ -90,6 +90,8 @@ jobs: run: echo "docker_service=$(cat ${GITHUB_WORKSPACE}/.github/config/${{ inputs.platform }}.json | jq -rc '.docker_service')" >> $GITHUB_ENV - id: set-docker-runner-service run: echo "docker_runner_service=$(cat ${GITHUB_WORKSPACE}/.github/config/${{ inputs.platform }}.json | jq -rc '.docker_runner_service')" >> $GITHUB_ENV + - id: set-runner-tag + run: echo "runner_tag=$(cat ${GITHUB_WORKSPACE}/.github/config/${{ inputs.platform }}.json | jq -rc '.runner_tag')" >> $GITHUB_ENV outputs: platforms: ${{ env.platforms }} includes: ${{ env.includes }} @@ -98,6 +100,7 @@ jobs: on_host_test_shards: ${{ env.on_host_test_shards }} docker_service: ${{ env.docker_service }} docker_runner_service: ${{ env.docker_runner_service }} + runner_tag: ${{ env.runner_tag }} # Build windows docker images. build-docker-image: needs: [initialize] @@ -130,7 +133,7 @@ jobs: build: needs: [initialize] permissions: {} - runs-on: [self-hosted, win32] + runs-on: [self-hosted, "${{ needs.initialize.outputs.runner_tag }}"] name: ${{matrix.name}}_${{matrix.config}} strategy: fail-fast: false @@ -164,7 +167,7 @@ jobs: needs: [initialize, build] permissions: {} if: needs.initialize.outputs.on_host_test == 'true' - runs-on: [self-hosted, win32] + runs-on: [self-hosted, "${{ needs.initialize.outputs.runner_tag }}"] name: ${{matrix.name}}_${{matrix.shard}}_test strategy: fail-fast: false diff --git a/.github/workflows/xb1.yaml b/.github/workflows/xb1.yaml new file mode 100644 index 0000000000000..96e37f5514eb0 --- /dev/null +++ b/.github/workflows/xb1.yaml @@ -0,0 +1,32 @@ +name: xb1 + +on: + pull_request: + types: [opened, reopened, synchronize, labeled] + branches: + - main + - feature/* + push: + branches: + - main + - feature/* + schedule: + # GTM timezone. + - cron: '0 4 * * *' + workflow_dispatch: + inputs: + nightly: + description: 'Nightly workflow.' + required: true + type: boolean + default: false + +jobs: + xb1: + uses: ./.github/workflows/main_win.yaml + permissions: + packages: write + pull-requests: write + with: + platform: xb1 + nightly: ${{ github.event.inputs.nightly }} diff --git a/docker-compose-windows.yml b/docker-compose-windows.yml index 9c6aa27a21c6c..935cc6674deca 100644 --- a/docker-compose-windows.yml +++ b/docker-compose-windows.yml @@ -97,6 +97,17 @@ services: - cobalt-build-win32-base image: cobalt-build-win-win32 + build-xb1: + <<: *common-definitions + build: + context: ./docker/windows/xb1 + dockerfile: ./Dockerfile + args: + - FROM_IMAGE=cobalt-build-win32-base + depends_on: + - cobalt-build-win32-base + image: cobalt-build-xb1 + # ----------------------------------------- # Win32 Platform Images for Building Cobalt # ----------------------------------------- @@ -115,6 +126,16 @@ services: PLATFORM: win-win32 image: cobalt-build-win32 + xb1: + <<: *common-definitions + environment: + <<: *shared-build-env + PLATFORM: xb1 + COBALT_CONCURRENT_LINKS: ${COBALT_CONCURRENT_LINKS:-2} + image: cobalt-build-xb1 + depends_on: + - build-xb1 + runner-win-win32: <<: *common-definitions build: @@ -122,6 +143,19 @@ services: dockerfile: ./Dockerfile args: - RUNNER_VERSION=2.294.0 + - FROM_IMAGE=cobalt-build-win-win32 depends_on: - cobalt-build-win32-base image: cobalt-runner-win-win32 + + runner-xb1: + <<: *common-definitions + build: + context: ./docker/windows/runner + dockerfile: ./Dockerfile + args: + - RUNNER_VERSION=2.294.0 + - FROM_IMAGE=cobalt-build-xb1 + depends_on: + - xb1 + image: cobalt-runner-xb1 diff --git a/docker/windows/runner/Dockerfile b/docker/windows/runner/Dockerfile index a49481150bbde..b8aa4ad105076 100644 --- a/docker/windows/runner/Dockerfile +++ b/docker/windows/runner/Dockerfile @@ -11,7 +11,8 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -FROM cobalt-build-win32-base +ARG FROM_IMAGE +FROM ${FROM_IMAGE} SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';$ProgressPreference='silentlyContinue';"] @@ -20,7 +21,7 @@ ARG RUNNER_VERSION RUN Invoke-WebRequest -Uri 'https://aka.ms/install-powershell.ps1' -OutFile install-powershell.ps1; \ powershell -ExecutionPolicy Unrestricted -File ./install-powershell.ps1 -AddToPath -RUN Invoke-WebRequest -Uri https://github.com/actions/runner/releases/download/v$env:RUNNER_VERSION/actions-runner-win-x64-$env:RUNNER_VERSION.zip -OutFile runner.zip; \ +RUN Invoke-WebRequest -Uri https://github.com/actions/runner/releases/download/v$env:RUNNER_VERSION/actions-runner-win-x64-$env:RUNNER_VERSION.zip -OutFile C:/runner.zip; \ Expand-Archive -Path C:/runner.zip -DestinationPath C:/actions-runner; \ Remove-Item -Path C:\runner.zip; \ setx /M PATH $(${Env:PATH} + \";${Env:ProgramFiles}\Git\bin\") @@ -31,4 +32,4 @@ RUN choco install -f -y 7zip --version=19.0 ENV TMP "C:\Users\ContainerAdministrator\AppData\Local\Temp2" ADD runner.ps1 C:/runner.ps1 -CMD ["pwsh", "-ExecutionPolicy", "Unrestricted", "-File", ".\\runner.ps1"] +CMD ["pwsh", "-ExecutionPolicy", "Unrestricted", "-File", "C:\\runner.ps1"] diff --git a/docker/windows/xb1/Dockerfile b/docker/windows/xb1/Dockerfile new file mode 100644 index 0000000000000..e4a7fd55c9ad3 --- /dev/null +++ b/docker/windows/xb1/Dockerfile @@ -0,0 +1,50 @@ +# escape=` + +# Copyright 2021 The Cobalt Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +ARG FROM_IMAGE +FROM ${FROM_IMAGE} + +SHELL ["powershell", "-ExecutionPolicy", "Unrestricted", "-Command", ` + "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +# Note: Visual Studio is installed as part of cobalt-build-win-base + +# Windows SDK +RUN Invoke-WebRequest -Uri https://go.microsoft.com/fwlink/p/?linkid=2173743 ` + -OutFile C:\win_sdk_installer.exe ; ` + Write-Host 'Installing win_sdk_installer.exe ...' ; ` + C:\win_sdk_installer.exe /ceip off /quiet /features + | Out-Null ; ` + Write-Host 'Install of win_sdk_installer.exe completed. Cleaning up ...' ; ` + Remove-Item -Force -Recurse $env:TEMP\* ; ` + Remove-Item C:\win_sdk_installer.exe + +# MSVC sdk +ARG vs_buildtools_version="15" +ARG windows_11_sdk_version="22000" +RUN Write-Host 'Downloading vs_buildtools.exe' ; ` + Invoke-WebRequest -Uri https://aka.ms/vs/${env:vs_buildtools_version}/release/vs_buildtools.exe ` + -OutFile C:\vs_buildtools.exe ; ` + Write-Host 'Installing vs_buildtools.exe ...' ;` + Start-Process -Wait -FilePath C:\vs_buildtools.exe -ArgumentList "--quiet","--wait","--norestart","--nocache","--installPath","C:\BuildTools","--add","Microsoft.VisualStudio.Component.Windows11SDK.${env:windows_11_sdk_version}","--add","Microsoft.VisualStudio.Component.VC.Redist.14.Latest" ; ` + Write-Host 'Install of vs_buildtools.exe completed. Cleaning up ...' ; ` + Remove-Item C:\vs_buildtools.exe + + +WORKDIR "C:\code" + +CMD python3 cobalt/build/gn.py -p $env:PLATFORM -c $env:CONFIG out/${env:PLATFORM}_${env:CONFIG};` + if ($?) {` + ninja $env:NINJA_FLAGS -C out/${env:PLATFORM}_$env:CONFIG $env:TARGET;` + }