1e66f31c5Sopenharmony_ciname: CI-win
2e66f31c5Sopenharmony_ci
3e66f31c5Sopenharmony_cion:
4e66f31c5Sopenharmony_ci  pull_request:
5e66f31c5Sopenharmony_ci    paths:
6e66f31c5Sopenharmony_ci      - '**'
7e66f31c5Sopenharmony_ci      - '!docs/**'
8e66f31c5Sopenharmony_ci      - '!src/unix/**'
9e66f31c5Sopenharmony_ci      - '!.**'
10e66f31c5Sopenharmony_ci      - '.github/workflows/CI-win.yml'
11e66f31c5Sopenharmony_ci  push:
12e66f31c5Sopenharmony_ci    branches:
13e66f31c5Sopenharmony_ci      - v[0-9].*
14e66f31c5Sopenharmony_ci      - master
15e66f31c5Sopenharmony_ci
16e66f31c5Sopenharmony_cijobs:
17e66f31c5Sopenharmony_ci  build-windows:
18e66f31c5Sopenharmony_ci    runs-on: windows-${{ matrix.config.server }}
19e66f31c5Sopenharmony_ci    name: build-${{ join(matrix.config.*, '-') }}
20e66f31c5Sopenharmony_ci    strategy:
21e66f31c5Sopenharmony_ci      fail-fast: false
22e66f31c5Sopenharmony_ci      matrix:
23e66f31c5Sopenharmony_ci        config:
24e66f31c5Sopenharmony_ci          - {toolchain: Visual Studio 16 2019, arch: Win32, server: 2019}
25e66f31c5Sopenharmony_ci          - {toolchain: Visual Studio 16 2019, arch: x64, server: 2019}
26e66f31c5Sopenharmony_ci          - {toolchain: Visual Studio 17 2022, arch: Win32, server: 2022}
27e66f31c5Sopenharmony_ci          - {toolchain: Visual Studio 17 2022, arch: x64, server: 2022}
28e66f31c5Sopenharmony_ci          - {toolchain: Visual Studio 17 2022, arch: x64, server: 2022, config: ASAN}
29e66f31c5Sopenharmony_ci          - {toolchain: Visual Studio 17 2022, arch: x64, server: 2022, config: UBSAN}
30e66f31c5Sopenharmony_ci          - {toolchain: Visual Studio 17 2022, arch: arm64, server: 2022}
31e66f31c5Sopenharmony_ci    steps:
32e66f31c5Sopenharmony_ci      - uses: actions/checkout@v2
33e66f31c5Sopenharmony_ci      - name: Build
34e66f31c5Sopenharmony_ci        run:
35e66f31c5Sopenharmony_ci          cmake -S . -B build -DBUILD_TESTING=ON
36e66f31c5Sopenharmony_ci            -G "${{ matrix.config.toolchain }}" -A ${{ matrix.config.arch }}
37e66f31c5Sopenharmony_ci            ${{ matrix.config.config == 'ASAN' && '-DASAN=on -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded' ||
38e66f31c5Sopenharmony_ci                matrix.config.config == 'UBSAN' && '-DUBSAN=on' || '' }}
39e66f31c5Sopenharmony_ci
40e66f31c5Sopenharmony_ci          cmake --build build --config RelWithDebInfo
41e66f31c5Sopenharmony_ci
42e66f31c5Sopenharmony_ci          ${{ matrix.config.config == 'ASAN' && 'Copy-Item -Path "build\\*.exe" -Destination "build\\RelWithDebInfo\\"' || '' }}
43e66f31c5Sopenharmony_ci
44e66f31c5Sopenharmony_ci          ${{ matrix.config.config == 'ASAN' && 'Copy-Item -Path "build\\*.dll" -Destination "build\\RelWithDebInfo\\"' || '' }}
45e66f31c5Sopenharmony_ci
46e66f31c5Sopenharmony_ci          ls -l build
47e66f31c5Sopenharmony_ci          
48e66f31c5Sopenharmony_ci          ls -l build\\RelWithDebInfo
49e66f31c5Sopenharmony_ci      - name: platform_output_a
50e66f31c5Sopenharmony_ci        if: ${{ matrix.config.arch != 'arm64' }}
51e66f31c5Sopenharmony_ci        shell: cmd
52e66f31c5Sopenharmony_ci        run:
53e66f31c5Sopenharmony_ci          build\\RelWithDebInfo\\uv_run_tests_a.exe platform_output
54e66f31c5Sopenharmony_ci      - name: platform_output
55e66f31c5Sopenharmony_ci        if: ${{ matrix.config.arch != 'arm64' }}
56e66f31c5Sopenharmony_ci        shell: cmd
57e66f31c5Sopenharmony_ci        run:
58e66f31c5Sopenharmony_ci          build\\RelWithDebInfo\\uv_run_tests.exe platform_output
59e66f31c5Sopenharmony_ci      - name: Test
60e66f31c5Sopenharmony_ci        # only valid with libuv-master with the fix for
61e66f31c5Sopenharmony_ci        # https://github.com/libuv/leps/blob/master/005-windows-handles-not-fd.md
62e66f31c5Sopenharmony_ci        if: ${{ matrix.config.config != 'ASAN' && matrix.config.arch != 'arm64' }}
63e66f31c5Sopenharmony_ci        shell: cmd
64e66f31c5Sopenharmony_ci        run:
65e66f31c5Sopenharmony_ci          cd build
66e66f31c5Sopenharmony_ci
67e66f31c5Sopenharmony_ci          ctest -C RelWithDebInfo -V
68e66f31c5Sopenharmony_ci      - name: Test only static
69e66f31c5Sopenharmony_ci        if: ${{ matrix.config.config == 'ASAN' && matrix.config.arch != 'arm64' }}
70e66f31c5Sopenharmony_ci        shell: cmd
71e66f31c5Sopenharmony_ci        run:
72e66f31c5Sopenharmony_ci          build\\RelWithDebInfo\\uv_run_tests_a.exe
73e66f31c5Sopenharmony_ci
74e66f31c5Sopenharmony_ci  build-mingw:
75e66f31c5Sopenharmony_ci    runs-on: ubuntu-latest
76e66f31c5Sopenharmony_ci    name: build-mingw-${{ matrix.config.arch }}
77e66f31c5Sopenharmony_ci    strategy:
78e66f31c5Sopenharmony_ci      fail-fast: false
79e66f31c5Sopenharmony_ci      matrix:
80e66f31c5Sopenharmony_ci        config:
81e66f31c5Sopenharmony_ci          - {arch: i686,   server: 2022, libgcc: dw2 }
82e66f31c5Sopenharmony_ci          - {arch: x86_64, server: 2022, libgcc: seh }
83e66f31c5Sopenharmony_ci    steps:
84e66f31c5Sopenharmony_ci      - uses: actions/checkout@v3
85e66f31c5Sopenharmony_ci      - name: Install mingw32 environment
86e66f31c5Sopenharmony_ci        run: |
87e66f31c5Sopenharmony_ci          sudo apt update
88e66f31c5Sopenharmony_ci          sudo apt install mingw-w64 ninja-build -y
89e66f31c5Sopenharmony_ci      - name: Build
90e66f31c5Sopenharmony_ci        run: |
91e66f31c5Sopenharmony_ci          cmake -S . -B build -G Ninja -DHOST_ARCH=${{ matrix.config.arch }} -DBUILD_TESTING=ON -DCMAKE_TOOLCHAIN_FILE=cmake-toolchains/cross-mingw32.cmake
92e66f31c5Sopenharmony_ci          cmake --build build
93e66f31c5Sopenharmony_ci          cmake --install build --prefix "`pwd`/build/usr"
94e66f31c5Sopenharmony_ci          mkdir -p build/usr/test build/usr/bin
95e66f31c5Sopenharmony_ci          cp -av test/fixtures build/usr/test
96e66f31c5Sopenharmony_ci          cp -av build/uv_run_tests_a.exe build/uv_run_tests.exe build/uv_run_tests_a_no_ext build/uv_run_tests_no_ext \
97e66f31c5Sopenharmony_ci             `${{ matrix.config.arch }}-w64-mingw32-gcc -print-file-name=libgcc_s_${{ matrix.config.libgcc }}-1.dll` \
98e66f31c5Sopenharmony_ci             `${{ matrix.config.arch }}-w64-mingw32-gcc -print-file-name=libwinpthread-1.dll` \
99e66f31c5Sopenharmony_ci             `${{ matrix.config.arch }}-w64-mingw32-gcc -print-file-name=libatomic-1.dll` \
100e66f31c5Sopenharmony_ci             build/usr/bin
101e66f31c5Sopenharmony_ci      - name: Upload build artifacts
102e66f31c5Sopenharmony_ci        uses: actions/upload-artifact@v3
103e66f31c5Sopenharmony_ci        with:
104e66f31c5Sopenharmony_ci          name: mingw-${{ matrix.config.arch }}
105e66f31c5Sopenharmony_ci          path: build/usr/**/*
106e66f31c5Sopenharmony_ci          retention-days: 2
107e66f31c5Sopenharmony_ci
108e66f31c5Sopenharmony_ci  test-mingw:
109e66f31c5Sopenharmony_ci    runs-on: windows-${{ matrix.config.server }}
110e66f31c5Sopenharmony_ci    name: test-mingw-${{ matrix.config.arch }}
111e66f31c5Sopenharmony_ci    needs: build-mingw
112e66f31c5Sopenharmony_ci    strategy:
113e66f31c5Sopenharmony_ci      fail-fast: false
114e66f31c5Sopenharmony_ci      matrix:
115e66f31c5Sopenharmony_ci        config:
116e66f31c5Sopenharmony_ci          - {arch: i686,   server: 2022}
117e66f31c5Sopenharmony_ci          - {arch: x86_64, server: 2022}
118e66f31c5Sopenharmony_ci    steps:
119e66f31c5Sopenharmony_ci      - name: Download build artifacts
120e66f31c5Sopenharmony_ci        uses: actions/download-artifact@v2
121e66f31c5Sopenharmony_ci        with:
122e66f31c5Sopenharmony_ci          name: mingw-${{ matrix.config.arch }}
123e66f31c5Sopenharmony_ci      - name: Test
124e66f31c5Sopenharmony_ci        shell: cmd
125e66f31c5Sopenharmony_ci        run: |
126e66f31c5Sopenharmony_ci          bin\uv_run_tests_a.exe
127e66f31c5Sopenharmony_ci      - name: Test
128e66f31c5Sopenharmony_ci        shell: cmd
129e66f31c5Sopenharmony_ci        run: |
130e66f31c5Sopenharmony_ci          bin\uv_run_tests.exe
131