ci: add Woodpecker checks, Cachix config and conventional commit hooks
This commit is contained in:
1 parent
e0169bf9f2
commit
b7e30ec148
5 files changed
+181
-2
No files matched your search
@@ -0,0 +1,15 @@
|
||||
default_install_hook_types: [pre-commit, commit-msg]
|
||||
repos:
|
||||
- repo: https://github.com/compilerla/conventional-pre-commit
|
||||
rev: v4.4.0
|
||||
hooks:
|
||||
- id: conventional-pre-commit
|
||||
stages: [commit-msg]
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: rustfmt-formatting
|
||||
name: rustfmt formatting
|
||||
entry: cargo fmt --all --check
|
||||
language: system
|
||||
types: [rust]
|
||||
pass_filenames: false
|
||||
@@ -0,0 +1,87 @@
|
||||
when:
|
||||
- repo: wvhulle/bootvine
|
||||
event: [pull_request, push, manual]
|
||||
|
||||
variables:
|
||||
- &nix_config
|
||||
NIX_CONFIG: |
|
||||
experimental-features = nix-command flakes
|
||||
build-users-group =
|
||||
accept-flake-config = true
|
||||
- &cache_writing_env
|
||||
<<: *nix_config
|
||||
CACHIX_AUTH_TOKEN:
|
||||
from_secret: cachix_auth_token
|
||||
- &on_main_branch
|
||||
- event: [push, manual]
|
||||
branch: main
|
||||
- &off_main_branch
|
||||
- event: pull_request
|
||||
- event: [push, manual]
|
||||
branch:
|
||||
exclude: main
|
||||
- &on_pull_requests
|
||||
- event: pull_request
|
||||
|
||||
steps:
|
||||
- name: build-test-and-cache-bootvine
|
||||
image: nixos/nix:latest
|
||||
depends_on: []
|
||||
when: *on_main_branch
|
||||
environment: *cache_writing_env
|
||||
commands:
|
||||
- nix run .#build-and-push-to-cachix -- .#checks.x86_64-linux.bootvine-build
|
||||
|
||||
- name: build-and-test-bootvine
|
||||
image: nixos/nix:latest
|
||||
depends_on: []
|
||||
when: *off_main_branch
|
||||
environment: *nix_config
|
||||
commands:
|
||||
- nix build --print-build-logs .#checks.x86_64-linux.bootvine-build
|
||||
|
||||
- name: build-and-cache-repo-tasks
|
||||
image: nixos/nix:latest
|
||||
depends_on: []
|
||||
when: *on_main_branch
|
||||
environment: *cache_writing_env
|
||||
commands:
|
||||
- nix run .#build-and-push-to-cachix -- .#checks.x86_64-linux.repo-tasks-build
|
||||
|
||||
- name: build-repo-tasks
|
||||
image: nixos/nix:latest
|
||||
depends_on: []
|
||||
when: *off_main_branch
|
||||
environment: *nix_config
|
||||
commands:
|
||||
- nix build --print-build-logs .#checks.x86_64-linux.repo-tasks-build
|
||||
|
||||
- name: lint-rust-with-clippy
|
||||
image: nixos/nix:latest
|
||||
depends_on: []
|
||||
environment: *nix_config
|
||||
commands:
|
||||
- nix build --print-build-logs .#checks.x86_64-linux.clippy-lints
|
||||
|
||||
- name: check-rust-formatting
|
||||
image: nixos/nix:latest
|
||||
depends_on: []
|
||||
environment: *nix_config
|
||||
commands:
|
||||
- nix build --print-build-logs .#checks.x86_64-linux.rustfmt-formatting
|
||||
|
||||
- name: evaluate-flake-outputs
|
||||
image: nixos/nix:latest
|
||||
depends_on: []
|
||||
environment: *nix_config
|
||||
commands:
|
||||
- nix flake check --no-build
|
||||
|
||||
- name: check-conventional-commit-messages
|
||||
image: nixos/nix:latest
|
||||
depends_on: []
|
||||
when: *on_pull_requests
|
||||
environment: *nix_config
|
||||
commands:
|
||||
- git fetch --quiet origin "$${CI_COMMIT_TARGET_BRANCH}"
|
||||
- nix run .#check-conventional-commits -- FETCH_HEAD..HEAD
|
||||
@@ -15,6 +15,25 @@ cargo fmt --all
|
||||
Clippy runs with the pedantic lints and forbids absolute paths; formatting
|
||||
needs the nightly toolchain the dev shell provides.
|
||||
|
||||
Commit messages follow [Conventional Commits](https://www.conventionalcommits.org).
|
||||
jj does not run git hooks, so check the commits you are about to push with:
|
||||
|
||||
```sh
|
||||
nix run .#check-conventional-commits -- origin/main..HEAD
|
||||
```
|
||||
|
||||
Git users can install the same commit-message check and a formatting check as
|
||||
hooks with `prek install` (from the dev shell) or `pre-commit install`.
|
||||
|
||||
## Continuous integration
|
||||
|
||||
`.woodpecker/rust-and-flake-checks.yaml` runs on Codeberg for every push and
|
||||
pull request: the bootvine build with its tests, the xtask build, clippy,
|
||||
rustfmt, an evaluation of every flake output, and the commit-message check on
|
||||
pull requests. Builds on `main` are pushed to the `wvhulle` Cachix cache, which
|
||||
`nixConfig` in `flake.nix` offers as a substituter. The two VM checks need KVM,
|
||||
which Codeberg's runners lack, so they only run locally.
|
||||
|
||||
## Testing
|
||||
|
||||
| What | Command |
|
||||
|
||||
@@ -10,6 +10,7 @@ let
|
||||
fileset = lib.fileset.unions [
|
||||
(craneLib.fileset.commonCargoSources ./.)
|
||||
./system-files
|
||||
./.rustfmt.toml
|
||||
];
|
||||
};
|
||||
strictDeps = true;
|
||||
@@ -23,6 +24,19 @@ let
|
||||
args: craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; } // args);
|
||||
in
|
||||
{
|
||||
rustfmt-formatting = craneLib.cargoFmt {
|
||||
inherit (commonArgs) src;
|
||||
cargoExtraArgs = "--all";
|
||||
};
|
||||
|
||||
clippy-lints = craneLib.cargoClippy (
|
||||
commonArgs
|
||||
// {
|
||||
inherit cargoArtifacts;
|
||||
cargoClippyExtraArgs = "--workspace --all-targets -- --deny warnings";
|
||||
}
|
||||
);
|
||||
|
||||
bootvine = buildWorkspaceMember {
|
||||
cargoExtraArgs = "-p bootvine";
|
||||
postInstall = ''
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
{
|
||||
description = "bootvine — live dependency tree of systemd jobs on the boot console";
|
||||
|
||||
nixConfig = {
|
||||
extra-substituters = [ "https://wvhulle.cachix.org" ];
|
||||
extra-trusted-public-keys = [
|
||||
"wvhulle.cachix.org-1:heXx8DZMiRsKUx6l1TxNoF+Nmtmz66QEdsonQzc1ir0="
|
||||
];
|
||||
};
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
crane.url = "github:ipetkov/crane";
|
||||
@@ -93,12 +100,38 @@
|
||||
}
|
||||
);
|
||||
};
|
||||
build-and-push-to-cachix = {
|
||||
type = "app";
|
||||
meta.description = "Build flake outputs and push everything built to the wvhulle Cachix cache";
|
||||
program = lib.getExe (
|
||||
pkgs.writeShellApplication {
|
||||
name = "build-and-push-to-cachix";
|
||||
runtimeInputs = [ pkgs.cachix ];
|
||||
text = ''exec cachix watch-exec wvhulle -- nix build --print-build-logs "$@"'';
|
||||
}
|
||||
);
|
||||
};
|
||||
check-conventional-commits = {
|
||||
type = "app";
|
||||
meta.description = "Check that the commit messages in a git revision range are conventional commits";
|
||||
program = lib.getExe (
|
||||
pkgs.writeShellApplication {
|
||||
name = "check-conventional-commits";
|
||||
runtimeInputs = [
|
||||
pkgs.convco
|
||||
pkgs.gitMinimal
|
||||
];
|
||||
text = ''exec convco check "$@"'';
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
checks = forEachSystem (
|
||||
{ pkgs, builds, ... }:
|
||||
{
|
||||
inherit (builds) rustfmt-formatting clippy-lints;
|
||||
bootvine-build = builds.bootvine;
|
||||
repo-tasks-build = builds.repo-tasks;
|
||||
vm-boot-and-shutdown = pkgs.testers.runNixOSTest (
|
||||
@@ -111,9 +144,20 @@
|
||||
);
|
||||
|
||||
devShells = forEachSystem (
|
||||
{ craneLib, builds, ... }:
|
||||
{
|
||||
default = craneLib.devShell { inputsFrom = [ builds.bootvine ]; };
|
||||
pkgs,
|
||||
craneLib,
|
||||
builds,
|
||||
...
|
||||
}:
|
||||
{
|
||||
default = craneLib.devShell {
|
||||
inputsFrom = [ builds.bootvine ];
|
||||
packages = [
|
||||
pkgs.prek
|
||||
pkgs.convco
|
||||
];
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user