Skip to content
Closed
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
1 change: 1 addition & 0 deletions .clangd
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ CompileFlags:
Add:
- -DSP_IMPLEMENTATION
- -DSP_GLOB_IMPLEMENTATION
- -Wno-macro-redefined
81 changes: 81 additions & 0 deletions .github/DISCUSSION_TEMPLATE/issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
labels: ["needs-confirmation"]
body:
- type: textarea
attributes:
label: Description
description: What's the problem?
validations:
required: true

- type: textarea
attributes:
label: Minimal Reproduction
description: The smallest C program which shows the issue. This must be runnable. A link to a gist is OK too.
render: c
value: |
#define SP_IMPLEMENTATION
#include "sp.h"

s32 main(s32 num_args, const c8** args) {
// ...reproduction
return 0;
}
validations:
required: true

- type: input
attributes:
label: sp.h commit
description: Commit SHA or release tag you're building against.
placeholder: e.g. 87aa835 or v0.3.1
validations:
required: true

- type: input
attributes:
label: OS
placeholder: e.g. Arch Linux, macOS 15.2, Windows 11
validations:
required: true

- type: dropdown
attributes:
label: Architecture
options:
- x86_64
- aarch64
- wasm32
- other
validations:
required: true

- type: dropdown
attributes:
label: Compiler
options:
- gcc
- clang
- MSVC
- mingw
- zig cc
- tcc
- cosmocc
- other
validations:
required: true

