Define the per-thread error detail once and release from the same CI run
This commit is contained in:
1 parent
6f6b5db6c2
commit
7ee1131c6f
5 files changed
+68
-97
No files matched your search
@@ -1,8 +1,14 @@
|
|||||||
name: ci
|
name: ci
|
||||||
|
|
||||||
|
# Builds and tests every push and pull request, packages the CLI as a workflow
|
||||||
|
# artifact, and -- when a tag is pushed -- turns those packages into a GitHub
|
||||||
|
# release. One file keeps the release job inside the same run as the build, so it
|
||||||
|
# collects that run's artifacts instead of rebuilding them.
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
pull_request:
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -22,6 +28,16 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Check the tag against the declared version
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
declared=$(sed -n 's/.*JOC_VERSION_STRING *"\([^"]*\)".*/\1/p' include/joc_version.h)
|
||||||
|
if [ -z "$declared" ] || [ "$GITHUB_REF_NAME" != "v$declared" ]; then
|
||||||
|
echo "the tag $GITHUB_REF_NAME does not match JOC_VERSION_STRING (${declared:-unset})" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Configure
|
- name: Configure
|
||||||
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
|
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
|
||||||
|
|
||||||
@@ -31,10 +47,8 @@ jobs:
|
|||||||
- name: Test
|
- name: Test
|
||||||
run: ctest --test-dir build --output-on-failure -C Release
|
run: ctest --test-dir build --output-on-failure -C Release
|
||||||
|
|
||||||
# Package the CLI with its runtime assets at the archive root and the
|
# The CLI and its runtime assets sit at the archive root with the libraries
|
||||||
# libraries in lib/ below it, so the download can be unpacked and run as it
|
# in lib/ below, so the download can be unpacked and run as it is.
|
||||||
# is: the CLI is beside the shared library and finds it through the rpath
|
|
||||||
# recorded in CMakeLists.txt.
|
|
||||||
- name: Stage
|
- name: Stage
|
||||||
run: cmake --install build --config Release --prefix stage
|
run: cmake --install build --config Release --prefix stage
|
||||||
|
|
||||||
@@ -46,9 +60,42 @@ jobs:
|
|||||||
cp -r stage/bin/. "package/$folder/"
|
cp -r stage/bin/. "package/$folder/"
|
||||||
cp -r stage/lib/. "package/$folder/lib/"
|
cp -r stage/lib/. "package/$folder/lib/"
|
||||||
|
|
||||||
|
- name: Archive
|
||||||
|
run: cmake -E tar cf "joc_cli_${{ matrix.label }}.zip" --format=zip "package/joc_cli_${{ matrix.label }}"
|
||||||
|
|
||||||
- name: Upload
|
- name: Upload
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: joc_cli_${{ matrix.label }}
|
name: joc_cli_${{ matrix.label }}
|
||||||
path: package/**
|
path: joc_cli_${{ matrix.label }}.zip
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
|
release:
|
||||||
|
# A pushed tag is what makes a release; branch and PR builds only leave
|
||||||
|
# artifacts. The archives come from the build job of this same run.
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
steps:
|
||||||
|
- name: Collect the packaged archives
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
path: dist
|
||||||
|
merge-multiple: true
|
||||||
|
|
||||||
|
- name: List what will be published
|
||||||
|
run: ls -l dist
|
||||||
|
|
||||||
|
# The archives are attached to the tag's release, whether it already exists
|
||||||
|
# (created in the web interface) or has to be created here.
|
||||||
|
- name: Publish
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1 \
|
||||||
|
|| gh release create "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" \
|
||||||
|
--title "$GITHUB_REF_NAME" --generate-notes
|
||||||
|
gh release upload "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" \
|
||||||
|
--clobber dist/*.zip
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
name: release
|
|
||||||
|
|
||||||
# A tag is the release trigger: pushing v<version> builds every platform, checks
|
|
||||||
# that the tag matches include/joc_version.h and publishes the packaged archives.
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags: ["v*"]
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: ${{ matrix.os }}
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
||||||
include:
|
|
||||||
- os: ubuntu-latest
|
|
||||||
label: linux
|
|
||||||
- os: macos-latest
|
|
||||||
label: macos
|
|
||||||
- os: windows-latest
|
|
||||||
label: windows
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Check the tag against the declared version
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
declared=$(sed -n 's/.*JOC_VERSION_STRING *"\([^"]*\)".*/\1/p' include/joc_version.h)
|
|
||||||
tag="${GITHUB_REF_NAME#v}"
|
|
||||||
if [ -z "$declared" ] || [ "$tag" != "$declared" ]; then
|
|
||||||
echo "tag $GITHUB_REF_NAME does not match the declared version (${declared:-unset})" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Configure
|
|
||||||
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: cmake --build build --config Release --parallel
|
|
||||||
|
|
||||||
- name: Test
|
|
||||||
run: ctest --test-dir build --output-on-failure -C Release
|
|
||||||
|
|
||||||
# The CLI and its runtime assets sit at the archive root with the libraries
|
|
||||||
# in lib/ below, so the download can be unpacked and run as it is.
|
|
||||||
- name: Stage
|
|
||||||
run: cmake --install build --config Release --prefix stage
|
|
||||||
|
|
||||||
- name: Package
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
folder="joc_cli_${{ matrix.label }}"
|
|
||||||
mkdir -p "package/$folder/lib"
|
|
||||||
cp -r stage/bin/. "package/$folder/"
|
|
||||||
cp -r stage/lib/. "package/$folder/lib/"
|
|
||||||
|
|
||||||
- name: Archive
|
|
||||||
run: cmake -E tar cf "joc_cli_${{ matrix.label }}.zip" --format=zip "package/joc_cli_${{ matrix.label }}"
|
|
||||||
|
|
||||||
- name: Upload
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: package-${{ matrix.label }}
|
|
||||||
path: joc_cli_*.zip
|
|
||||||
if-no-files-found: error
|
|
||||||
|
|
||||||
release:
|
|
||||||
needs: build
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/download-artifact@v4
|
|
||||||
with:
|
|
||||||
path: dist
|
|
||||||
merge-multiple: true
|
|
||||||
# The archives are attached to the tag's release, whether that release was
|
|
||||||
# created here or beforehand in the web interface.
|
|
||||||
- name: Publish
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
run: |
|
|
||||||
gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1 \
|
|
||||||
|| gh release create "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" \
|
|
||||||
--title "$GITHUB_REF_NAME" --generate-notes
|
|
||||||
gh release upload "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" \
|
|
||||||
--clobber dist/*.zip
|
|
||||||
@@ -101,6 +101,7 @@ set(JOC_INTERNAL_SOURCES
|
|||||||
src/foundation/fs_utf8.cpp
|
src/foundation/fs_utf8.cpp
|
||||||
src/foundation/mini_json.cpp
|
src/foundation/mini_json.cpp
|
||||||
src/foundation/sha256.cpp
|
src/foundation/sha256.cpp
|
||||||
|
src/foundation/status.cpp
|
||||||
src/hrtf/jochrtf.cpp
|
src/hrtf/jochrtf.cpp
|
||||||
src/hrtf/public_filterbank.cpp
|
src/hrtf/public_filterbank.cpp
|
||||||
src/hrtf/rosella_model.cpp
|
src/hrtf/rosella_model.cpp
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#include "foundation/status.h"
|
||||||
|
|
||||||
|
namespace joc {
|
||||||
|
|
||||||
|
// The single definition of the per-thread detail string. It cannot live in the
|
||||||
|
// header: a thread_local with dynamic initialisation that is included by several
|
||||||
|
// translation units makes each of them emit its own TLS initialisation routine,
|
||||||
|
// and ld64 rejects those as duplicate symbols (GNU ld and MSVC fold them).
|
||||||
|
thread_local std::string last_error_detail;
|
||||||
|
|
||||||
|
} // namespace joc
|
||||||
@@ -36,8 +36,10 @@ private:
|
|||||||
// Structured detail of the most recent failing call, as returned by
|
// Structured detail of the most recent failing call, as returned by
|
||||||
// joc_last_error_detail(). It is one instance per thread across the whole
|
// joc_last_error_detail(). It is one instance per thread across the whole
|
||||||
// library, so every C entry point -- the task API and the streaming API alike --
|
// library, so every C entry point -- the task API and the streaming API alike --
|
||||||
// reports through the same string.
|
// reports through the same string. Defined in status.cpp: a thread_local with
|
||||||
inline thread_local std::string last_error_detail;
|
// dynamic initialisation defined in a header emits a TLS initialisation routine
|
||||||
|
// in every including unit, and ld64 rejects those duplicates.
|
||||||
|
extern thread_local std::string last_error_detail;
|
||||||
|
|
||||||
inline void record_error_detail(const Status& status) {
|
inline void record_error_detail(const Status& status) {
|
||||||
if (status.ok()) {
|
if (status.ok()) {
|
||||||
|
|||||||
Reference in new issue
Block a user