summaryrefslogtreecommitdiff
path: root/.github/workflows/mingw.yml
blob: 5c639ad48bdf38ce590534acff92e14e3067bec8 (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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
name: MinGW
on:
  push:
    paths-ignore:
      - 'doc/**'
      - '**/man/*'
      - '**.md'
      - '**.rdoc'
      - '**/.document'
      - '.*.yml'
  pull_request:
    paths-ignore:
      - 'doc/**'
      - '**/man/*'
      - '**.md'
      - '**.rdoc'
      - '**/.document'
      - '.*.yml'
  merge_group:

concurrency:
  group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
  cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}

permissions:
  contents: read

# Notes:
# Actions console encoding causes issues, see test-all & test-spec steps
#
jobs:
  make:
    runs-on: windows-${{ matrix.os }}

    name: ${{ github.workflow }} (${{ matrix.msystem }})

    env:
      MSYSTEM: ${{ matrix.msystem }}
      MSYS2_ARCH: >-
        ${{
        contains(matrix.msystem, 'arm64') && 'aarch64' ||
        contains(matrix.msystem, '64') && 'x86_64' || 'i686'
        }}
      MINGW_PACKAGE_PREFIX: >-
        mingw-w${{
        endsWith(matrix.msystem, '64') && '64' || '32'
        }}-${{
        startsWith(matrix.msystem, 'clang') && 'clang' ||
        startsWith(matrix.msystem, 'ucrt') && 'ucrt' ||
        'mingw'
        }}-${{
        contains(matrix.msystem, 'arm64') && 'aarch64' ||
        endsWith(matrix.msystem, '64') && 'x86_64' || 'i686'
        }}
      CFLAGS: '-mtune=generic -O3 -pipe'
      CXXFLAGS: '-mtune=generic -O3 -pipe'
      CPPFLAGS: '-D_FORTIFY_SOURCE=2 -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048'
      LDFLAGS: '-pipe'
      GITPULLOPTIONS: --no-tags origin ${{ github.ref }}

    strategy:
      matrix:
        include:
          # To mitigate flakiness of MinGW CI, we test only one runtime that newer MSYS2 uses.
          # Ruby 3.2 is the first Windows Ruby to use OpenSSL 3.x
          - msystem: 'UCRT64'
            os: 2022
            test_task: 'check'
            test-all-opts: '--name=!/TestObjSpace#test_reachable_objects_during_iteration/'
          - msystem: 'CLANGARM64'
            os: 11-arm
            test_task: 'check'
      fail-fast: false

    if: >-
      ${{!(false
      || contains(github.event.head_commit.message, '[DOC]')
      || contains(github.event.pull_request.title, '[DOC]')
      || contains(github.event.pull_request.labels.*.name, 'Documentation')
      || (github.event_name == 'push' && github.event.pull_request.user.login == 'dependabot[bot]')
      )}}

    steps:
      - uses: msys2/setup-msys2@4f806de0a5a7294ffabaff804b38a9b435a73bda # v2.30.0
        id: msys2
        with:
          msystem: ${{ matrix.msystem }}
          update: true
          install: >-
            git
            make
            ruby
            autoconf
            ${{ env.MINGW_PACKAGE_PREFIX }}-gcc
            ${{ env.MINGW_PACKAGE_PREFIX }}-ragel
            ${{ env.MINGW_PACKAGE_PREFIX }}-openssl
            ${{ env.MINGW_PACKAGE_PREFIX }}-libyaml
            ${{ env.MINGW_PACKAGE_PREFIX }}-libffi

      - name: Set up env
        id: setup-env
        working-directory:
        run: |
          $msys2 = ${env:MSYS2_LOCATION}
          $msystem = ${env:MSYSTEM}.ToLower()
          echo $msys2\usr\bin $msys2\$msystem\bin |
            Tee-Object ${env:GITHUB_PATH} -Append -Encoding utf-8

          # Use the fast device for the temporary directory.
          # %TEMP% is inconsistent with %TMP% and test-all expects they are consistent.
          # https://github.com/actions/virtual-environments/issues/712#issuecomment-613004302
          $tmp = ${env:RUNNER_TEMP}
          echo HOME=$home TMP=$tmp TEMP=$tmp TMPDIR=$tmp |
            Tee-Object ${env:GITHUB_ENV} -Append -Encoding utf-8
        shell: pwsh             # cmd.exe does not strip spaces before `|`.
        env:
          MSYS2_LOCATION: ${{ steps.msys2.outputs.msys2-location }}
          MSYSTEM: ${{ matrix.msystem }}

      - name: Remove Strawberry Perl pkg-config
        working-directory:
        # `pkg-config.bat` included in Strawberry Perl is written in
        # Perl and doesn't work when another msys2 `perl` precede its
        # own `perl`.
        #
        # ```
        # Can't find C:\Strawberry\perl\bin\pkg-config.bat on PATH, '.' not in PATH.
        # ```
        run: |
          Get-Command pkg-config.bat | % { ren $_.path ($_.path + "~") }
        shell: pwsh

      - name: Misc system & package info
        working-directory:
        run: |
          group() { echo ::group::$'\e[94;1m'"$*"$'\e[m'; }
          endgroup() { echo ::endgroup::; }

          group Path
          cygpath -wa / . $(type -p cygpath bash sh)
          endgroup

          I() {
              group $1
              run Where type -pa $1 && { [ $# -eq 1 ] || run Version "$@"; } ||
                  failed+=($1)
              endgroup
          }
          run() { local w m=$1; shift; w="$("$@")" && show "$m" && indent "$w"; }
          indent() { [ -z "$1" ] || echo "$1" | /bin/sed '/^$/!s/^/  /'; }
          show() { echo $'\e[96m'"$*"$'\e[m'; }

          failed=()

          I gcc.exe --version
          I ragel.exe --version
          I make.exe --version
          I openssl.exe version
          I libcrypto-3-x64.dll
          I libssl-3-x64.dll

          group Packages
          pacman -Qs $MINGW_PACKAGE_PREFIX-* | /bin/sed -n "s,local/$MINGW_PACKAGE_PREFIX-,,p"
          endgroup

          [ ${#failed[@]} -eq 0 ]
        shell: sh

      - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
        with:
          sparse-checkout-cone-mode: false
          sparse-checkout: /.github

      - uses: ./.github/actions/setup/directories
        with:
          srcdir: src
          builddir: build
          makeup: true
          # Set fetch-depth: 10 so that Launchable can receive commits information.
          fetch-depth: 10

      - name: configure
        run: >
          ../src/configure --disable-install-doc --prefix=/.
          --build=$CHOST --host=$CHOST --target=$CHOST
        shell: sh
        env:
          CHOST: ${{ env.MSYS2_ARCH }}-w64-mingw32

      - name: make all
        timeout-minutes: 30
        run: make -j4

      - name: make install
        run: make DESTDIR=../install install-nodoc

      - name: Set up Launchable
        uses: ./.github/actions/launchable/setup
        with:
          os: windows-2022
          launchable-token: ${{ secrets.LAUNCHABLE_TOKEN }}
          builddir: build
          srcdir: src
          test-tasks: '["test", "test-all", "test-spec"]'
        continue-on-error: true
        timeout-minutes: 3

      - name: test
        timeout-minutes: 30
        run: make test test-tool
        env:
          GNUMAKEFLAGS: ''
          RUBY_TESTOPTS: '-v --tty=no'
        if: ${{ matrix.test_task == 'check' || matrix.test_task == 'test' }}

      - name: test-all
        timeout-minutes: 45
        run: |
          make ${{ StartsWith(matrix.test_task, 'test/') && matrix.test_task || 'test-all' }}
        env:
          RUBY_TESTOPTS: >-
            --retry --job-status=normal --show-skip --timeout-scale=1.5 -j4
            ${{ matrix.test-all-opts }}
            ${{ env.TESTS }}
          BUNDLER_VERSION:
        if: ${{ matrix.test_task == 'check' || matrix.test_task == 'test-all' || StartsWith(matrix.test_task, 'test/') }}

      - name: test-spec
        timeout-minutes: 10
        run: |
          make ${{ StartsWith(matrix.test_task, 'spec/') && matrix.test_task || 'test-spec' }}
        if: ${{ matrix.test_task == 'check' || matrix.test_task == 'test-spec' || StartsWith(matrix.test_task, 'spec/') }}

      - uses: ./src/.github/actions/slack
        with:
          label: ${{ matrix.msystem }} / ${{ matrix.test_task }}
          SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
        if: ${{ failure() }}

defaults:
  run:
    working-directory: build
    shell: cmd