90 lines
2.2 KiB
YAML
90 lines
2.2 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
typos:
|
|
name: "Typos"
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Check typos
|
|
uses: crate-ci/typos@master
|
|
with:
|
|
config: ./typos.toml
|
|
|
|
clippy:
|
|
name: "Clippy"
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: "Install Rust"
|
|
run: |
|
|
sudo apt update
|
|
DEBIAN_FRONTEND=noninteractive \
|
|
sudo apt install --yes rustup
|
|
rustup default stable
|
|
|
|
- name: Run clippy
|
|
run: cargo clippy --all-targets --all-features
|
|
|
|
buildandtest:
|
|
name: "Build and test"
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: "Install Rust"
|
|
run: |
|
|
sudo apt update
|
|
DEBIAN_FRONTEND=noninteractive \
|
|
sudo apt install --yes rustup
|
|
rustup default stable
|
|
|
|
- name: Build
|
|
run: cargo build --release
|
|
|
|
- name: Test
|
|
run: cargo test --release
|
|
|
|
check-version:
|
|
name: Check version
|
|
runs-on: ubuntu-latest
|
|
# Skip this job on push to main
|
|
if: github.event_name != 'push' || github.ref != 'refs/heads/main'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: check version
|
|
run: |
|
|
# Get base branch (usually main)
|
|
BASE_REF="${{ github.base_ref }}"
|
|
if [ -z "$BASE_REF" ]; then
|
|
BASE_REF="main"
|
|
fi
|
|
|
|
# Get current version
|
|
CURRENT_VERSION=$(grep -m 1 '^version = ' Cargo.toml | sed 's/version = "\(.*\)"/\1/')
|
|
echo "Current version: $CURRENT_VERSION"
|
|
|
|
# Get version from base branch
|
|
git fetch origin $BASE_REF
|
|
BASE_VERSION=$(git show origin/$BASE_REF:Cargo.toml | grep -m 1 '^version = ' | sed 's/version = "\(.*\)"/\1/')
|
|
echo "Base version: $BASE_VERSION"
|
|
|
|
# Check if version changed
|
|
if [ "$CURRENT_VERSION" = "$BASE_VERSION" ]; then
|
|
echo "::error::Version in Cargo.toml has not been changed."
|
|
exit 1
|
|
else
|
|
echo "Version has been updated from $BASE_VERSION to $CURRENT_VERSION"
|
|
fi
|