summaryrefslogtreecommitdiff
path: root/.github/workflows/tarball-windows.yml
blob: a66cdf729d01413eec3572b165c63a4091cbedd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
name: tarball-windows (reusable)

on:
  workflow_call:
    inputs:
      archname:
        description: 'archname (e.g. snapshot-master)'
        required: true
        type: string
      notify-release-channel:
        description: 'Also send failure notifications to SNAPSHOT_SLACK_WEBHOOK_URL (schedule/release builds).'
        required: false
        type: boolean
        default: false
    secrets:
      SIMPLER_ALERTS_URL:
        required: false
      SNAPSHOT_SLACK_WEBHOOK_URL:
        required: false

permissions:
  contents: read

jobs:
  windows:
    strategy:
      matrix:
        include:
          - os: '2022'
            test_task: check
          - os: '2025-vs2026'
            test_task: check
      fail-fast: false
    runs-on: windows-${{ matrix.os }}
    defaults:
      run:
        shell: cmd
        working-directory: build
    name: Windows ${{ matrix.os }} (${{ matrix.test_task }})
    env:
      GITPULLOPTIONS: --no-tags origin ${{github.ref}}
      PATCH: C:\msys64\usr\bin\patch.exe
      OS_VER: windows-${{ matrix.os }}
      # see https://github.com/ruby/ruby/commit/9ff4399decef0036897d3cfb9ac2c710dea913ca
      OPENSSL_MODULES: C:\vcpkg\installed\x64-windows\bin
    steps:
      - run: md build
        working-directory:

      - uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
        with:
          ruby-version: '3.2'
          bundler: none
          windows-toolchain: none

      - uses: msys2/setup-msys2@e9898307ac31d1a803454791be09ab9973336e1c # v2.31.1
        id: setup-msys2
        with:
          update: true
          install: >-
            patch
      - name: patch path
        shell: msys2 {0}
        run: echo PATCH=$(cygpath -wa $(command -v patch)) >> $GITHUB_ENV
        if: ${{ steps.setup-msys2.outcome == 'success' }}
      - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
        with:
          path: C:\vcpkg\installed
          key: ${{ runner.os }}-vcpkg-installed-${{ env.OS_VER }}-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-vcpkg-installed-${{ env.OS_VER }}-
            ${{ runner.os }}-vcpkg-installed-
      - name: Install libraries with vcpkg
        run: |
          vcpkg --triplet x64-windows install gmp libffi libyaml openssl zlib

      - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
        with:
          name: Packages
          path: pkg
      - name: Extract
        run: 7z x pkg/*.zip
        working-directory:

      - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
        with:
          path: snapshot-*/.downloaded-cache
          key: downloaded-cache

      - name: setup env
        # %TEMP% is inconsistent with %TMP% and test-all expects they are consistent.
        # https://github.com/actions/virtual-environments/issues/712#issuecomment-613004302
        env:
          ARCHNAME: ${{ inputs.archname }}
        run: |
          set > old.env
          call ..\%ARCHNAME%\win32\vssetup.cmd
          set TMP=%USERPROFILE%\AppData\Local\Temp
          set TEMP=%USERPROFILE%\AppData\Local\Temp
          set /a TEST_JOBS=(15 * %NUMBER_OF_PROCESSORS% / 10) > nul
          set > new.env

      - name: update env
        shell: pwsh
        run: |
          $old = (Get-Content old.env); $new = (Get-Content new.env)
          del *.env
          Compare-Object $old $new |
            Where-Object { $_.SideIndicator -eq '=>' } |
            Select-Object -ExpandProperty InputObject |
            Add-Content -Path $env:GITHUB_ENV
      - name: link libraries
        run: |
          for %%I in (C:\vcpkg\installed\x64-windows\bin\*.dll) do (
            mklink %%~nxI %%I
          )
      - name: Configure
        env:
          ARCHNAME: ${{ inputs.archname }}
        run: >-
          ../%ARCHNAME%/win32/configure.bat --disable-install-doc
          --with-opt-dir=C:/vcpkg/installed/x64-windows
      - run: nmake incs
      - run: nmake extract-extlibs
      - run: nmake
        env:
          YACC: win_bison

      - name: ruby -v
        run: .\ruby -v

      - run: nmake test
        timeout-minutes: 5

      - run: nmake ${{ matrix.test_task }}
        env:
          RUBY_TESTOPTS: -j${{env.TEST_JOBS}}
        timeout-minutes: 70
        continue-on-error: ${{ matrix.continue-on-error || false }}

      - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
        with:
          sparse-checkout: .github/actions/slack
          sparse-checkout-cone-mode: false
          persist-credentials: false
        if: ${{ failure() }}
      - uses: ./.github/actions/slack
        with:
          label: "${{ env.OS_VER }} / ${{ matrix.test_task }}"
          SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
        if: ${{ failure() }}
      - uses: ruby/action-slack@d260b61aa817726d5bedd22dd6cc305787fa4cdd # v4.0.0
        with:
          payload: |
            {
              "attachments": [{
                "text": "${{ job.status }}: ${{ env.OS_VER }} / ${{ matrix.test_task }} <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ inputs.archname }}>",
                "color": "danger"
              }]
            }
        env:
          SLACK_WEBHOOK_URL: ${{ secrets.SNAPSHOT_SLACK_WEBHOOK_URL }}
        if: failure() && inputs.notify-release-channel