<commit_before>name: "Windows MSVC"
on:
  - push
  - pull_request
jobs:
  test:
    name: Test
    strategy:
      fail-fast: false
      matrix:
        label:
          - Visual Studio 2019 x64
          - Visual Studio 2019 x86
          - Visual Studio 2017 x64
          - Visual Studio 2017 x86
        include:
          - label: Visual Studio 2019 x64
            architecture: x64
            artifact-name: vs-2019-x64
            cmake-architecture: x64
            cmake-generator: Visual Studio 16 2019
            runs-on: windows-2019
            vc-architecture: x64
            vc-toolset-version: 142
            vs-version: 2019
          - label: Visual Studio 2019 x86
            architecture: x86
            artifact-name: vs-2019-x86
            cmake-architecture: Win32
            cmake-generator: Visual Studio 16 2019
            runs-on: windows-2019
            vc-architecture: x64_x86
            vc-toolset-version: 142
            vs-version: 2019
          - label: Visual Studio 2017 x64
            architecture: x64
            artifact-name: vs-2017-x64
            cmake-generator: Visual Studio 15 2017 Win64
            runs-on: windows-2016
            vc-architecture: x64
            vc-toolset-version: 141
            vs-version: 2017
          - label: Visual Studio 2017 x86
            architecture: x86
            artifact-name: vs-2017-x86
            cmake-generator: Visual Studio 15 2017
            runs-on: windows-2016
            vc-architecture: x64_x86
            vc-toolset-version: 141
            vs-version: 2017
    runs-on: ${{ matrix.runs-on }}
    steps:
      - name: Disable crash dialog
        run: |
          reg add "HKCU\SOFTWARE\Microsoft\Windows\Windows Error Reporting" `
            /v DontShowUI `
            /t REG_DWORD `
            /d 1 `
            /f
      - name: Use JST
        run: |
          Set-TimeZone -Id "Tokyo Standard Time"
      - uses: actions/setup-ruby@v1
      - uses: actions/checkout@v2
        with:
          submodules: recursive
      - name: Download bundled packages
        run: |
          cd vendor
          ruby download_groonga_normalizer_mysql.rb
          ruby download_lz4.rb
          ruby download_mecab.rb
          ruby download_message_pack.rb
          ruby download_rapidjson.rb
      - name: Set environments
        run: |
          Write-Output "::set-env name=CMAKE_BUILD_PARALLEL_LEVEL::${Env:NUMBER_OF_PROCESSORS}"

          $GROONGA_VERSION = (Get-Content base_version)
          if (!("${Env:GITHUB_REF}".StartsWith("refs/tags/"))) {
            $GROONGA_VERSION += "-$(${Env:GITHUB_SHA}.Substring(0, 7))"
          }
          Write-Output "::set-env name=GROONGA_VERSION::${GROONGA_VERSION}"

          $INSTALL_FOLDER = "groonga-${GROONGA_VERSION}-${{ matrix.architecture }}-vs${{ matrix.vs-version }}"
          $INSTALL_FOLDER_WITH_VCRUNTIME = "${INSTALL_FOLDER}-with-vcruntime"
          # TODO: We need to change system locale to ja-JP to test installing
          # to multibyte path works well but we can't change system locale
          # to ja-JP on GitHub Actions...
          # $INSTALL_PARENT_FOLDER = "インストール"
          $INSTALL_PARENT_FOLDER = "install"
          $FULL_INSTALL_FOLDER = `
            "${Env:GITHUB_WORKSPACE}\${INSTALL_PARENT_FOLDER}\${INSTALL_FOLDER}"
          Write-Output "::set-env name=INSTALL_FOLDER::${INSTALL_FOLDER}"
          Write-Output "::set-env name=INSTALL_FOLDER_WITH_VCRUNTIME::${INSTALL_FOLDER_WITH_VCRUNTIME}"
          Write-Output "::set-env name=FULL_INSTALL_FOLDER::${FULL_INSTALL_FOLDER}"

          $VC_PREFIX = "C:\Program Files (x86)\Microsoft Visual Studio\${{ matrix.vs-version }}\Enterprise\VC"
          Write-Output "::set-env name=VC_PREFIX::${VC_PREFIX}"
      - name: Set version
        run: |
          "GRN_VERSION=${Env:GROONGA_VERSION}" | Set-Content version.sh
      - name: Install Apache Arrow
        if: |
          matrix.architecture == 'x64'
        run: |
          New-Item ..\apache-arrow-build -ItemType Directory
          $CMAKE_ARGS = (
            "-S", "vendor\apache-arrow-source\cpp",
            "-B", "..\apache-arrow-build",
            "-G", "${{ matrix.cmake-generator }}",
            "-DARROW_VERBOSE_THIRDPARTY_BUILD=ON",
            "-DBOOST_SOURCE=BUNDLED",
            "-DCMAKE_BUILD_TYPE=Release",
            "-DCMAKE_INSTALL_PREFIX=${Env:FULL_INSTALL_FOLDER}"
          )
          if ("${{ matrix.cmake-architecture }}" -ne "") {
            $CMAKE_ARGS += ("-A", "${{ matrix.cmake-architecture }}")
          }
          cmake ${CMAKE_ARGS}
          cmake --build ..\apache-arrow-build --config Release
          cmake --build ..\apache-arrow-build --config Release --target Install
      - name: Install dependencies
        run: |
          choco install -y winflexbison3
      - name: Install Groonga
        shell: cmd
        run: |
          set YACC="win_bison.exe"
          call "%VC_PREFIX%\Auxiliary\Build\vcvarsall.bat" ${{ matrix.vc-architecture }}
          mkdir ..\groonga-build
          set CMAKE_ARGS=-S .
          set CMAKE_ARGS=%CMAKE_ARGS% -B ..\groonga-build
          if not "${{ matrix.cmake-architecture }}" == "" (
            set CMAKE_ARGS=%CMAKE_ARGS% -A ${{ matrix.cmake-architecture }}
          )
          set CMAKE_ARGS=%CMAKE_ARGS% -G "${{ matrix.cmake-generator }}"
          set CMAKE_ARGS=%CMAKE_ARGS% "-DCMAKE_INSTALL_PREFIX=%FULL_INSTALL_FOLDER%"
          set CMAKE_ARGS=%CMAKE_ARGS% -DCMAKE_BUILD_TYPE=RelWithDebInfo
          if "${{ matrix.architecture }}" == "x64" (
            set CMAKE_ARGS=%CMAKE_ARGS% -DGRN_WITH_APACHE_ARROW=yes
          )
          set CMAKE_ARGS=%CMAKE_ARGS% -DGRN_WITH_MRUBY=yes
          cmake %CMAKE_ARGS%
          type ..\groonga-build\CMakeFiles\CMakeError.log
          cmake --build ..\groonga-build --config RelWithDebInfo
          cmake --build ..\groonga-build --config RelWithDebInfo --target Install

      # Artifact
      - name: Prepare artifacts without VC++ runtime
        run: |
          New-Item artifacts -ItemType Directory
          pushd "${Env:FULL_INSTALL_FOLDER}\.."
          Compress-Archive `
            -Path "${Env:INSTALL_FOLDER}" `
            -DestinationPath "${Env:GITHUB_WORKSPACE}\artifacts\${Env:INSTALL_FOLDER}.zip"
          popd
      - uses: actions/upload-artifact@v2
        with:
          name: ${{ matrix.artifact-name }}
          path: artifacts
      - name: Prepare artifacts with VC++ runtime
        run: |
          Set-PSDebug -Trace 2

          New-Item artifacts-with-vcruntime -ItemType Directory
          pushd "${Env:FULL_INSTALL_FOLDER}\.."

          Copy-Item -Recurse `
             "${Env:INSTALL_FOLDER}" `
             "${Env:INSTALL_FOLDER_WITH_VCRUNTIME}"
          $GROONGA_VC_REDIST_LICENSE_DIR = `
            "${Env:INSTALL_FOLDER_WITH_VCRUNTIME}\share\groonga\vcruntime"
          New-Item `
            -Path "${Env:GROONGA_VC_REDIST_LICENSE_DIR}" `
            -ItemType Directory

          $VC_REDIST_VERSION = (Get-Content "${Env:VC_PREFIX}\Auxiliary\Build\Microsoft.VCRedistVersion.default.txt")
          $VC_REDIST_DIR = "${Env:VC_PREFIX}\Redist\MSVC\${VC_REDIST_VERSION}\${{ matrix.architecture }}\Microsoft.VC${{ matrix.vc-toolset-version }}.CRT"
          $VC_REDIST_VCRUNTIME = "${VC_REDIST_DIR}\vcruntime140.dll"
          $VC_REDIST_VCRUNTIME_1 = "${VC_REDIST_DIR}\vcruntime140_1.dll"
          $VC_REDIST_MSVCP = "${VC_REDIST_DIR}\msvcp140.dll"
          Copy-Item `
            "${VC_REDIST_VCRUNTIME}" `
            "${Env:INSTALL_FOLDER_WITH_VCRUNTIME}\bin"
          Copy-Item `
            "${VC_REDIST_VCRUNTIME_1}" `
            "${Env:INSTALL_FOLDER_WITH_VCRUNTIME}\bin"
          Copy-Item `
            "${VC_REDIST_MSVCP}" `
            "${Env:INSTALL_FOLDER_WITH_VCRUNTIME}\bin"
          Copy-Item `
            "${Env:GITHUB_WORKSPACE}\packages\windows\vcruntime\vs${{ matrix.vs-version }}\readme.txt" `
            "${Env:GROONGA_VC_REDIST_LICENSE_DIR}"

          $UCRT_REDIST_DIR = "C:\Program Files (x86)\Windows Kits\10\Redist\ucrt\DLLs\${{ matrix.architecture }}"
          Copy-Item `
            "${UCRT_REDIST_DIR}\*.dll" `
            "${Env:INSTALL_FOLDER_WITH_VCRUNTIME}\bin"
          Copy-Item `
            "${Env:GITHUB_WORKSPACE}\packages\windows\vcruntime\ucrt-readme.txt" `
            "${Env:GROONGA_VC_REDIST_LICENSE_DIR}"

          Compress-Archive `
            -Path ${Env:INSTALL_FOLDER_WITH_VCRUNTIME} `
            -DestinationPath "${Env:GITHUB_WORKSPACE}\artifacts-with-vcruntime\${Env:INSTALL_FOLDER_WITH_VCRUNTIME}.zip"
          popd
      - uses: actions/upload-artifact@v1
        with:
          name: ${{ matrix.artifact-name }}-with-vcruntime
          path: artifacts-with-vcruntime

      # Release
      - name: Asset
        if: |
          startsWith(github.ref, 'refs/tags/')
        id: asset
        run: |
          Write-Output "::set-output name=base_name::${INSTALL_FOLDER}"
      - name: Ensure creating release
        if: |
          startsWith(github.ref, 'refs/tags/')
        id: create-release
        uses: actions/github-script@0.4.0
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          result-encoding: string
          script: |
            const AsyncFunction = Object.getPrototypeOf(async () => {}).constructor
            const fs = require("fs");
            const path = ".github/workflows/ensure-creating-release.js";
            const script = fs.readFileSync(path).toString();
            const func = new AsyncFunction("require", "github", "context", script);
            return await func(require, github, context);
      - name: Upload the artifact without VC++ runtime to release
        uses: actions/upload-release-asset@v1.0.1
        if: |
          startsWith(github.ref, 'refs/tags/')
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create-release.outputs.result }}
          asset_path: artifacts/${{ steps.asset.outputs.base_name }}.zip
          asset_name: ${{ steps.asset.outputs.base_name }}.zip
          asset_content_type: application/zip
      - name: Upload the artifact with VC++ runtime to release
        uses: actions/upload-release-asset@v1.0.1
        if: |
          startsWith(github.ref, 'refs/tags/')
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create-release.outputs.result }}
          asset_path: artifacts-with-vcruntime/${{ steps.asset.outputs.base_name }}-with-vcruntime.zip
          asset_name: ${{ steps.asset.outputs.base_name }}-with-vcruntime.zip
          asset_content_type: application/zip

      # Test
      - name: Update MSYS2
        run: |
          ridk exec pacman --sync --refresh --sysupgrade --noconfirm
      - name: Update GCC
        run: |
          ridk exec pacman --sync --noconfirm mingw-w64-x86_64-gcc
      - name: Install grntest
        run: |
          git clone --depth 1 `
            https://github.com/groonga/grntest.git `
            ..\grntest
          cd ..\grntest
          bundle install
          bundle exec ruby -rdevkit -S rake install
          gem install red-arrow
      - name: "Test: command line"
        run: |
          ruby test\command_line\run-test.rb `
            --groonga-install-prefix="${Env:FULL_INSTALL_FOLDER}"
      - name: "Test: HTTP: reference count"
        run: |
          $Env:GRN_ENABLE_REFERENCE_COUNT = "yes"
          grntest `
            --base-directory test\command `
            --groonga "${Env:FULL_INSTALL_FOLDER}\bin\groonga.exe" `
            --interface http `
            --n-retries 2 `
            --n-workers ${Env:NUMBER_OF_PROCESSORS} `
            --read-timeout 30 `
            --reporter mark `
            --timeout 60 `
            test\command\suite
      - name: "Test: HTTP: Apache Arrow: chunked"
        run: |
          grntest `
            --base-directory test\command `
            --groonga "${Env:FULL_INSTALL_FOLDER}\bin\groonga.exe" `
            --input-type apache-arrow `
            --interface http `
            --n-retries 2 `
            --n-workers ${Env:NUMBER_OF_PROCESSORS} `
            --read-timeout 30 `
            --reporter mark `
            --timeout 360 `
            --use-http-chunked `
            test\command\suite
<commit_msg>ci windows-msvc: remove needless Env:<commit_after>name: "Windows MSVC"
on:
  - push
  - pull_request
jobs:
  test:
    name: Test
    strategy:
      fail-fast: false
      matrix:
        label:
          - Visual Studio 2019 x64
          - Visual Studio 2019 x86
          - Visual Studio 2017 x64
          - Visual Studio 2017 x86
        include:
          - label: Visual Studio 2019 x64
            architecture: x64
            artifact-name: vs-2019-x64
            cmake-architecture: x64
            cmake-generator: Visual Studio 16 2019
            runs-on: windows-2019
            vc-architecture: x64
            vc-toolset-version: 142
            vs-version: 2019
          - label: Visual Studio 2019 x86
            architecture: x86
            artifact-name: vs-2019-x86
            cmake-architecture: Win32
            cmake-generator: Visual Studio 16 2019
            runs-on: windows-2019
            vc-architecture: x64_x86
            vc-toolset-version: 142
            vs-version: 2019
          - label: Visual Studio 2017 x64
            architecture: x64
            artifact-name: vs-2017-x64
            cmake-generator: Visual Studio 15 2017 Win64
            runs-on: windows-2016
            vc-architecture: x64
            vc-toolset-version: 141
            vs-version: 2017
          - label: Visual Studio 2017 x86
            architecture: x86
            artifact-name: vs-2017-x86
            cmake-generator: Visual Studio 15 2017
            runs-on: windows-2016
            vc-architecture: x64_x86
            vc-toolset-version: 141
            vs-version: 2017
    runs-on: ${{ matrix.runs-on }}
    steps:
      - name: Disable crash dialog
        run: |
          reg add "HKCU\SOFTWARE\Microsoft\Windows\Windows Error Reporting" `
            /v DontShowUI `
            /t REG_DWORD `
            /d 1 `
            /f
      - name: Use JST
        run: |
          Set-TimeZone -Id "Tokyo Standard Time"
      - uses: actions/setup-ruby@v1
      - uses: actions/checkout@v2
        with:
          submodules: recursive
      - name: Download bundled packages
        run: |
          cd vendor
          ruby download_groonga_normalizer_mysql.rb
          ruby download_lz4.rb
          ruby download_mecab.rb
          ruby download_message_pack.rb
          ruby download_rapidjson.rb
      - name: Set environments
        run: |
          Write-Output "::set-env name=CMAKE_BUILD_PARALLEL_LEVEL::${Env:NUMBER_OF_PROCESSORS}"

          $GROONGA_VERSION = (Get-Content base_version)
          if (!("${Env:GITHUB_REF}".StartsWith("refs/tags/"))) {
            $GROONGA_VERSION += "-$(${Env:GITHUB_SHA}.Substring(0, 7))"
          }
          Write-Output "::set-env name=GROONGA_VERSION::${GROONGA_VERSION}"

          $INSTALL_FOLDER = "groonga-${GROONGA_VERSION}-${{ matrix.architecture }}-vs${{ matrix.vs-version }}"
          $INSTALL_FOLDER_WITH_VCRUNTIME = "${INSTALL_FOLDER}-with-vcruntime"
          # TODO: We need to change system locale to ja-JP to test installing
          # to multibyte path works well but we can't change system locale
          # to ja-JP on GitHub Actions...
          # $INSTALL_PARENT_FOLDER = "インストール"
          $INSTALL_PARENT_FOLDER = "install"
          $FULL_INSTALL_FOLDER = `
            "${Env:GITHUB_WORKSPACE}\${INSTALL_PARENT_FOLDER}\${INSTALL_FOLDER}"
          Write-Output "::set-env name=INSTALL_FOLDER::${INSTALL_FOLDER}"
          Write-Output "::set-env name=INSTALL_FOLDER_WITH_VCRUNTIME::${INSTALL_FOLDER_WITH_VCRUNTIME}"
          Write-Output "::set-env name=FULL_INSTALL_FOLDER::${FULL_INSTALL_FOLDER}"

          $VC_PREFIX = "C:\Program Files (x86)\Microsoft Visual Studio\${{ matrix.vs-version }}\Enterprise\VC"
          Write-Output "::set-env name=VC_PREFIX::${VC_PREFIX}"
      - name: Set version
        run: |
          "GRN_VERSION=${Env:GROONGA_VERSION}" | Set-Content version.sh
      - name: Install Apache Arrow
        if: |
          matrix.architecture == 'x64'
        run: |
          New-Item ..\apache-arrow-build -ItemType Directory
          $CMAKE_ARGS = (
            "-S", "vendor\apache-arrow-source\cpp",
            "-B", "..\apache-arrow-build",
            "-G", "${{ matrix.cmake-generator }}",
            "-DARROW_VERBOSE_THIRDPARTY_BUILD=ON",
            "-DBOOST_SOURCE=BUNDLED",
            "-DCMAKE_BUILD_TYPE=Release",
            "-DCMAKE_INSTALL_PREFIX=${Env:FULL_INSTALL_FOLDER}"
          )
          if ("${{ matrix.cmake-architecture }}" -ne "") {
            $CMAKE_ARGS += ("-A", "${{ matrix.cmake-architecture }}")
          }
          cmake ${CMAKE_ARGS}
          cmake --build ..\apache-arrow-build --config Release
          cmake --build ..\apache-arrow-build --config Release --target Install
      - name: Install dependencies
        run: |
          choco install -y winflexbison3
      - name: Install Groonga
        shell: cmd
        run: |
          set YACC="win_bison.exe"
          call "%VC_PREFIX%\Auxiliary\Build\vcvarsall.bat" ${{ matrix.vc-architecture }}
          mkdir ..\groonga-build
          set CMAKE_ARGS=-S .
          set CMAKE_ARGS=%CMAKE_ARGS% -B ..\groonga-build
          if not "${{ matrix.cmake-architecture }}" == "" (
            set CMAKE_ARGS=%CMAKE_ARGS% -A ${{ matrix.cmake-architecture }}
          )
          set CMAKE_ARGS=%CMAKE_ARGS% -G "${{ matrix.cmake-generator }}"
          set CMAKE_ARGS=%CMAKE_ARGS% "-DCMAKE_INSTALL_PREFIX=%FULL_INSTALL_FOLDER%"
          set CMAKE_ARGS=%CMAKE_ARGS% -DCMAKE_BUILD_TYPE=RelWithDebInfo
          if "${{ matrix.architecture }}" == "x64" (
            set CMAKE_ARGS=%CMAKE_ARGS% -DGRN_WITH_APACHE_ARROW=yes
          )
          set CMAKE_ARGS=%CMAKE_ARGS% -DGRN_WITH_MRUBY=yes
          cmake %CMAKE_ARGS%
          type ..\groonga-build\CMakeFiles\CMakeError.log
          cmake --build ..\groonga-build --config RelWithDebInfo
          cmake --build ..\groonga-build --config RelWithDebInfo --target Install

      # Artifact
      - name: Prepare artifacts without VC++ runtime
        run: |
          New-Item artifacts -ItemType Directory
          pushd "${Env:FULL_INSTALL_FOLDER}\.."
          Compress-Archive `
            -Path "${Env:INSTALL_FOLDER}" `
            -DestinationPath "${Env:GITHUB_WORKSPACE}\artifacts\${Env:INSTALL_FOLDER}.zip"
          popd
      - uses: actions/upload-artifact@v2
        with:
          name: ${{ matrix.artifact-name }}
          path: artifacts
      - name: Prepare artifacts with VC++ runtime
        run: |
          Set-PSDebug -Trace 2

          New-Item artifacts-with-vcruntime -ItemType Directory
          pushd "${Env:FULL_INSTALL_FOLDER}\.."

          Copy-Item -Recurse `
             "${Env:INSTALL_FOLDER}" `
             "${Env:INSTALL_FOLDER_WITH_VCRUNTIME}"
          $GROONGA_VC_REDIST_LICENSE_DIR = `
            "${Env:INSTALL_FOLDER_WITH_VCRUNTIME}\share\groonga\vcruntime"
          New-Item `
            -Path "${GROONGA_VC_REDIST_LICENSE_DIR}" `
            -ItemType Directory

          $VC_REDIST_VERSION = (Get-Content "${Env:VC_PREFIX}\Auxiliary\Build\Microsoft.VCRedistVersion.default.txt")
          $VC_REDIST_DIR = "${Env:VC_PREFIX}\Redist\MSVC\${VC_REDIST_VERSION}\${{ matrix.architecture }}\Microsoft.VC${{ matrix.vc-toolset-version }}.CRT"
          $VC_REDIST_VCRUNTIME = "${VC_REDIST_DIR}\vcruntime140.dll"
          $VC_REDIST_VCRUNTIME_1 = "${VC_REDIST_DIR}\vcruntime140_1.dll"
          $VC_REDIST_MSVCP = "${VC_REDIST_DIR}\msvcp140.dll"
          Copy-Item `
            "${VC_REDIST_VCRUNTIME}" `
            "${Env:INSTALL_FOLDER_WITH_VCRUNTIME}\bin"
          Copy-Item `
            "${VC_REDIST_VCRUNTIME_1}" `
            "${Env:INSTALL_FOLDER_WITH_VCRUNTIME}\bin"
          Copy-Item `
            "${VC_REDIST_MSVCP}" `
            "${Env:INSTALL_FOLDER_WITH_VCRUNTIME}\bin"
          Copy-Item `
            "${Env:GITHUB_WORKSPACE}\packages\windows\vcruntime\vs${{ matrix.vs-version }}\readme.txt" `
            "${Env:GROONGA_VC_REDIST_LICENSE_DIR}"

          $UCRT_REDIST_DIR = "C:\Program Files (x86)\Windows Kits\10\Redist\ucrt\DLLs\${{ matrix.architecture }}"
          Copy-Item `
            "${UCRT_REDIST_DIR}\*.dll" `
            "${Env:INSTALL_FOLDER_WITH_VCRUNTIME}\bin"
          Copy-Item `
            "${Env:GITHUB_WORKSPACE}\packages\windows\vcruntime\ucrt-readme.txt" `
            "${Env:GROONGA_VC_REDIST_LICENSE_DIR}"

          Compress-Archive `
            -Path ${Env:INSTALL_FOLDER_WITH_VCRUNTIME} `
            -DestinationPath "${Env:GITHUB_WORKSPACE}\artifacts-with-vcruntime\${Env:INSTALL_FOLDER_WITH_VCRUNTIME}.zip"
          popd
      - uses: actions/upload-artifact@v1
        with:
          name: ${{ matrix.artifact-name }}-with-vcruntime
          path: artifacts-with-vcruntime

      # Release
      - name: Asset
        if: |
          startsWith(github.ref, 'refs/tags/')
        id: asset
        run: |
          Write-Output "::set-output name=base_name::${INSTALL_FOLDER}"
      - name: Ensure creating release
        if: |
          startsWith(github.ref, 'refs/tags/')
        id: create-release
        uses: actions/github-script@0.4.0
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          result-encoding: string
          script: |
            const AsyncFunction = Object.getPrototypeOf(async () => {}).constructor
            const fs = require("fs");
            const path = ".github/workflows/ensure-creating-release.js";
            const script = fs.readFileSync(path).toString();
            const func = new AsyncFunction("require", "github", "context", script);
            return await func(require, github, context);
      - name: Upload the artifact without VC++ runtime to release
        uses: actions/upload-release-asset@v1.0.1
        if: |
          startsWith(github.ref, 'refs/tags/')
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create-release.outputs.result }}
          asset_path: artifacts/${{ steps.asset.outputs.base_name }}.zip
          asset_name: ${{ steps.asset.outputs.base_name }}.zip
          asset_content_type: application/zip
      - name: Upload the artifact with VC++ runtime to release
        uses: actions/upload-release-asset@v1.0.1
        if: |
          startsWith(github.ref, 'refs/tags/')
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create-release.outputs.result }}
          asset_path: artifacts-with-vcruntime/${{ steps.asset.outputs.base_name }}-with-vcruntime.zip
          asset_name: ${{ steps.asset.outputs.base_name }}-with-vcruntime.zip
          asset_content_type: application/zip

      # Test
      - name: Update MSYS2
        run: |
          ridk exec pacman --sync --refresh --sysupgrade --noconfirm
      - name: Update GCC
        run: |
          ridk exec pacman --sync --noconfirm mingw-w64-x86_64-gcc
      - name: Install grntest
        run: |
          git clone --depth 1 `
            https://github.com/groonga/grntest.git `
            ..\grntest
          cd ..\grntest
          bundle install
          bundle exec ruby -rdevkit -S rake install
          gem install red-arrow
      - name: "Test: command line"
        run: |
          ruby test\command_line\run-test.rb `
            --groonga-install-prefix="${Env:FULL_INSTALL_FOLDER}"
      - name: "Test: HTTP: reference count"
        run: |
          $Env:GRN_ENABLE_REFERENCE_COUNT = "yes"
          grntest `
            --base-directory test\command `
            --groonga "${Env:FULL_INSTALL_FOLDER}\bin\groonga.exe" `
            --interface http `
            --n-retries 2 `
            --n-workers ${Env:NUMBER_OF_PROCESSORS} `
            --read-timeout 30 `
            --reporter mark `
            --timeout 60 `
            test\command\suite
      - name: "Test: HTTP: Apache Arrow: chunked"
        run: |
          grntest `
            --base-directory test\command `
            --groonga "${Env:FULL_INSTALL_FOLDER}\bin\groonga.exe" `
            --input-type apache-arrow `
            --interface http `
            --n-retries 2 `
            --n-workers ${Env:NUMBER_OF_PROCESSORS} `
            --read-timeout 30 `
            --reporter mark `
            --timeout 360 `
            --use-http-chunked `
            test\command\suite

{'fraction_non_alphanumeric': 0.11897261933607947, 'fraction_numerical': 0.018253775947015587, 'mean_word_length': 1.8820996275605215, 'pattern_counts': {'":': 14, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6939897', 'n_tokens_mistral': 8273, 'n_tokens_neox': 7650, 'n_words': 1414}