# Gitea Actions workflow for the Rust workspace. # Self-hosted runner friendly. # Does not use external GitHub Actions. name: bat-rust on: push: branches: - "**" pull_request: workflow_dispatch: jobs: rust: name: Build and test Rust runs-on: linux env: CARGO_TERM_COLOR: always RUST_BACKTRACE: 1 BAT_SKIP_ENV_FILE: "1" steps: - name: Checkout shell: bash run: | set -euo pipefail : "${GITHUB_SERVER_URL:?GITHUB_SERVER_URL is required}" : "${GITHUB_REPOSITORY:?GITHUB_REPOSITORY is required}" : "${GITHUB_SHA:?GITHUB_SHA is required}" repo_url="${GITHUB_SERVER_URL%/}/${GITHUB_REPOSITORY}.git" if [ -d .git ]; then git remote set-url origin "${repo_url}" else git init . git remote add origin "${repo_url}" fi ref="${GITHUB_REF:-${GITHUB_SHA}}" git fetch \ --no-tags \ --depth=1 \ origin \ "${ref}" \ || git fetch \ --no-tags \ --depth=1 \ origin \ "${GITHUB_SHA}" git checkout --force --detach FETCH_HEAD git submodule update --init --recursive - name: Show tool versions shell: bash run: | set -euo pipefail source /var/lib/act_runner/env.sh command -v git command -v rustc command -v cargo rustc --version cargo --version rustfmt --version cargo clippy --version - name: Check formatting shell: bash run: | source /var/lib/act_runner/env.sh cargo fmt --all -- --check - name: Check workspace shell: bash run: | source /var/lib/act_runner/env.sh cargo check --workspace --locked - name: Build workspace shell: bash run: | source /var/lib/act_runner/env.sh cargo build \ --workspace \ --release \ --locked - name: Run clippy shell: bash run: | source /var/lib/act_runner/env.sh cargo clippy \ --workspace \ --all-targets \ --locked \ -- -D warnings - name: Run tests shell: bash run: | source /var/lib/act_runner/env.sh cargo test \ --workspace \ --locked - name: Package binary shell: bash run: | set -euo pipefail mkdir -p artifact cp target/release/bat artifact/ tar \ -czf \ bat-linux-x86_64.tar.gz \ -C artifact \ bat sha256sum \ bat-linux-x86_64.tar.gz \ > bat-linux-x86_64.sha256 - name: Prepare artifact shell: bash run: | set -euo pipefail mkdir upload cp bat-linux-x86_64.tar.gz upload/ cp bat-linux-x86_64.sha256 upload/ cd upload zip -q \ ../bat-linux-x86_64.zip \ * cd .. ls -lh bat-linux-x86_64.zip go-api: name: Build and test Go API runs-on: linux env: GOCACHE: /tmp/bat-go-cache steps: - name: Checkout shell: bash run: | set -euo pipefail : "${GITHUB_SERVER_URL:?GITHUB_SERVER_URL is required}" : "${GITHUB_REPOSITORY:?GITHUB_REPOSITORY is required}" : "${GITHUB_SHA:?GITHUB_SHA is required}" repo_url="${GITHUB_SERVER_URL%/}/${GITHUB_REPOSITORY}.git" if [ -d .git ]; then git remote set-url origin "${repo_url}" else git init . git remote add origin "${repo_url}" fi ref="${GITHUB_REF:-${GITHUB_SHA}}" git fetch \ --no-tags \ --depth=1 \ origin \ "${ref}" \ || git fetch \ --no-tags \ --depth=1 \ origin \ "${GITHUB_SHA}" git checkout --force --detach FETCH_HEAD git submodule update --init --recursive - name: Show Go tool version shell: bash run: | set -euo pipefail source /var/lib/act_runner/env.sh command -v go go version - name: Run Go API tests shell: bash run: | set -euo pipefail source /var/lib/act_runner/env.sh make test-go-api - name: Check Go formatting shell: bash run: | set -euo pipefail source /var/lib/act_runner/env.sh files="$(git ls-files '*.go')" test -n "${files}" test -z "$(gofmt -l ${files})" - name: Run Go API vet shell: bash run: | set -euo pipefail source /var/lib/act_runner/env.sh go vet ./internal/api/... ./internal/backendrpc/... ./cmd/bat-api/... - name: Build Go API shell: bash run: | set -euo pipefail source /var/lib/act_runner/env.sh go build -o /tmp/bat-api ./cmd/bat-api - name: Required Go lint shell: bash run: | set -euo pipefail source /var/lib/act_runner/env.sh source scripts/ci-versions.sh command -v golangci-lint >/dev/null 2>&1 actual="$(golangci_lint_actual_version)" test "${actual}" = "${GOLANGCI_LINT_VERSION}" export XDG_CACHE_HOME="${XDG_CACHE_HOME:-/tmp/bat-xdg-cache}" golangci-lint run ./... - name: Run documentation status gate shell: bash run: | set -euo pipefail make check-docs