Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 140 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ name: CI

on:
push:
branches: ["master","main"]
branches: ["master", "main"]
pull_request:
workflow_dispatch:

jobs:
test:
Expand All @@ -13,12 +14,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@v10.1.0

- name: Install Meson and Ninja
run: python -m pip install --upgrade meson ninja
- name: Install meson and ninja
run: uv tool install meson && uv tool install ninja

- name: Configure (debug + tests)
run: meson setup build --buildtype=debug -Dbuild_tests=true -Db_sanitize=address,undefined
Expand All @@ -36,12 +35,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@v10.1.0

- name: Install Meson and Ninja
run: python -m pip install --upgrade meson ninja
- name: Install meson and ninja
run: uv tool install meson && uv tool install ninja

# TSAN and ASAN are mutually exclusive, so this is a dedicated job with
# only the thread sanitizer. It exercises the concurrent torn-read test
Expand All @@ -63,12 +60,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@v10.1.0

- name: Install Meson, Ninja, and gcovr
run: python -m pip install --upgrade meson ninja gcovr
- name: Install meson, ninja and gcovr
run: uv tool install meson && uv tool install ninja && uv tool install gcovr

# -fprofile-update=atomic makes gcov's counter increments atomic. The
# concurrent tests exercise the same instrumented lines from multiple
Expand Down Expand Up @@ -101,15 +96,139 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@v10.1.0

- name: Install Meson and Ninja
run: python -m pip install --upgrade meson ninja
- name: Install meson and ninja
run: uv tool install meson && uv tool install ninja

- name: Configure (release)
run: meson setup build --buildtype=release -Dbuild_tests=false

- name: Build
run: meson compile -C build

# ---------------------------------------------------------------------------
# Cross-compile the library with TI's C2000 code generation tools, a target
# with CHAR_BIT == 16 and a 16-bit int, under both object ABIs. The compiler
# defines __STDC_NO_ATOMICS__ and not __GNUC__, so this builds the
# uniprocessor backend. The installer is checksum-pinned and the toolchain
# is cached.
# ---------------------------------------------------------------------------
c2000:
name: "TI C2000 (CGT ${{ matrix.cgt }})"
runs-on: ubuntu-latest
needs: test
strategy:
fail-fast: false
matrix:
include:
- cgt: "22.6.2"
sha256: "9773f338df7b7314bc459be2cd9d9bf329786da8de6531f8f2d3d38c1e9f5750"
- cgt: "25.11.1"
sha256: "2f3a978e24a53279c9796ad374c32b530fc58fd085fd71288597846fe169c821"

steps:
- uses: actions/checkout@v4

- uses: astral-sh/setup-uv@v10.1.0

- name: Install meson and ninja
run: uv tool install meson && uv tool install ninja

- name: Cache TI C2000 CGT
id: cache-cgt
uses: actions/cache@v4
with:
path: ~/ti
key: ti-cgt-c2000-${{ matrix.cgt }}

- name: Install TI C2000 CGT
if: steps.cache-cgt.outputs.cache-hit != 'true'
run: |
bin="ti_cgt_c2000_${{ matrix.cgt }}.LTS_linux-x64_installer.bin"
curl -sSfL --retry 3 -o "$RUNNER_TEMP/$bin" \
"https://dr-download.ti.com/software-development/ide-configuration-compiler-or-debugger/MD-xqxJ05PLfM/${{ matrix.cgt }}.LTS/$bin"
echo "${{ matrix.sha256 }} $RUNNER_TEMP/$bin" | sha256sum -c -
chmod +x "$RUNNER_TEMP/$bin"
"$RUNNER_TEMP/$bin" --mode unattended --prefix "$HOME/ti"

- name: Configure and build (COFF and EABI)
run: |
CGT="$HOME/ti/ti-cgt-c2000_${{ matrix.cgt }}.LTS"
for abi in coffabi eabi; do
cat > "c2000-$abi.ini" <<INI
[binaries]
c = '$CGT/bin/cl2000'
ar = '$CGT/bin/ar2000'
strip = '$CGT/bin/strip2000'