- type: dropdown
attributes:
label: libc
options:
- glibc
- musl
- MSVCRT
- UCRT
- apple
- cosmopolitan
- WASI
- freestanding
- other
validations:
required: true
34 changes: 34 additions & 0 deletions .github/DISCUSSION_TEMPLATE/vouch-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
body:
- type: markdown
attributes:
value: |
> [!IMPORTANT]
> This form is for **first-time contributors** who need to be vouched before submitting pull requests. Please read the [Contributing Guide](https://github.com/tspader/sp/blob/main/CONTRIBUTING.md) before submitting.
>
> Keep your request **concise** and write it **in your own voice** — do not have an AI write this for you. A maintainer will comment `!vouch` if your request is approved, after which you can submit PRs.
- type: textarea
attributes:
label: What do you want to change?
description: |
Describe the change you'd like to make to `sp.h`. If there is an existing issue or discussion, link to it.
validations:
required: true
- type: textarea
attributes:
label: Why do you want to make this change?
description: |
Explain your motivation. Why is this change important or useful?
validations:
required: true
- type: checkboxes
attributes:
label: "I acknowledge that:"
options:
- label: >-
I have read the [Contributing Guide](https://github.com/tspader/sp/blob/main/CONTRIBUTING.md)
and understand the contribution process.
required: true
- label: >-
I wrote this vouch request myself, in my
own voice, without AI generating it.
required: true
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Features, Bug Reports, Questions
url: https://github.com/tspader/sp/discussions/new/choose
about: Our preferred starting point if you have any questions or suggestions about configuration, features or behavior.
11 changes: 11 additions & 0 deletions .github/VOUCHED.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Vouched contributors for this project.
#
# See https://github.com/mitchellh/vouch for details.
#
# Syntax:
# - One handle per line (without @), sorted alphabetically.
# - Optional platform prefix: platform:username (e.g., github:user).
# - Denounce with minus prefix: -username or -platform:username.
# - Optional details after a space following the handle.

github:tspader
7 changes: 7 additions & 0 deletions .github/asset/vouch/unvouched-issue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Thanks for opening an issue. I really appreciate anyone trying to make the project better by taking the time to open an issue.

We use Mitchell Hashimoto's contribution model to guard against "plausible-lookingbut actually low-quality contributions" generated by AI. Instead of filing issues, I ask that you simply:
- Read [CONTRIBUTING.md](https://github.com/tspader/sp/blob/main/CONTRIBUTING.md)
- Open a Discussion instead, introducing yourself and describing the issue there instead.

This issue will be closed automatically.
5 changes: 5 additions & 0 deletions .github/terraform/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.terraform/
terraform.tfstate
terraform.tfstate.backup
terraform.tfvars
*.pem
24 changes: 24 additions & 0 deletions .github/terraform/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 69 additions & 0 deletions .github/terraform/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
terraform {
required_version = ">= 1.5"
required_providers {
github = {
source = "integrations/github"
version = "~> 6.0"
}
}
}

provider "github" {
owner = "tspader"
}

resource "github_repository" "sp" {
name = "sp"
description = "A modern C standard library"
has_issues = true
has_projects = true
has_wiki = true
has_discussions = true

lifecycle {
prevent_destroy = true
}
}

resource "github_actions_secret" "vouch_app_id" {
repository = github_repository.sp.name
secret_name = "VOUCH_APP_ID"
value =var.vouch_app_id
}

resource "github_actions_secret" "vouch_app_private_key" {
repository = github_repository.sp.name
secret_name = "VOUCH_APP_PRIVATE_KEY"
value =var.vouch_app_private_key
}

resource "github_repository_ruleset" "main" {
name = "main"
repository = github_repository.sp.name
target = "branch"
enforcement = "active"

conditions {
ref_name {
include = ["~DEFAULT_BRANCH"]
exclude = []
}
}

bypass_actors {
actor_id = 5 # RepositoryRole: admin
actor_type = "RepositoryRole"
bypass_mode = "always"
}

bypass_actors {
actor_id = var.vouch_app_id
actor_type = "Integration"
bypass_mode = "always"
}

rules {
deletion = true
non_fast_forward = true
}
}
10 changes: 10 additions & 0 deletions .github/terraform/terraform.tfvars.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
vouch_app_id = 1234567
vouch_app_installation_id = 89012345

# Paste the full .pem contents between the EOT markers, including the
# BEGIN/END lines. Indentation is stripped by <<-.
vouch_app_private_key = <<-EOT
-----BEGIN RSA PRIVATE KEY-----
...
-----END RSA PRIVATE KEY-----
EOT
10 changes: 10 additions & 0 deletions .github/terraform/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
variable "vouch_app_id" {
type = number
description = "App ID from the Vouch GitHub App's General page."
}

variable "vouch_app_private_key" {
type = string
description = "Private key for the GitHub App installed to the repository"
sensitive = true
}
128 changes: 128 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: ci
on:
workflow_dispatch:
pull_request:
push:
tags: ['v*']

jobs:
matrix:
runs-on: ubuntu-latest
outputs:
include: ${{ steps.set.outputs.include }}
steps:
- id: set
shell: bash
run: |
{
echo 'include<<EOF'
cat <<'JSON'
[
{"triple": "x86_64-linux-none", "runs-on": "ubuntu-latest", "ext": ""},
{"triple": "x86_64-linux-gnu", "runs-on": "ubuntu-latest", "ext": ""},
{"triple": "x86_64-linux-musl", "runs-on": "ubuntu-latest", "ext": ""},
{"triple": "aarch64-linux-none", "runs-on": "ubuntu-24.04-arm", "ext": ""},
{"triple": "aarch64-linux-gnu", "runs-on": "ubuntu-24.04-arm", "ext": ""},
{"triple": "aarch64-linux-musl", "runs-on": "ubuntu-24.04-arm", "ext": ""},
{"triple": "x86_64-windows-gnu", "runs-on": "windows-latest", "ext": ".exe"},
{"triple": "aarch64-macos", "runs-on": "macos-14", "ext": ""}
]
JSON
echo EOF
} >> $GITHUB_OUTPUT

build-zig:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: mlugg/setup-zig@v2
with:
version: master
- run: make big
- uses: actions/upload-artifact@v4
with:
name: build-all
path: build/

build-msvc:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: microsoft/setup-msbuild@v2
- run: msbuild tools\windows\sp\sp.sln /p:Configuration=Release /p:Platform=x64 /m
- uses: actions/upload-artifact@v4
with:
name: build-msvc
path: tools/windows/sp/build/**

test:
needs: [matrix, build-zig]
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.matrix.outputs.include) }}
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/download-artifact@v4
with:
name: build-all
path: build
- shell: bash
run: |
for dir in build/${{ matrix.triple }}/test build/cpp/${{ matrix.triple }}/test; do
chmod +x "$dir"/*${{ matrix.ext }}
for t in "$dir"/*${{ matrix.ext }}; do
echo "=== $t ==="
"$t" || exit 1
done
done

test-wasm:
needs: build-zig
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: build-all
path: build
- uses: bytecodealliance/actions/wasmtime/setup@v1
- shell: bash
run: |
for dir in build/wasm32-wasi/test build/cpp/wasm32-wasi/test; do
for t in "$dir"/*.wasm; do
echo "=== $t ==="
wasmtime run "$t" || exit 1
done
done

test-msvc:
needs: build-msvc
runs-on: windows-latest
steps:
- uses: actions/download-artifact@v4
with:
name: build-msvc
path: bin
- shell: bash
run: for t in bin/**/test/*.exe; do echo "=== $t ==="; "$t" || exit 1; done

release:
if: startsWith(github.ref, 'refs/tags/v')
needs: [test, test-wasm, test-msvc]
runs-on: ubuntu-latest
permissions: { contents: write }
steps:
- uses: actions/download-artifact@v4
with: { path: dist, pattern: build-* }
- run: |
mkdir release
for d in dist/build-all/*/; do
t=$(basename "$d")
[ -d "$d/test" ] || continue
tar -czf release/sp-$t.tar.gz -C dist/build-all "$t"
done
[ -d dist/build-msvc ] && tar -czf release/sp-msvc.tar.gz -C dist build-msvc || true
- uses: softprops/action-gh-release@v2
with:
files: release/*.tar.gz
generate_release_notes: true
Loading
Loading