summaryrefslogtreecommitdiffstatshomepage
path: root/.github/workflows/test.yml
blob: 3ea7060373f40a2fba725592afa06290be0e6052 (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
name: Test

on:
  push:
  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:
      fail-fast: false
      matrix:
        os:
          - windows-2022
          - windows-2025
          - windows-latest
        python: [0, 1]
        default: [0, 1]
        include:
          # Prettier run names.
          - {os: windows-2022, name: 2022}
          - {os: windows-2025, name: 2025}
          - {os: windows-latest, name: latest}
          - {default: 0, default_descr: ''}
          - {default: 1, default_descr: ' + C:\Windows'}
          - {python: 0, python_descr: ''}
          - {python: 1, python_descr: ' + setup-python'}
    runs-on: ${{ matrix.os }}
    name: ${{ matrix.name }}${{ matrix.default_descr }}${{ matrix.python_descr }}
    defaults:
      run:
        shell: pwsh
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          persist-credentials: false

      - name: Set up Python
        uses: actions/setup-python@v7
        with:
          python-version: '3.x'
        if: matrix.python

      - name: Show %PATH%
        run: |
          $env:PATH.Split([IO.Path]::PathSeparator) | %{ echo $_ }

      # There should be plenty of MinGW distributions in PATH, some kind of GCC
      # should be there.
      - name: gcc.exe should be found
        run: |
          $(Get-Command gcc -ErrorAction SilentlyContinue) -or $(throw "gcc.exe wasn't found!")

      - name: python.exe should be found
        run: |
          $(Get-Command python -ErrorAction SilentlyContinue) -or $(throw "python.exe wasn't found!")
        if: matrix.python

      - name: Clean up PATH
        uses: $/
        with:
          dirs: C:\foo;C:\bar
          default: ${{ matrix.default }}

      - name: Show %PATH%
        run: |
          $env:PATH.Split([IO.Path]::PathSeparator) | %{ echo $_ }

      - name: gcc.exe shouldn't be found
        run: |
          $(Get-Command gcc -ErrorAction SilentlyContinue) -and $(throw "cl.exe was found!")

      # I'm not sure how this works actually.
      # Do these setup-* actions use a different API?
      - name: python.exe should _still_ be found
        run: |
          $(Get-Command python -ErrorAction SilentlyContinue) -or $(throw "python.exe wasn't found!")
        if: matrix.python

      - name: Check %PATH%
        run: |
          $env:PATH.Split([IO.Path]::PathSeparator) | %{
              if ($_.StartsWith('C:\Program Files\PowerShell')) {
                  # Thanks to `shell: pwsh`, C:\Program Files\PowerShell should
                  # be there.
              } elseif ('${{ matrix.default }}' -eq '1' -and $_.StartsWith('C:\Windows')) {
                  # If the default paths are added, they all should start with
                  # C:\Windows.
              } elseif ('${{ matrix.python }}' -eq '1' -and $_.Contains('\Python\')) {
                  # If we're testing w/ setup-python, it should still be there.
              } elseif ($_ -eq 'C:\foo' -or $_ -eq 'C:\bar') {
                  # Our custom directories.
              } else {
                  throw "Unexpected path: $_"
              }
          }

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