[built-in options]
c_args = ['-v28', '--float_support=fpu32', '--abi=$abi', '-I$CGT/include']

[host_machine]
system = 'bare-metal'
cpu_family = 'c2000'
cpu = 'c28x'
endian = 'little'
INI
meson setup "build-$abi" --cross-file="c2000-$abi.ini" \
-Dbuild_tests=false -Dwerror=true
meson compile -C "build-$abi"
done

# ---------------------------------------------------------------------------
# Formatting, with the clang-format release pinned in scripts/format.sh.
# ---------------------------------------------------------------------------
format:
name: "clang-format"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: astral-sh/setup-uv@v10.1.0

- name: Check formatting
run: scripts/format.sh

# ---------------------------------------------------------------------------
# MISRA C:2023 analysis with misch, once per atomic backend. CI fails on any
# finding outside that backend's baseline in analysis/baseline/.
# ---------------------------------------------------------------------------
misra:
name: "MISRA (misch)"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: astral-sh/setup-uv@v10.1.0

# Ubuntu 24.04 ships cppcheck 2.13, whose findings differ from current
# releases. The Homebrew bottle is current; brew is preinstalled.
- name: Install cppcheck
env:
HOMEBREW_NO_AUTO_UPDATE: "1"
run: |
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
brew install cppcheck
echo "$(brew --prefix)/bin" >> "$GITHUB_PATH"
cppcheck --version

- name: Install meson, ninja and misch
run: uv tool install meson && uv tool install ninja && uv tool install misch

- name: Configure (compile database)
run: meson setup build --buildtype=debug -Dbuild_tests=true

- name: Analyse (__atomic backend)
run: misch run --baseline -v

- name: Analyse (C11 backend)
run: misch run --baseline --profile c11 -v

- name: Analyse (uniprocessor backend)
run: misch run --baseline --profile no_atomics -v

- name: Deviation record
run: misch deviations
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [Unreleased]

### Added

- `scripts/format.sh`, which pins the clang-format release and runs it with `uvx`. CI checks formatting through it.
- CI runs the MISRA C:2023 analysis with `misch` for each atomic backend, fails on any finding outside that backend's recorded baseline, and prints the deviation record.
- CI compiles the library with warnings as errors using two releases of a vendor C11 compiler for a 16-bit-MAU DSP target, under both of its object formats. That compiler selects the uniprocessor backend.

### Changed

- The build produces and installs only the static library. The shared library, which neither `seqlock_dep` nor `seqlock.pc` linked, is no longer built.
- CI installs Meson, Ninja and gcovr with `uv` instead of `pip`.
- CI gates on 100% branch coverage as well as line coverage. The reader retry branches are reached deterministically by a single-threaded test, and the no-atomics backend is built and tested alongside the C11 backend.

- Added security policy, SPDX headers, and cleaned ignore rules while leaving the existing special coverage/concurrency handling unchanged.
Expand Down
17 changes: 17 additions & 0 deletions analysis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# MISRA analysis assets

This directory was created by `misch init --scaffold`. Its configured paths are resolved relative to the project-root `misra.toml`.

- `rules/` explains how to supply licensed MISRA rule headlines.
- `deviations/` contains reviewed project-level cppcheck suppressions.
- `baseline/` is the configured destination for accepted finding counts.

## Recommended workflow

1. Review `misra.toml`, especially the scope, exclusions, and compilation-database source.
2. Supply rule texts as described in `rules/README.md` when headlines and categories are needed.
3. Run `misch run`, then fix findings or document justified deviations.
4. Run `misch baseline` only after explicitly accepting the current finding counts.
5. Commit reviewed project deviations and the generated baseline so CI can enforce them.

Do not commit MISRA guideline text unless its licence and the repository's access controls permit that distribution.
9 changes: 9 additions & 0 deletions analysis/baseline/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# MISRA baseline

Each atomic backend has its own baseline, because the findings differ between them:

- `misra-baseline.json` — the GCC/Clang `__atomic` backend (base configuration).
- `misra-baseline.c11.json` — the C11 `<stdatomic.h>` backend (`--profile c11`).
- `misra-baseline.no_atomics.json` — the uniprocessor `volatile` backend (`--profile no_atomics`).

