Ci improvements #4
+29
-12
@@ -2,27 +2,43 @@ name: CI
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
branches: [main]
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ci-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
env:
|
env:
|
||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
RUST_BACKTRACE: short
|
RUST_BACKTRACE: "1"
|
||||||
RUSTFLAGS: -D warnings
|
RUSTFLAGS: -D warnings
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
fmt:
|
fmt:
|
||||||
name: cargo fmt --check
|
name: cargo fmt --check
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 5
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: dtolnay/rust-toolchain@1.83
|
- uses: dtolnay/rust-toolchain@1.83
|
||||||
with:
|
with:
|
||||||
components: rustfmt
|
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
|
- run: cargo fmt --all -- --check
|
||||||
|
|
||||||
clippy:
|
clippy:
|
||||||
name: cargo clippy
|
name: cargo clippy
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 5
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: dtolnay/rust-toolchain@1.83
|
- uses: dtolnay/rust-toolchain@1.83
|
||||||
@@ -35,13 +51,14 @@ jobs:
|
|||||||
~/.cargo/git
|
~/.cargo/git
|
||||||
target
|
target
|
||||||
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
|
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
|
||||||
restore-keys: |
|
restore-keys:
|
||||||
${{ runner.os }}-cargo-clippy-
|
- ${{ runner.os }}-cargo-clippy-
|
||||||
- run: cargo clippy --workspace --all-targets -- -D warnings
|
- run: cargo clippy --workspace --all-targets -- -D warnings
|
||||||
|
|
||||||
test:
|
test:
|
||||||
name: cargo test
|
name: cargo test
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 5
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: dtolnay/rust-toolchain@1.83
|
- uses: dtolnay/rust-toolchain@1.83
|
||||||
@@ -52,8 +69,8 @@ jobs:
|
|||||||
~/.cargo/git
|
~/.cargo/git
|
||||||
target
|
target
|
||||||
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
|
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
|
||||||
restore-keys: |
|
restore-keys:
|
||||||
${{ runner.os }}-cargo-test-
|
- ${{ runner.os }}-cargo-test-
|
||||||
- run: cargo test --workspace --all-targets
|
- run: cargo test --workspace --all-targets
|
||||||
|
|
||||||
keymaps:
|
keymaps:
|
||||||
@@ -74,15 +91,15 @@ jobs:
|
|||||||
~/.cargo/git
|
~/.cargo/git
|
||||||
target
|
target
|
||||||
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
|
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
|
||||||
restore-keys: |
|
restore-keys:
|
||||||
${{ runner.os }}-cargo-test-
|
- ${{ runner.os }}-cargo-test-
|
||||||
- name: install Neovim 0.11 + Vim
|
- name: install Neovim + Vim
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
# Apt's neovim is too old (Ubuntu LTS ships 0.6/0.7), missing
|
# Test the minimum supported Neovim version (0.11.0) so we
|
||||||
# `vim.lsp.get_clients` and rejecting `@group.modifier`
|
# catch API regressions at the bottom of the supported range.
|
||||||
# highlight names. Pull the official static tarball instead.
|
# Pinning to a specific patch version; bump when 0.12 ships.
|
||||||
NVIM_VER=v0.11.3
|
NVIM_VER=v0.11.0
|
||||||
curl -fsSL -o /tmp/nvim.tar.gz \
|
curl -fsSL -o /tmp/nvim.tar.gz \
|
||||||
"https://github.com/neovim/neovim/releases/download/${NVIM_VER}/nvim-linux-x86_64.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 tar -xzf /tmp/nvim.tar.gz -C /opt
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ permissions:
|
|||||||
env:
|
env:
|
||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
RUST_BACKTRACE: short
|
RUST_BACKTRACE: short
|
||||||
|
RUSTFLAGS: -D warnings
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -22,19 +23,19 @@ jobs:
|
|||||||
include:
|
include:
|
||||||
- target: x86_64-unknown-linux-gnu
|
- target: x86_64-unknown-linux-gnu
|
||||||
apt: ""
|
apt: ""
|
||||||
rustflags: ""
|
rustflags: "-D warnings"
|
||||||
- target: aarch64-unknown-linux-gnu
|
- target: aarch64-unknown-linux-gnu
|
||||||
# gcc-aarch64-linux-gnu ships the cross compiler/binutils
|
# gcc-aarch64-linux-gnu ships the cross compiler/binutils
|
||||||
# but no target libc; libc6-dev-arm64-cross adds Scrt1.o,
|
# but no target libc; libc6-dev-arm64-cross adds Scrt1.o,
|
||||||
# crti.o, and friends needed at link time.
|
# crti.o, and friends needed at link time.
|
||||||
apt: "gcc-aarch64-linux-gnu libc6-dev-arm64-cross"
|
apt: "gcc-aarch64-linux-gnu libc6-dev-arm64-cross"
|
||||||
rustflags: ""
|
rustflags: "-D warnings"
|
||||||
- target: x86_64-unknown-linux-musl
|
- target: x86_64-unknown-linux-musl
|
||||||
apt: "musl-tools"
|
apt: "musl-tools"
|
||||||
rustflags: ""
|
rustflags: "-D warnings"
|
||||||
- target: aarch64-unknown-linux-musl
|
- target: aarch64-unknown-linux-musl
|
||||||
apt: ""
|
apt: ""
|
||||||
rustflags: "-C linker=rust-lld -C link-self-contained=yes"
|
rustflags: "-D warnings -C linker=rust-lld -C link-self-contained=yes"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
@@ -56,8 +57,8 @@ jobs:
|
|||||||
~/.cargo/git
|
~/.cargo/git
|
||||||
target
|
target
|
||||||
key: ${{ runner.os }}-cargo-release-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
|
key: ${{ runner.os }}-cargo-release-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
|
||||||
restore-keys: |
|
restore-keys:
|
||||||
${{ runner.os }}-cargo-release-${{ matrix.target }}-
|
- ${{ runner.os }}-cargo-release-${{ matrix.target }}-
|
||||||
|
|
||||||
- name: Build nuwiki-ls
|
- name: Build nuwiki-ls
|
||||||
env:
|
env:
|
||||||
@@ -93,8 +94,6 @@ jobs:
|
|||||||
needs: build
|
needs: build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Download all build artifacts
|
- name: Download all build artifacts
|
||||||
# Paired with upload-artifact@v3 above. v3 has no merge-multiple
|
# Paired with upload-artifact@v3 above. v3 has no merge-multiple
|
||||||
# option and nests each artifact under its own subdirectory.
|
# option and nests each artifact under its own subdirectory.
|
||||||
@@ -111,6 +110,26 @@ jobs:
|
|||||||
apt-get update && apt-get install -y --no-install-recommends curl
|
apt-get update && apt-get install -y --no-install-recommends curl
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Generate release notes
|
||||||
|
id: notes
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
# Get commits since the previous tag (or the first commit if this is the first release).
|
||||||
|
prev_tag=$(git tag --sort=-version:refname | awk "NR==2" || echo "")
|
||||||
|
if [ -n "$prev_tag" ]; then
|
||||||
|
log=$(git log --oneline "$prev_tag"..HEAD)
|
||||||
|
else
|
||||||
|
log=$(git log --oneline --max-parents=0..HEAD)
|
||||||
|
fi
|
||||||
|
# Write notes to a file for later use.
|
||||||
|
cat > release-notes.txt <<EOF
|
||||||
|
**Full Changelog**: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/compare/${prev_tag:-$(git rev-list --max-parents=0 HEAD)}...${GITHUB_REF_NAME}
|
||||||
|
|
||||||
|
**Changes**:
|
||||||
|
$log
|
||||||
|
EOF
|
||||||
|
echo "Generated release notes"
|
||||||
|
|
||||||
- name: Create Gitea release + upload assets
|
- name: Create Gitea release + upload assets
|
||||||
env:
|
env:
|
||||||
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||||
@@ -125,21 +144,33 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
echo "Releasing $TAG to $GITEA_SERVER/$REPO"
|
echo "Releasing $TAG to $GITEA_SERVER/$REPO"
|
||||||
|
|
||||||
payload=$(jq -n --arg tag "$TAG" --arg name "$TAG" \
|
# Check if a release for this tag already exists (idempotency).
|
||||||
'{tag_name: $tag, name: $name, draft: false, prerelease: false}')
|
release_id=""
|
||||||
|
existing=$(curl --fail --silent --show-error -o /dev/null -w "%{http_code}" \
|
||||||
release_id=$(curl --fail --silent --show-error \
|
|
||||||
-H "Authorization: token $RELEASE_TOKEN" \
|
-H "Authorization: token $RELEASE_TOKEN" \
|
||||||
-H "Content-Type: application/json" \
|
"$GITEA_SERVER/api/v1/repos/$REPO/releases/tags/$TAG" \
|
||||||
-d "$payload" \
|
|| true)
|
||||||
"$GITEA_SERVER/api/v1/repos/$REPO/releases" \
|
if [ "$existing" = "200" ]; then
|
||||||
| jq -r '.id')
|
echo "Release for $TAG already exists — fetching existing id"
|
||||||
|
release_id=$(curl --fail --silent --show-error \
|
||||||
if [ -z "$release_id" ] || [ "$release_id" = "null" ]; then
|
-H "Authorization: token $RELEASE_TOKEN" \
|
||||||
echo "::error::failed to create release"
|
"$GITEA_SERVER/api/v1/repos/$REPO/releases/tags/$TAG" \
|
||||||
exit 1
|
| jq -r '.id')
|
||||||
|
else
|
||||||
|
payload=$(jq -n --arg tag "$TAG" --arg name "$TAG" \
|
||||||
|
'{tag_name: $tag, name: $name, 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
|
fi
|
||||||
echo "Created release id=$release_id"
|
|
||||||
|
|
||||||
# download-artifact@v3 nests each artifact under its own dir
|
# download-artifact@v3 nests each artifact under its own dir
|
||||||
# (artifacts/<artifact-name>/<file>), so recurse.
|
# (artifacts/<artifact-name>/<file>), so recurse.
|
||||||
|
|||||||
Reference in New Issue
Block a user