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

windows-2016 Azure Pipelines environment is deprecated #4748

Closed
StrikerRUS opened this issue Oct 29, 2021 · 19 comments · Fixed by #5059 or #5079
Closed

windows-2016 Azure Pipelines environment is deprecated #4748

StrikerRUS opened this issue Oct 29, 2021 · 19 comments · Fixed by #5059 or #5079

Comments

@StrikerRUS
Copy link
Collaborator

StrikerRUS commented Oct 29, 2021

The windows-2016 environment will be deprecated on November 15, 2021, and removed on March 15, 2022. Migrate to windows-latest instead. For more details see actions/runner-images#4312

We use this environment here

vmImage: 'vs2017-win2016'

The main problem is that that environment is used right now to create release artifacts: LightGBM executable, dll, SWIG jar and win_amd64 Python wheel file.

LightGBM/.vsts-ci.yml

Lines 287 to 288 in 96ecab6

- task: PublishBuildArtifacts@1
condition: and(succeeded(), in(variables['TASK'], 'regular', 'bdist', 'swig'), not(startsWith(variables['Build.SourceBranch'], 'refs/pull/')))

So we should be careful during migration to not accidentally change LightGBM installation requirements (refer to #1708, #2889 as an examples of problems we may face).

@jameslamb
Copy link
Collaborator

Thanks for noticing and documenting this.

The main problem is that that environment is used right now to create release artifacts...So we should be careful during migration to not accidentally change LightGBM installation requirements

Do you think that between now and March 15, 2022 we should try to move generation of these artifacts into Windows containers? So that future changes in these VM images will be less impactful?

(linking relevant comment #3469 (comment))

@StrikerRUS
Copy link
Collaborator Author

That would be great!
Just one thing I'm afraid of is that Windows containers is not something common and we may face weird issues that will nobody know how to fix/workaround. But if we succeed, it will be a great step for many our CI jobs.

@StrikerRUS
Copy link
Collaborator Author

Example of Windows containers with LightGBM installation from PyPI:
microsoft/lightgbm-benchmark@f4c79cb

@jameslamb
Copy link
Collaborator

!!!! Awesome. Glad our friends over there already did so much of the hard work 😛

@jameslamb
Copy link
Collaborator

I just received an email from GitHub. To alert projects about this deprecation, they are going to perform two "brown outs" (temporary planned outages).

In preparation for the deprecation, there are two scheduled brownout periods for our team to perform maintenance:
December 1, 2021: 4:00pm–10:00pm UTC
February 7, 2022: 4:00pm–10:00pm UTC
Jobs that use Windows 2016 scheduled to run during this time will temporarily fail.

@jameslamb
Copy link
Collaborator

I think this notice explains why we just started observing some failures in the R-package (windows-2016) jobs.

e.g. https://github.com/microsoft/LightGBM/runs/4384271108?check_suite_focus=true

image

It's currently 5:11p UTC, so for the next 5 hours this project's CI will be blocked by this 😬

@StrikerRUS
Copy link
Collaborator Author

The main problem I see with Windows containers is Visual Studio Build Tools. We need it to compile LightGBM. Yesterday I played with Windows Docker for GitHub Actions and learned some interesting things.

Quotes for strings in env file are part of a value.

There is no special handling of quotation marks. This means that they are part of the VAL.
https://docs.docker.com/compose/env-file/#syntax-rules

There should be ./ for Start-Process -FilePath argument to avoid The system cannot find the file specified. error
https://stackoverflow.com/a/49074555

In DOTNET methods current working directory doesn't match one set by PowerShell commandlet.
https://stackoverflow.com/a/11248149

There are a lot of restrictions on Host and client versions of Windows:
https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/version-compatibility

GitHub Actions doesn't support containers out of the box on Windows and macOS runners. And there are no plans for adding support.
actions/runner#904 (comment)

There are no official images with installed Visual Studio:

In short, we have no plans to publish such an image.
https://devblogs.microsoft.com/setup/no-container-image-for-build-tools-for-visual-studio-2017/

I'd like to post my current progress here - maybe it would be helpful to someone.

diff --git a/.ci/test_r_package_windows.ps1 b/.ci/test_r_package_windows.ps1
index 62562b47..1915d203 100644
--- a/.ci/test_r_package_windows.ps1
+++ b/.ci/test_r_package_windows.ps1
@@ -65,6 +65,7 @@ Remove-Item C:\rtools40 -Force -Recurse -ErrorAction Ignore
 # NOTES:
 #    * some paths and file names are different on R4.0
 $env:R_MAJOR_VERSION = $env:R_VERSION.split('.')[0]
+$env:PANDOC_VERSION = "2.16.2"
 if ($env:R_MAJOR_VERSION -eq "3") {
   # Rtools 3.x has to be installed at C:\Rtools\
   #     * https://stackoverflow.com/a/46619260/3986677
@@ -86,7 +87,7 @@ if ($env:R_MAJOR_VERSION -eq "3") {
 
 $env:R_LIB_PATH = "$env:BUILD_SOURCESDIRECTORY/RLibrary" -replace '[\\]', '/'
 $env:R_LIBS = "$env:R_LIB_PATH"
-$env:PATH = "$env:RTOOLS_BIN;" + "$env:RTOOLS_MINGW_BIN;" + "$env:R_LIB_PATH/R/bin/x64;" + "$env:R_LIB_PATH/miktex/texmfs/install/miktex/bin/x64;" + $env:PATH
+$env:PATH = "$env:RTOOLS_BIN;" + "$env:RTOOLS_MINGW_BIN;" + "$env:R_LIB_PATH/R/bin/x64;" + "$env:R_LIB_PATH/miktex/texmfs/install/miktex/bin/x64;" + "$env:BUILD_SOURCESDIRECTORY/pandoc/pandoc-$env:PANDOC_VERSION;" + $env:PATH
 $env:CRAN_MIRROR = "https://cloud.r-project.org/"
 $env:CTAN_MIRROR = "https://ctan.math.illinois.edu/systems/win32/miktex"
 $env:CTAN_PACKAGE_ARCHIVE = "$env:CTAN_MIRROR/tm/packages/"
@@ -102,7 +103,6 @@ if (($env:COMPILER -eq "MINGW") -and ($env:R_BUILD_TYPE -eq "cmake")) {
   $env:CXX = "$env:RTOOLS_MINGW_BIN/g++.exe"
   $env:CC = "$env:RTOOLS_MINGW_BIN/gcc.exe"
 }
-
 cd $env:BUILD_SOURCESDIRECTORY
 tzutil /s "GMT Standard Time"
 [Void][System.IO.Directory]::CreateDirectory($env:R_LIB_PATH)
@@ -114,11 +114,11 @@ Download-File-With-Retries -url "https://github.com/microsoft/LightGBM/releases/
 
 # Install R
 Write-Output "Installing R"
-Start-Process -FilePath R-win.exe -NoNewWindow -Wait -ArgumentList "/VERYSILENT /DIR=$env:R_LIB_PATH/R /COMPONENTS=main,x64,i386" ; Check-Output $?
+Start-Process -FilePath ./R-win.exe -NoNewWindow -Wait -ArgumentList "/VERYSILENT /DIR=$env:R_LIB_PATH/R /COMPONENTS=main,x64,i386" ; Check-Output $?
 Write-Output "Done installing R"
 
 Write-Output "Installing Rtools"
-Start-Process -FilePath Rtools.exe -NoNewWindow -Wait -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /DIR=$RTOOLS_INSTALL_PATH" ; Check-Output $?
+Start-Process -FilePath ./Rtools.exe -NoNewWindow -Wait -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /DIR=$RTOOLS_INSTALL_PATH" ; Check-Output $?
 Write-Output "Done installing Rtools"
 
 Write-Output "Installing dependencies"
@@ -132,7 +132,7 @@ Run-R-Code-Redirect-Stderr "options(install.packages.check.source = 'no'); insta
 if (($env:COMPILER -eq "MINGW") -or ($env:R_BUILD_TYPE -eq "cran")) {
     Download-File-With-Retries "https://github.com/microsoft/LightGBM/releases/download/v2.0.12/miktexsetup-4.0-x64.zip" -destfile "miktexsetup-x64.zip"
     Add-Type -AssemblyName System.IO.Compression.FileSystem
-    [System.IO.Compression.ZipFile]::ExtractToDirectory("miktexsetup-x64.zip", "miktex")
+    [System.IO.Compression.ZipFile]::ExtractToDirectory("$env:BUILD_SOURCESDIRECTORY/miktexsetup-x64.zip", "$env:BUILD_SOURCESDIRECTORY/miktex")
     Write-Output "Setting up MiKTeX"
     .\miktex\miktexsetup.exe --remote-package-repository="$env:CTAN_PACKAGE_ARCHIVE" --local-package-repository=./miktex/download --package-set=essential --quiet download ; Check-Output $?
     Write-Output "Installing MiKTeX"
@@ -140,6 +140,9 @@ if (($env:COMPILER -eq "MINGW") -or ($env:R_BUILD_TYPE -eq "cran")) {
     Write-Output "Done installing MiKTeX"
 
     Run-R-Code-Redirect-Stderr "result <- processx::run(command = 'initexmf', args = c('--set-config-value', '[MPM]AutoInstall=1'), echo = TRUE, windows_verbatim_args = TRUE, error_on_status = TRUE)" ; Check-Output $?
+
+    Download-File-With-Retries -url "https://github.com/jgm/pandoc/releases/download/$env:PANDOC_VERSION/pandoc-$env:PANDOC_VERSION-windows-x86_64.zip" -destfile "pandoc-windows-x86_64.zip"
+    [System.IO.Compression.ZipFile]::ExtractToDirectory("$env:BUILD_SOURCESDIRECTORY/pandoc-windows-x86_64.zip", "$env:BUILD_SOURCESDIRECTORY/pandoc")
 }
 
 Write-Output "Building R package"
diff --git a/.github/workflows/r_package.yml b/.github/workflows/r_package.yml
index b2e16261..20ae9c6e 100644
--- a/.github/workflows/r_package.yml
+++ b/.github/workflows/r_package.yml
@@ -3,7 +3,7 @@ name: R-package
 on:
   push:
     branches:
-    - master
+    - win_docker
   pull_request:
     branches:
     - master
@@ -32,52 +32,6 @@ jobs:
           ################
           # CMake builds #
           ################
-          - os: ubuntu-latest
-            task: r-package
-            compiler: gcc
-            r_version: 3.6
-            build_type: cmake
-          - os: ubuntu-latest
-            task: r-package
-            compiler: gcc
-            r_version: 4.0
-            build_type: cmake
-          - os: ubuntu-latest
-            task: r-package
-            compiler: clang
-            r_version: 3.6
-            build_type: cmake
-          - os: ubuntu-latest
-            task: r-package
-            compiler: clang
-            r_version: 4.0
-            build_type: cmake
-          - os: macOS-latest
-            task: r-package
-            compiler: gcc
-            r_version: 3.6
-            build_type: cmake
-          - os: macOS-latest
-            task: r-package
-            compiler: gcc
-            r_version: 4.0
-            build_type: cmake
-          - os: macOS-latest
-            task: r-package
-            compiler: clang
-            r_version: 3.6
-            build_type: cmake
-          - os: macOS-latest
-            task: r-package
-            compiler: clang
-            r_version: 4.0
-            build_type: cmake
-          - os: windows-latest
-            task: r-package
-            compiler: MINGW
-            toolchain: MINGW
-            r_version: 3.6
-            build_type: cmake
           - os: windows-latest
             task: r-package
             compiler: MINGW
@@ -85,26 +39,12 @@ jobs:
             r_version: 4.0
             build_type: cmake
           # Visual Studio 2017
-          - os: windows-2016
+          - os: windows-latest
             task: r-package
             compiler: MSVC
             toolchain: MSVC
             r_version: 3.6
             build_type: cmake
-          # Visual Studio 2019
-          - os: windows-2019
-            task: r-package
-            compiler: MSVC
-            toolchain: MSVC
-            r_version: 4.0
-            build_type: cmake
-          # Visual Studio 2022
-          - os: windows-2022
-            task: r-package
-            compiler: MSVC
-            toolchain: MSVC
-            r_version: 4.0
-            build_type: cmake
           ###############
           # CRAN builds #
           ###############
@@ -114,30 +54,6 @@ jobs:
             toolchain: MINGW
             r_version: 3.6
             build_type: cran
-          - os: windows-latest
-            task: r-package
-            compiler: MINGW
-            toolchain: MSYS
-            r_version: 4.0
-            build_type: cran
-          - os: ubuntu-latest
-            task: r-package
-            compiler: gcc
-            r_version: 4.0
-            build_type: cran
-          - os: macOS-latest
-            task: r-package
-            compiler: clang
-            r_version: 4.0
-            build_type: cran
-          ################
-          # Other checks #
-          ################
-          - os: ubuntu-latest
-            task: r-rchk
-            compiler: gcc
-            r_version: 4.0
-            build_type: cran
     steps:
       - name: Prevent conversion of line endings on Windows
         if: startsWith(matrix.os, 'windows')
@@ -150,99 +66,28 @@ jobs:
           submodules: true
       - name: Install pandoc
         uses: r-lib/actions/setup-pandoc@v1
-      - name: Setup and run tests on Linux and macOS
-        if: matrix.os == 'macOS-latest' || matrix.os == 'ubuntu-latest'
-        shell: bash
-        run: |
-          export TASK="${{ matrix.task }}"
-          export COMPILER="${{ matrix.compiler }}"
-          export GITHUB_ACTIONS="true"
-          if [[ "${{ matrix.os }}" == "macOS-latest" ]]; then
-              export OS_NAME="macos"
-          elif [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
-              export OS_NAME="linux"
-          fi
-          export BUILD_DIRECTORY="$GITHUB_WORKSPACE"
-          export R_VERSION="${{ matrix.r_version }}"
-          export R_BUILD_TYPE="${{ matrix.build_type }}"
-          $GITHUB_WORKSPACE/.ci/setup.sh
-          $GITHUB_WORKSPACE/.ci/test.sh
       - name: Setup and run tests on Windows
-        if: startsWith(matrix.os, 'windows')
-        shell: pwsh -command ". {0}"
         run: |
-          $env:BUILD_SOURCESDIRECTORY = $env:GITHUB_WORKSPACE
-          $env:TOOLCHAIN = "${{ matrix.toolchain }}"
-          $env:R_VERSION = "${{ matrix.r_version }}"
-          $env:R_BUILD_TYPE = "${{ matrix.build_type }}"
-          $env:COMPILER = "${{ matrix.compiler }}"
-          $env:GITHUB_ACTIONS = "true"
-          $env:TASK = "${{ matrix.task }}"
-          & "$env:GITHUB_WORKSPACE/.ci/test_windows.ps1"
-  test-r-sanitizers:
-    name: r-sanitizers (ubuntu-latest, R-devel, ${{ matrix.compiler }} ASAN/UBSAN)
-    timeout-minutes: 60
-    runs-on: ubuntu-latest
-    container: wch1/r-debug
-    strategy:
-      fail-fast: false
-      matrix:
-        include:
-          - r_customization: san
-            compiler: gcc
-          - r_customization: csan
-            compiler: clang
-    steps:
-      - name: Checkout repository
-        uses: actions/checkout@v2.4.0
-        with:
-          fetch-depth: 5
-          submodules: true
-      - name: Install packages
-        shell: bash
-        run: |
-          RDscript${{ matrix.r_customization }} -e "install.packages(c('R6', 'data.table', 'jsonlite', 'knitr', 'Matrix', 'rmarkdown', 'testthat'), repos = 'https://cran.r-project.org', Ncpus = parallel::detectCores())"
-          sh build-cran-package.sh --r-executable=RD${{ matrix.r_customization }}
-          RD${{ matrix.r_customization }} CMD INSTALL lightgbm_*.tar.gz || exit -1
-      - name: Run tests with sanitizers
-        shell: bash
-        run: |
-          cd R-package/tests
-          exit_code=0
-          RDscript${{ matrix.r_customization }} testthat.R >> tests.log 2>&1 || exit_code=-1
-          cat ./tests.log
-          exit ${exit_code}
-  test-r-debian-clang:
-    name: r-package (debian, R-devel, clang)
-    timeout-minutes: 60
-    runs-on: ubuntu-latest
-    container: rhub/debian-clang-devel
-    steps:
-      - name: Install Git before checkout
-        shell: bash
-        run: |
-          apt-get update --allow-releaseinfo-change
-          apt-get install --no-install-recommends -y git
-      - name: Checkout repository
-        uses: actions/checkout@v2.4.0
-        with:
-          fetch-depth: 5
-          submodules: true
-      - name: Install packages and run tests
-        shell: bash
-        run: |
-          export PATH=/opt/R-devel/bin/:${PATH}
-          Rscript -e "install.packages(c('R6', 'data.table', 'jsonlite', 'knitr', 'Matrix', 'rmarkdown', 'testthat'), repos = 'https://cran.r-project.org', Ncpus = parallel::detectCores())"
-          sh build-cran-package.sh
-          R CMD check --as-cran --run-donttest lightgbm_*.tar.gz || exit -1
-          if grep -q -E "NOTE|WARNING|ERROR" lightgbm.Rcheck/00check.log; then
-              echo "NOTEs, WARNINGs, or ERRORs have been found by R CMD check"
-              exit -1
-          fi
-  all-successful:
-    # https://github.community/t/is-it-possible-to-require-all-github-actions-tasks-to-pass-without-enumerating-them/117957/4?u=graingert
-    runs-on: ubuntu-latest
-    needs: [test, test-r-sanitizers, test-r-debian-clang]
-    steps:
-    - name: Note that all tests succeeded
-      run: echo "🎉"
+          $ROOT_DOCKER_FOLDER = "C:/LightGBM"
+          @"
+          BUILD_SOURCESDIRECTORY=$ROOT_DOCKER_FOLDER
+          TOOLCHAIN=${{ matrix.toolchain }}
+          R_VERSION=${{ matrix.r_version }}
+          R_BUILD_TYPE=${{ matrix.build_type }}
+          COMPILER=${{ matrix.compiler }}
+          GITHUB_ACTIONS=true
+          TASK=${{ matrix.task }}
+          _R_CHECK_SYSTEM_CLOCK_=0
+          _R_CHECK_CRAN_INCOMING_REMOTE_=0
+          _R_CHECK_PKG_SIZES_THRESHOLD_=100
+          "@ | Out-File -FilePath docker.env
+          docker run `
+            --rm `
+            --env-file docker.env `
+            -v "${{ github.workspace }}:$ROOT_DOCKER_FOLDER" `
+            "mcr.microsoft.com/windows/servercore:ltsc2019-amd64" `
+            powershell `
+              -NoProfile `
+              -NonInteractive `
+              -ExecutionPolicy Bypass `
+              -File "$ROOT_DOCKER_FOLDER/.ci/test_windows.ps1"

Visual Studio Build Tools installation time and resulting image size is quite big. I guess our only option is to prebuild Docker images we need (for R, for Python, etc.) and publish them, let say, on GitHub Packages.
This note is not actual anymore:

Sadly it appears to be the case that Windows images are not supported by the GitHub registry
https://stackoverflow.com/a/63617457

When installing or publishing a Docker image, the Container registry supports foreign layers, such as Windows images.
https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#about-container-registry-support

For example, I can find some images with VS Tools at Docker Hub:
https://hub.docker.com/search?q=visual%20studio&type=image&operating_system=windows&page=1

@jameslamb
Copy link
Collaborator

@StrikerRUS thanks for this great investigation!

@shiyu1994 is there any opportunity for someone from Microsoft to help us with this issue of windows-2016 environment being removed from Azure pipelines?

I also want to note that @StrikerRUS if you or anyone else comes back to trying to make Windows containers work for this, since it seems like this might be a very large effort, I think Python jobs should probably be prioritized over the R ones. Unlike with the wheels published to PyPI, for the R package we don't publish any precompiled artifacts for R.

@StrikerRUS
Copy link
Collaborator Author

I think Python jobs should probably be prioritized over the R ones. Unlike with the wheels published to PyPI, for the R package we don't publish any precompiled artifacts for R.

Absolutely agree! I picked up R jobs just because we already install all necessary R stuff on the fly in our scripts (particularly, for CRAN ones). In Python jobs, we rely, for example, on pre-installed conda and CMake.

@StrikerRUS
Copy link
Collaborator Author

Just a reminder: one month left.

@shiyu1994
Copy link
Collaborator

@StrikerRUS thanks for this great investigation!

@shiyu1994 is there any opportunity for someone from Microsoft to help us with this issue of windows-2016 environment being removed from Azure pipelines?

I also want to note that @StrikerRUS if you or anyone else comes back to trying to make Windows containers work for this, since it seems like this might be a very large effort, I think Python jobs should probably be prioritized over the R ones. Unlike with the wheels published to PyPI, for the R package we don't publish any precompiled artifacts for R.

Sure. I'll search to see if there's anyone can help within the company tomorrow. Thanks for you reminder!

@StrikerRUS
Copy link
Collaborator Author

@shiyu1994

I'll search to see if there's anyone can help within the company tomorrow.

Is there any progress with it?

I guess we have to simply bump vmImage version given the lack of time.

@shiyu1994
Copy link
Collaborator

@StrikerRUS Thanks for fixing this! Great work!

@StrikerRUS
Copy link
Collaborator Author

There won't be official support for VS 2017 from GitHub team:

We are not planning to continue supporting vs2017 as soon as windows-2016 is disbanded, due to support expanses and security concerns. If one wants to continue having vs2017 they are free to install it on their own risk straight in the runtime (using self-hosted runners).
actions/runner-images#5177 (comment)

@jameslamb
Copy link
Collaborator

jameslamb commented Apr 10, 2022

😬 that puts LightGBM into a difficult situation, given that Microsoft has committed to supporting VS Code 2017 through 2027.

At https://docs.microsoft.com/en-us/visualstudio/releases/2017/vs2017-servicingarchive-vs I see the following

These products follow the Microsoft Product Lifecycle Policy of 10 years (5 years of Mainstream Support and 5 years of Extended Support), starting with the date the major product version is released to the world (RTW). For example, Visual Studio 2017 was released in 2017; its support lifecycle will end in 2027.

See https://docs.microsoft.com/en-us/lifecycle/policies/fixed#lifecycle-phases-for-products-under-the-fixed-lifecycle-policy for "the Microsoft Product Lifecycle Policy".

I guess we'll have to rely on AppVeyor to get some coverage of VS Code 2017?

https://www.appveyor.com/docs/windows-images-software/#visual-studio-2017

@StrikerRUS
Copy link
Collaborator Author

given that Microsoft has committed to supporting VS Code 2017 through 2027.

Sorry, I'm confused here. VS Code is a code editor developed by Microsoft. How is it related to the VS Studio?

Right now we are using even VS 2015 at Appveyor:

image: Visual Studio 2015

So, I guess everything is OK and no action should be taken.

@jameslamb
Copy link
Collaborator

oh sorry, I meant "VS" not "VS Code". You're absolutely right.

@jameslamb
Copy link
Collaborator

Microsoft confused me by giving those two things such similar names. I make this mistake often 😂

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity since it was closed.
To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues
including a reference to this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants