aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/.github/workflows/test.yml
blob: 5365e7de4a65823e98024253c36d95a6f98263b5 (plain) (blame)
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
name: Test

on:
  push:
    paths-ignore:
      - '**.md'
  schedule:
    # Weekly, at 00:30 UTC on Friday (somewhat randomly chosen).
    - cron: '30 00 * * 5'
  workflow_dispatch:

permissions: {}

jobs:
  lint:
    name: Linting
    runs-on: ubuntu-slim
    permissions:
      security-events: write
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          persist-credentials: false
      - name: Run zizmor
        uses: zizmorcore/zizmor-action@v0.7.1

  test:
    strategy:
      # It's much easier to re-run as few jobs as possible:
      fail-fast: false
      matrix:
        platform:
          - x86
          - x64
        os:
          - ubuntu-22.04
          - ubuntu-24.04
          - ubuntu-26.04
          - ubuntu-latest
          - windows-2022
          - windows-2025
          - windows-latest
        include:
          - {platform: x86, expected_prefix: i686-w64-mingw32}
          - {platform: x64, expected_prefix: x86_64-w64-mingw32}
    runs-on: ${{ matrix.os }}
    name: |
      Test: ${{ matrix.os }} / ${{ matrix.platform }}
    defaults:
      run:
        shell: pwsh
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          persist-credentials: false
      - name: Clean up PATH
        uses: egor-tensin/cleanup-path@v5
        if: runner.os == 'Windows'
      - name: Set up MinGW
        id: setup
        uses: $/
        with:
          platform: ${{ matrix.platform }}
          cc: 1
      - name: Check prefix
        env:
          PREFIX: ${{ steps.setup.outputs.prefix }}
        run: |
          $env:PREFIX -eq '${{ matrix.expected_prefix }}' -or $(throw "Unexpected prefix: $env:PREFIX")
      - name: Build threads.exe
        env:
          GXX: ${{ steps.setup.outputs.gxx }}
        run: |
          & $env:GXX -std=c++14 -o (Join-Path . test threads) (Join-Path . test threads.cpp)
      - name: Run threads.exe
        uses: $/.github/actions/run-threads
        if: runner.os == 'Windows'
      - name: Check cc/c++
        uses: $/.github/actions/check-cc

  test_windows_versions:
    strategy:
      matrix:
        version:
          - 8.1.0
          - 12.2.0
          - 15.2.0
    runs-on: windows-latest
    name: |
      Version: ${{ matrix.version }}
    defaults:
      run:
        shell: pwsh
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          persist-credentials: false
      - name: Clean up PATH
        uses: egor-tensin/cleanup-path@v5
      - name: Set up MinGW
        id: setup
        uses: $/
        with:
          version: ${{ matrix.version }}
      - name: Verify version
        uses: $/.github/actions/check-cc
        with:
          version: ${{ matrix.version }}
      - name: Check prefix
        env:
          PREFIX: ${{ steps.setup.outputs.prefix }}
        run: |
          $env:PREFIX -eq 'x86_64-w64-mingw32' -or $(throw "Unexpected prefix: $env:PREFIX")
      - name: Build threads.exe
        env:
          GXX: ${{ steps.setup.outputs.gxx }}
        run: |
          & $env:GXX -std=c++14 -o (Join-Path . test threads) (Join-Path . test threads.cpp)
      - name: Run threads.exe
        uses: $/.github/actions/run-threads

  release:
    if: github.ref_type == 'tag'
    name: Release
    runs-on: ubuntu-latest
    needs:
      - test
      - test_windows_versions
    permissions:
      contents: write
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          persist-credentials: false
      - name: Release
        uses: softprops/action-gh-release@v3