aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/.github/workflows/test.yml
blob: 37492f2e69622d9143dfe29c6fb48f3755f486a9 (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
name: Test

on:
  push:
  pull_request:
  schedule:
    # Weekly, at 5:45 AM on Friday (somewhat randomly chosen).
    - cron: '45 5 * * 5'
  workflow_dispatch:

jobs:
  old_and_new:
    strategy:
      matrix:
        os: [ubuntu-latest]
        version: [10, 11]
        style: [file, Chromium]
        include:
          - {style: file, exclude: test/chromium.cpp}
          - {style: Chromium, exclude: test/file.cpp}

    runs-on: '${{ matrix.os }}'

    name: '${{ matrix.os }} / ${{ matrix.version }} / ${{ matrix.style }}'

    defaults:
      run:
        shell: pwsh

    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: clang-format (success)
        uses: ./
        with:
          version: '${{ matrix.version }}'
          style: '${{ matrix.style }}'
          exclude: '${{ matrix.exclude }}'

      - id: diff
        name: clang-format (fail)
        uses: ./
        with:
          version: '${{ matrix.version }}'
          style: '${{ matrix.style }}'
        continue-on-error: true

      - name: Verify diff
        run: |
          $output = '${{ steps.diff.outputs.diff }}'
          $basename = Split-Path '${{ matrix.exclude }}' -Leaf
          $original  = "$basename (original)"
          $formatted = "$basename (formatted)"
          $output.Contains($original)  -or $(throw "Diff should contain: $original")
          $output.Contains($formatted) -or $(throw "Diff should contain: $formatted")