[onton-tui-ux-polish] Patch P9: Meaningful error and failure messages #618
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| # Cancel in-progress runs for the same branch/PR | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build-and-test: | |
| name: Build & Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| - uses: ocaml/setup-ocaml@dec6499fef64fc5d7ed43d43a87251b7b1c306f5 # v3 | |
| with: | |
| ocaml-compiler: '5.4.0' | |
| dune-cache: true | |
| - name: Install dependencies | |
| run: opam install . --deps-only --with-test -y | |
| - name: Build | |
| id: build | |
| run: | | |
| opam exec -- dune build 2>&1 | tee build.log | |
| exit ${PIPESTATUS[0]} | |
| - name: Annotate build errors | |
| if: failure() && steps.build.outcome == 'failure' | |
| run: | | |
| # Parse OCaml compiler errors into GitHub annotations | |
| python3 -c " | |
| import re, sys | |
| log = open('build.log').read() | |
| # Match: File \"path\", line N, characters C-C: | |
| for m in re.finditer(r'File \"([^\"]+)\", line (\d+), characters (\d+)-\d+:\n(.*?)(?=\nFile |\Z)', log, re.DOTALL): | |
| f, line, col, msg = m.groups() | |
| msg = msg.strip().replace('\n', ' ') | |
| level = 'error' if 'Error' in msg else 'warning' | |
| print(f'::{level} file={f},line={line},col={col}::{msg}') | |
| " | |
| - name: Run tests | |
| run: opam exec -- dune runtest 2>&1 | tee test.log | |
| - name: Annotate test failures | |
| if: failure() && hashFiles('test.log') != '' | |
| run: | | |
| python3 -c " | |
| import re | |
| log = open('test.log').read() | |
| for m in re.finditer(r'File \"([^\"]+)\", line (\d+).*?:\s*(.*?FAILED.*)', log): | |
| f, line, msg = m.groups() | |
| print(f'::error file={f},line={line}::{msg.strip()}') | |
| for m in re.finditer(r'FAIL\s+(.+?)\s+in\s+(\S+)\s+at\s+line\s+(\d+)', log): | |
| name, f, line = m.groups() | |
| print(f'::error file={f},line={line}::Test failed: {name}') | |
| " | |
| property-tests: | |
| name: Property Tests (10k) | |
| needs: build-and-test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| - uses: ocaml/setup-ocaml@dec6499fef64fc5d7ed43d43a87251b7b1c306f5 # v3 | |
| with: | |
| ocaml-compiler: '5.4.0' | |
| dune-cache: true | |
| - name: Install dependencies | |
| run: opam install . --deps-only --with-test -y | |
| - name: Run property tests (10k iterations) | |
| run: opam exec -- dune runtest 2>&1 | tee proptest.log | |
| env: | |
| QCHECK_COUNT: "10000" | |
| - name: Annotate property test failures | |
| if: failure() | |
| run: | | |
| python3 -c " | |
| import re | |
| log = open('proptest.log').read() | |
| for m in re.finditer(r'File \"([^\"]+)\", line (\d+).*?:\s*(.*?fail.*)', log, re.IGNORECASE): | |
| f, line, msg = m.groups() | |
| print(f'::error file={f},line={line}::{msg.strip()}') | |
| " | |
| format: | |
| name: Format Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| - uses: ocaml/setup-ocaml@dec6499fef64fc5d7ed43d43a87251b7b1c306f5 # v3 | |
| with: | |
| ocaml-compiler: '5.4.0' | |
| - uses: ocaml/setup-ocaml/lint-fmt@dec6499fef64fc5d7ed43d43a87251b7b1c306f5 # v3 |