|
| 1 | +name: 'Generated Files Up To Date' |
| 2 | + |
| 3 | +# Several files in this repository are generated and checked in, and nothing rebuilt them and |
| 4 | +# compared -- so a template could stop matching its output and the build stayed green. The file was |
| 5 | +# then only discovered to be unregenerable the next time somebody actually tried. |
| 6 | +# |
| 7 | +# That had happened twice by the time this was written. `EquationSystemFunctionPattern.txt` still |
| 8 | +# said `Tensor?` long after the type was renamed to `Matrix?` (repaired by #1029), and |
| 9 | +# `TupleToIntervalTest.txt` still said `MathS.Matrices.Interval`, which does not exist -- so |
| 10 | +# regenerating that test file produced eighteen CS0117 errors. Both were found by hand, years apart, |
| 11 | +# which is the argument for this job. |
| 12 | +# |
| 13 | +# The ANTLR parser has its own job, GrammarUpToDate.yml, because it needs a Java runtime where this |
| 14 | +# needs a dotnet tool. Keeping them apart means neither goes red for the other's reason. |
| 15 | +# https://github.com/asc-community/AngouriMath/issues/1034 |
| 16 | + |
| 17 | +on: |
| 18 | + push: |
| 19 | + branches: |
| 20 | + - master |
| 21 | + paths: |
| 22 | + - "Sources/AngouriMath/**/*.tt" |
| 23 | + - "Sources/AngouriMath/Convenience/CompilationExtensions.cs" |
| 24 | + - "Sources/AngouriMath/Functions/Compilation/**" |
| 25 | + - "Sources/Utils/**" |
| 26 | + - "Sources/Tests/UnitTests/Convenience/TupleToIntervalTest.cs" |
| 27 | + - "Sources/AngouriMath/AngouriMath.csproj" |
| 28 | + - ".github/workflows/GeneratedFilesUpToDate.yml" |
| 29 | + pull_request: |
| 30 | + branches: |
| 31 | + - '*' |
| 32 | + paths: |
| 33 | + - "Sources/AngouriMath/**/*.tt" |
| 34 | + - "Sources/AngouriMath/Convenience/CompilationExtensions.cs" |
| 35 | + - "Sources/AngouriMath/Functions/Compilation/**" |
| 36 | + - "Sources/Utils/**" |
| 37 | + - "Sources/Tests/UnitTests/Convenience/TupleToIntervalTest.cs" |
| 38 | + - "Sources/AngouriMath/AngouriMath.csproj" |
| 39 | + - ".github/workflows/GeneratedFilesUpToDate.yml" |
| 40 | + |
| 41 | +jobs: |
| 42 | + Regenerate: |
| 43 | + runs-on: ubuntu-latest |
| 44 | + |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@v6 |
| 47 | + |
| 48 | + - name: Setup .NET 10 |
| 49 | + uses: actions/setup-dotnet@v5 |
| 50 | + with: |
| 51 | + dotnet-version: '10.x' |
| 52 | + dotnet-quality: 'preview' |
| 53 | + |
| 54 | + # The one tool this needs beyond the SDK the other jobs already install. |
| 55 | + - name: 'Install the T4 processor' |
| 56 | + run: dotnet tool install -g dotnet-t4 |
| 57 | + |
| 58 | + - name: 'Regenerate every generated file' |
| 59 | + run: bash Sources/Utils/regenerate_all.sh |
| 60 | + |
| 61 | + # No exclusions. The templates emit the copyright header themselves, so the generated file is |
| 62 | + # the committed file byte for byte and there is nothing here that could quietly grow to hide a |
| 63 | + # real difference. Two of the three T4 templates did not emit it until this issue, which meant |
| 64 | + # regenerating them produced files that failed the build outright -- IDE0073 is an error here. |
| 65 | + - name: 'Fail if a committed generated file is not what its generator produces' |
| 66 | + run: | |
| 67 | + if ! git diff --exit-code --stat; then |
| 68 | + echo "::error::A checked-in generated file does not match its generator." |
| 69 | + echo "::error::Run Sources/Utils/regenerate_all.sh and commit the result." |
| 70 | + echo "--- the difference ---" |
| 71 | + git --no-pager diff |
| 72 | + exit 1 |
| 73 | + fi |
0 commit comments