CI runs `misch run --baseline` for each, and fails on any finding not recorded in that backend's baseline. Regenerate a baseline only after a deliberate review, with `misch baseline` and the same `--profile`; do not edit it by hand.
53 changes: 53 additions & 0 deletions analysis/baseline/misra-baseline.c11.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"schema": "misch/baseline@2",
"fingerprints": {
"2553c4e512ab": {
"rule_id": "misra-c2012-8.7",
"file": "src/seqlock.c",
"message": "misra violation (use --rule-texts=<file> to get proper output)",
"count": 4
},
"370d2dc0f26b": {
"rule_id": "misra-c2012-20.10",
"file": "include/seqlock.h",
"message": "misra violation (use --rule-texts=<file> to get proper output)",
"count": 1
},
"60d7de2693da": {
"rule_id": "misra-c2012-2.5",
"file": "include/seqlock_conf.h",
"message": "misra violation (use --rule-texts=<file> to get proper output)",
"count": 3
},
"63ee1dea83af": {
"rule_id": "misra-c2012-10.4",
"file": "include/seqlock.h",
"message": "misra violation (use --rule-texts=<file> to get proper output)",
"count": 1
},
"6432a4e45231": {
"rule_id": "misra-c2012-15.5",
"file": "src/seqlock.c",
"message": "misra violation (use --rule-texts=<file> to get proper output)",
"count": 6
},
"a3f09014320e": {
"rule_id": "misra-c2012-12.1",
"file": "include/seqlock.h",
"message": "misra violation (use --rule-texts=<file> to get proper output)",
"count": 6
},
"c0c606393b08": {
"rule_id": "misra-c2012-12.1",
"file": "src/seqlock.c",
"message": "misra violation (use --rule-texts=<file> to get proper output)",
"count": 12
},
"e4c3053cf18a": {
"rule_id": "misra-c2012-2.5",
"file": "include/seqlock.h",
"message": "misra violation (use --rule-texts=<file> to get proper output)",
"count": 3
}
}
}
59 changes: 59 additions & 0 deletions analysis/baseline/misra-baseline.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"schema": "misch/baseline@2",
"fingerprints": {
"055c7abe9a38": {
"rule_id": "misra-c2012-17.3",
"file": "include/seqlock.h",
"message": "misra violation (use --rule-texts=<file> to get proper output)",
"count": 1
},
"2553c4e512ab": {
"rule_id": "misra-c2012-8.7",
"file": "src/seqlock.c",
"message": "misra violation (use --rule-texts=<file> to get proper output)",
"count": 4
},
"370d2dc0f26b": {
"rule_id": "misra-c2012-20.10",
"file": "include/seqlock.h",
"message": "misra violation (use --rule-texts=<file> to get proper output)",
"count": 1
},
"60d7de2693da": {
"rule_id": "misra-c2012-2.5",
"file": "include/seqlock_conf.h",
"message": "misra violation (use --rule-texts=<file> to get proper output)",
"count": 3
},
"6432a4e45231": {
"rule_id": "misra-c2012-15.5",
"file": "src/seqlock.c",
"message": "misra violation (use --rule-texts=<file> to get proper output)",
"count": 6
},
"a3f09014320e": {
"rule_id": "misra-c2012-12.1",
"file": "include/seqlock.h",
"message": "misra violation (use --rule-texts=<file> to get proper output)",
"count": 1
},
"c0c606393b08": {
"rule_id": "misra-c2012-12.1",
"file": "src/seqlock.c",
"message": "misra violation (use --rule-texts=<file> to get proper output)",
"count": 12
},
"d63ad8bce9c3": {
"rule_id": "misra-c2012-17.3",
"file": "src/seqlock.c",
"message": "misra violation (use --rule-texts=<file> to get proper output)",
"count": 11
},
"e4c3053cf18a": {
"rule_id": "misra-c2012-2.5",
"file": "include/seqlock.h",
"message": "misra violation (use --rule-texts=<file> to get proper output)",
"count": 3
}
}
}
Loading
Loading