feat: initial nuwiki Rust workspace (core, lsp, ls)
This commit is contained in:
@@ -0,0 +1,128 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
RUST_BACKTRACE: "1"
|
||||
RUSTFLAGS: -D warnings
|
||||
|
||||
jobs:
|
||||
fmt:
|
||||
name: cargo fmt --check
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@1.83
|
||||
with:
|
||||
components: rustfmt
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-fmt-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cargo-fmt-
|
||||
- run: cargo fmt --all -- --check
|
||||
|
||||
clippy:
|
||||
name: cargo clippy
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@1.83
|
||||
with:
|
||||
components: clippy
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cargo-clippy-
|
||||
- run: cargo clippy --workspace --all-targets -- -D warnings
|
||||
|
||||
test:
|
||||
name: cargo test
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@1.83
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cargo-test-
|
||||
- run: cargo test --workspace --all-targets
|
||||
|
||||
keymaps:
|
||||
name: editor keymaps
|
||||
runs-on: ubuntu-latest
|
||||
# Serialise behind the cargo jobs so we never compete with them
|
||||
# for runners, and inherit their warm cargo cache instead of
|
||||
# forcing a release build of our own.
|
||||
needs: test
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@1.83
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cargo-test-
|
||||
- name: install Neovim + Vim
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# Test the minimum supported Neovim version (0.11.0) so we
|
||||
# catch API regressions at the bottom of the supported range.
|
||||
# Pinning to a specific patch version; bump when 0.12 ships.
|
||||
NVIM_VER=v0.11.0
|
||||
curl -fsSL -o /tmp/nvim.tar.gz \
|
||||
"https://github.com/neovim/neovim/releases/download/${NVIM_VER}/nvim-linux-x86_64.tar.gz"
|
||||
sudo tar -xzf /tmp/nvim.tar.gz -C /opt
|
||||
sudo ln -sf /opt/nvim-linux-x86_64/bin/nvim /usr/local/bin/nvim
|
||||
nvim --version | head -1
|
||||
# Vim from apt is fine — only the pure-VimL keymaps run there.
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -y --no-install-recommends vim
|
||||
vim --version | head -1
|
||||
- name: run Neovim keymap harness
|
||||
run: ./development/tests/test-keymaps.sh
|
||||
- name: run Vim keymap harness
|
||||
run: ./development/tests/test-keymaps-vim.sh
|
||||
- name: run Neovim config parity harness
|
||||
run: ./development/tests/test-config.sh
|
||||
- name: run Vim config parity harness
|
||||
run: ./development/tests/test-config-vim.sh
|
||||
- name: run Neovim calendar integration harness
|
||||
run: ./development/tests/test-calendar.sh
|
||||
- name: run Vim calendar integration harness
|
||||
run: ./development/tests/test-calendar-vim.sh
|
||||
- name: run Vim vars-shim harness
|
||||
run: ./development/tests/test-vars-vim.sh
|
||||
- name: run Vim vimwiki-config compat harness
|
||||
run: ./development/tests/test-vimwiki-compat-vim.sh
|
||||
- name: run Neovim global-shorthand harness
|
||||
run: ./development/tests/test-global-shorthand.sh
|
||||
- name: run Vim coc-registration harness
|
||||
run: ./development/tests/test-coc-register-vim.sh
|
||||
@@ -0,0 +1,276 @@
|
||||
name: Release
|
||||
|
||||
# Releases are cut from the Actions UI: "Run workflow" → enter the version
|
||||
# (e.g. 0.4.0). The `prepare` job stamps that version into every hardcoded
|
||||
# spot (scripts/set-version.sh), commits "chore(release): X.Y.Z", and pushes
|
||||
# the vX.Y.Z tag. The build matrix + release job then run off that tag. No
|
||||
# more hand-editing versions across Cargo.toml/plugin/nuwiki.vim.
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: 'Release version, no leading v (e.g. 0.4.0)'
|
||||
required: true
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
RUST_BACKTRACE: short
|
||||
RUSTFLAGS: -D warnings
|
||||
|
||||
jobs:
|
||||
prepare:
|
||||
name: bump + tag
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
version: ${{ steps.stamp.outputs.version }}
|
||||
tag: ${{ steps.stamp.outputs.tag }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
# Push the release commit + tag back with a write-capable token.
|
||||
token: ${{ secrets.RELEASE_TOKEN }}
|
||||
|
||||
- uses: dtolnay/rust-toolchain@1.83
|
||||
|
||||
- name: Cache cargo state
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-prepare-${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cargo-prepare-
|
||||
|
||||
- name: Validate version + stamp
|
||||
id: stamp
|
||||
env:
|
||||
VERSION: ${{ inputs.version }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
ver="${VERSION#v}" # tolerate a leading v
|
||||
if ! printf '%s' "$ver" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+([-.][0-9A-Za-z.-]+)?$'; then
|
||||
echo "::error::'$ver' is not a semver version (expected e.g. 0.4.0)"
|
||||
exit 1
|
||||
fi
|
||||
tag="v$ver"
|
||||
if git rev-parse -q --verify "refs/tags/$tag" >/dev/null \
|
||||
|| git ls-remote --exit-code --tags origin "$tag" >/dev/null 2>&1; then
|
||||
echo "::error::tag $tag already exists"
|
||||
exit 1
|
||||
fi
|
||||
bash scripts/set-version.sh "$ver"
|
||||
echo "version=$ver" >> "$GITHUB_OUTPUT"
|
||||
echo "tag=$tag" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# Gate: never tag code that doesn't build/test. If this fails nothing
|
||||
# is committed or pushed, so the release simply doesn't happen.
|
||||
- name: Test
|
||||
run: cargo test --workspace
|
||||
|
||||
- name: Commit, tag, push
|
||||
env:
|
||||
VER: ${{ steps.stamp.outputs.version }}
|
||||
TAG: ${{ steps.stamp.outputs.tag }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git config user.name "gitea-actions"
|
||||
git config user.email "gitea-actions@users.noreply.code.gfran.co"
|
||||
git add Cargo.toml Cargo.lock \
|
||||
crates/nuwiki-lsp/Cargo.toml crates/nuwiki-ls/Cargo.toml \
|
||||
plugin/nuwiki.vim
|
||||
git commit -m "chore(release): $VER"
|
||||
git tag -a "$TAG" -m "nuwiki $VER"
|
||||
git push origin "HEAD:${GITHUB_REF_NAME}"
|
||||
git push origin "$TAG"
|
||||
|
||||
build:
|
||||
name: build ${{ matrix.target }}
|
||||
needs: prepare
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- target: x86_64-unknown-linux-gnu
|
||||
apt: ""
|
||||
rustflags: "-D warnings"
|
||||
- target: aarch64-unknown-linux-gnu
|
||||
# gcc-aarch64-linux-gnu ships the cross compiler/binutils
|
||||
# but no target libc; libc6-dev-arm64-cross adds Scrt1.o,
|
||||
# crti.o, and friends needed at link time.
|
||||
apt: "gcc-aarch64-linux-gnu libc6-dev-arm64-cross"
|
||||
rustflags: "-D warnings"
|
||||
- target: x86_64-unknown-linux-musl
|
||||
apt: "musl-tools"
|
||||
rustflags: "-D warnings"
|
||||
- target: aarch64-unknown-linux-musl
|
||||
apt: ""
|
||||
rustflags: "-D warnings -C linker=rust-lld -C link-self-contained=yes"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
# Build the just-tagged commit, not the branch tip.
|
||||
ref: ${{ needs.prepare.outputs.tag }}
|
||||
|
||||
- uses: dtolnay/rust-toolchain@1.83
|
||||
with:
|
||||
targets: ${{ matrix.target }}
|
||||
|
||||
- name: Install cross toolchain
|
||||
if: matrix.apt != ''
|
||||
run: |
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -y --no-install-recommends ${{ matrix.apt }}
|
||||
|
||||
- name: Cache cargo state
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-release-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cargo-release-${{ matrix.target }}-
|
||||
|
||||
- name: Build nuwiki-ls
|
||||
env:
|
||||
# Per-target linker overrides. Cargo ignores the entries that
|
||||
# don't match the current target, so setting all of them here
|
||||
# keeps the matrix declarative.
|
||||
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
|
||||
CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER: musl-gcc
|
||||
RUSTFLAGS: ${{ matrix.rustflags }}
|
||||
run: cargo build --release --target ${{ matrix.target }} -p nuwiki-ls
|
||||
|
||||
- name: Package archive
|
||||
id: package
|
||||
env:
|
||||
VERSION: ${{ needs.prepare.outputs.version }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
archive="nuwiki-ls-${VERSION}-${{ matrix.target }}.tar.gz"
|
||||
tar -czf "$archive" -C "target/${{ matrix.target }}/release" nuwiki-ls
|
||||
# Use a stable name without version so /releases/latest/download/nuwiki-ls-{target}.tar.gz always resolves.
|
||||
stable="nuwiki-ls-${{ matrix.target }}.tar.gz"
|
||||
mv "$archive" "$stable"
|
||||
echo "archive=$stable" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: nuwiki-ls-${{ matrix.target }}
|
||||
path: ${{ steps.package.outputs.archive }}
|
||||
if-no-files-found: error
|
||||
|
||||
release:
|
||||
name: gitea release
|
||||
needs: [prepare, build]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ needs.prepare.outputs.tag }}
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Download all build artifacts
|
||||
# download-artifact@v3 nests each artifact under its own dir
|
||||
# (artifacts/<artifact-name>/<file>), so recurse.
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
path: ./artifacts
|
||||
|
||||
- name: Ensure jq + curl
|
||||
run: |
|
||||
if ! command -v jq >/dev/null 2>&1; then
|
||||
apt-get update && apt-get install -y --no-install-recommends jq
|
||||
fi
|
||||
if ! command -v curl >/dev/null 2>&1; then
|
||||
apt-get update && apt-get install -y --no-install-recommends curl
|
||||
fi
|
||||
|
||||
- name: Generate release notes
|
||||
id: notes
|
||||
env:
|
||||
TAG: ${{ needs.prepare.outputs.tag }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git fetch --tags --force origin >/dev/null 2>&1 || true
|
||||
# Previous tag = newest tag that isn't the one we just cut.
|
||||
prev_tag=$(git tag --sort=-version:refname | grep -vxF "$TAG" | head -n1 || echo "")
|
||||
if [ -n "$prev_tag" ]; then
|
||||
log=$(git log --oneline "$prev_tag..$TAG")
|
||||
else
|
||||
log=$(git log --oneline "$TAG")
|
||||
fi
|
||||
cat > release-notes.txt <<EOF
|
||||
**Full Changelog**: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/compare/${prev_tag:-$(git rev-list --max-parents=0 HEAD)}...${TAG}
|
||||
|
||||
**Changes**:
|
||||
$log
|
||||
EOF
|
||||
echo "Generated release notes"
|
||||
|
||||
- name: Create Gitea release + upload assets
|
||||
env:
|
||||
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||
GITEA_SERVER: ${{ github.server_url }}
|
||||
REPO: ${{ github.repository }}
|
||||
TAG: ${{ needs.prepare.outputs.tag }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [ -z "${RELEASE_TOKEN:-}" ]; then
|
||||
echo "::error::RELEASE_TOKEN secret is not set"
|
||||
exit 1
|
||||
fi
|
||||
echo "Releasing $TAG to $GITEA_SERVER/$REPO"
|
||||
|
||||
# Check if a release for this tag already exists (idempotency).
|
||||
release_id=""
|
||||
existing=$(curl --fail --silent --show-error -o /dev/null -w "%{http_code}" \
|
||||
-H "Authorization: token $RELEASE_TOKEN" \
|
||||
"$GITEA_SERVER/api/v1/repos/$REPO/releases/tags/$TAG" \
|
||||
2>/dev/null || true)
|
||||
if [ "$existing" = "200" ]; then
|
||||
echo "Release for $TAG already exists — fetching existing id"
|
||||
release_id=$(curl --fail --silent --show-error \
|
||||
-H "Authorization: token $RELEASE_TOKEN" \
|
||||
"$GITEA_SERVER/api/v1/repos/$REPO/releases/tags/$TAG" \
|
||||
| jq -r '.id')
|
||||
else
|
||||
notes=$(cat release-notes.txt 2>/dev/null || echo "")
|
||||
payload=$(jq -n --arg tag "$TAG" --arg name "$TAG" --arg body "$notes" \
|
||||
'{tag_name: $tag, name: $name, body: $body, draft: false, prerelease: false}')
|
||||
release_id=$(curl --fail --silent --show-error \
|
||||
-H "Authorization: token $RELEASE_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$payload" \
|
||||
"$GITEA_SERVER/api/v1/repos/$REPO/releases" \
|
||||
| jq -r '.id')
|
||||
if [ -z "$release_id" ] || [ "$release_id" = "null" ]; then
|
||||
echo "::error::failed to create release"
|
||||
exit 1
|
||||
fi
|
||||
echo "Created release id=$release_id"
|
||||
fi
|
||||
|
||||
# download-artifact@v3 nests each artifact under its own dir
|
||||
# (artifacts/<artifact-name>/<file>), so recurse.
|
||||
for archive in $(find artifacts -name '*.tar.gz' -type f); do
|
||||
name="$(basename "$archive")"
|
||||
echo "Uploading $name …"
|
||||
curl --fail --silent --show-error \
|
||||
-H "Authorization: token $RELEASE_TOKEN" \
|
||||
-H "Content-Type: application/gzip" \
|
||||
--data-binary "@$archive" \
|
||||
"$GITEA_SERVER/api/v1/repos/$REPO/releases/$release_id/assets?name=$name" \
|
||||
>/dev/null
|
||||
done
|
||||
echo "All assets uploaded."
|
||||
Reference in New Issue
Block a user