ci: improvements in scripting and testing
This commit is contained in:
parent
7ac8b90f27
commit
c447577eee
3 changed files with 45 additions and 43 deletions
|
@ -15,30 +15,22 @@ jobs:
|
||||||
# rust code must be formatted for standardisation
|
# rust code must be formatted for standardisation
|
||||||
lint_fmt:
|
lint_fmt:
|
||||||
# build it using teh base nixos system, helps with caching
|
# build it using teh base nixos system, helps with caching
|
||||||
runs-on: docker
|
runs-on: nix
|
||||||
steps:
|
steps:
|
||||||
# get the repo first
|
# get the repo first
|
||||||
- uses: https://code.forgejo.org/actions/checkout@v4
|
- uses: https://code.forgejo.org/actions/checkout@v4
|
||||||
- uses: https://github.com/actions-rust-lang/setup-rust-toolchain@v1
|
- run: nix build .#fmt --verbose
|
||||||
with:
|
|
||||||
components: rustfmt
|
|
||||||
cache: false
|
|
||||||
- uses: https://github.com/actions-rust-lang/rustfmt@v1
|
|
||||||
|
|
||||||
# clippy is incredibly useful for making yer code better
|
# clippy is incredibly useful for making yer code better
|
||||||
lint_clippy:
|
lint_clippy:
|
||||||
# build it using teh base nixos system, helps with caching
|
# build it using teh base nixos system, helps with caching
|
||||||
runs-on: docker
|
runs-on: nix
|
||||||
permissions:
|
permissions:
|
||||||
checks: write
|
checks: write
|
||||||
steps:
|
steps:
|
||||||
# get the repo first
|
# get the repo first
|
||||||
- uses: https://code.forgejo.org/actions/checkout@v4
|
- uses: https://code.forgejo.org/actions/checkout@v4
|
||||||
- uses: https://github.com/actions-rust-lang/setup-rust-toolchain@v1
|
- run: nix build .#clippy --verbose
|
||||||
with:
|
|
||||||
components: clippy
|
|
||||||
cache: false
|
|
||||||
- run: cargo clippy
|
|
||||||
|
|
||||||
build:
|
build:
|
||||||
# build it using teh base nixos system, helps with caching
|
# build it using teh base nixos system, helps with caching
|
||||||
|
|
26
flake.lock
26
flake.lock
|
@ -5,11 +5,11 @@
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1692351612,
|
"lastModified": 1721727458,
|
||||||
"narHash": "sha256-KTGonidcdaLadRnv9KFgwSMh1ZbXoR/OBmPjeNMhFwU=",
|
"narHash": "sha256-r/xppY958gmZ4oTfLiHN0ZGuQ+RSTijDblVgVLFi1mw=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "naersk",
|
"repo": "naersk",
|
||||||
"rev": "78789c30d64dea2396c9da516bbcc8db3a475207",
|
"rev": "3fb418eaf352498f6b6c30592e3beb63df42ef11",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -20,11 +20,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1693060755,
|
"lastModified": 1723151389,
|
||||||
"narHash": "sha256-KNsbfqewEziFJEpPR0qvVz4rx0x6QXxw1CcunRhlFdk=",
|
"narHash": "sha256-9AVY0ReCmSGXHrlx78+1RrqcDgVSRhHUKDVV1LLBy28=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "c66ccfa00c643751da2fd9290e096ceaa30493fc",
|
"rev": "13fe00cb6c75461901f072ae62b5805baef9f8b2",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -34,16 +34,16 @@
|
||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1693087214,
|
"lastModified": 1722995383,
|
||||||
"narHash": "sha256-Kn1SSqRfPpqcI1MDy82JXrPT1WI8c03TA2F0xu6kS+4=",
|
"narHash": "sha256-UzuXo7ZM8ZK0SkWFhHocKkLSGQPHS4JxaE1jvVR4fUo=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "f155f0cf4ea43c4e3c8918d2d327d44777b6cad4",
|
"rev": "957d95fc8b9bf1eb60d43f8d2eba352b71bbf2be",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"id": "nixpkgs",
|
"id": "nixpkgs",
|
||||||
"ref": "nixos-23.05",
|
"ref": "nixos-unstable",
|
||||||
"type": "indirect"
|
"type": "indirect"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -74,11 +74,11 @@
|
||||||
"systems": "systems"
|
"systems": "systems"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1692799911,
|
"lastModified": 1710146030,
|
||||||
"narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=",
|
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44",
|
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
40
flake.nix
40
flake.nix
|
@ -2,16 +2,11 @@
|
||||||
description = "Skynet Discord Bot";
|
description = "Skynet Discord Bot";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "nixpkgs/nixos-23.05";
|
nixpkgs.url = "nixpkgs/nixos-unstable";
|
||||||
naersk.url = "github:nix-community/naersk";
|
naersk.url = "github:nix-community/naersk";
|
||||||
utils.url = "github:numtide/flake-utils";
|
utils.url = "github:numtide/flake-utils";
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
sudo nano /etc/nix/nix.conf
|
|
||||||
trusted-users = {username}
|
|
||||||
*/
|
|
||||||
|
|
||||||
nixConfig = {
|
nixConfig = {
|
||||||
extra-substituters = "https://nix-cache.skynet.ie/skynet-cache";
|
extra-substituters = "https://nix-cache.skynet.ie/skynet-cache";
|
||||||
extra-trusted-public-keys = "skynet-cache:zMFLzcRZPhUpjXUy8SF8Cf7KGAZwo98SKrzeXvdWABo=";
|
extra-trusted-public-keys = "skynet-cache:zMFLzcRZPhUpjXUy8SF8Cf7KGAZwo98SKrzeXvdWABo=";
|
||||||
|
@ -25,20 +20,35 @@
|
||||||
}:
|
}:
|
||||||
utils.lib.eachDefaultSystem (
|
utils.lib.eachDefaultSystem (
|
||||||
system: let
|
system: let
|
||||||
pkgs = nixpkgs.legacyPackages."${system}";
|
pkgs = (import nixpkgs) {inherit system;};
|
||||||
naersk-lib = naersk.lib."${system}";
|
naersk' = pkgs.callPackage naersk {};
|
||||||
package_name = "skynet_discord_bot";
|
package_name = "skynet_discord_bot";
|
||||||
desc = "Skynet Discord Bot";
|
desc = "Skynet Discord Bot";
|
||||||
in rec {
|
|
||||||
# `nix build`
|
|
||||||
packages."${package_name}" = naersk-lib.buildPackage {
|
|
||||||
pname = "${package_name}";
|
|
||||||
root = ./.;
|
|
||||||
|
|
||||||
buildInputs = with pkgs; [
|
buildInputs = with pkgs; [
|
||||||
openssl
|
openssl
|
||||||
pkg-config
|
pkg-config
|
||||||
|
rustfmt
|
||||||
];
|
];
|
||||||
|
in rec {
|
||||||
|
packages = {
|
||||||
|
# For `nix build` & `nix run`:
|
||||||
|
default = naersk'.buildPackage {
|
||||||
|
pname = "${package_name}";
|
||||||
|
src = ./.;
|
||||||
|
buildInputs = buildInputs;
|
||||||
|
};
|
||||||
|
# Run `nix build .#fmt` to run tests
|
||||||
|
fmt = naersk'.buildPackage {
|
||||||
|
src = ./.;
|
||||||
|
mode = "fmt";
|
||||||
|
buildInputs = buildInputs;
|
||||||
|
};
|
||||||
|
# Run `nix build .#clippy` to lint code
|
||||||
|
clippy = naersk'.buildPackage {
|
||||||
|
src = ./.;
|
||||||
|
mode = "clippy";
|
||||||
|
buildInputs = buildInputs;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultPackage = packages."${package_name}";
|
defaultPackage = packages."${package_name}";
|
||||||
|
@ -52,7 +62,7 @@
|
||||||
|
|
||||||
# `nix develop`
|
# `nix develop`
|
||||||
devShell = pkgs.mkShell {
|
devShell = pkgs.mkShell {
|
||||||
nativeBuildInputs = with pkgs; [rustc cargo pkg-config openssl];
|
nativeBuildInputs = with pkgs; [rustc cargo pkg-config openssl rustfmt];
|
||||||
};
|
};
|
||||||
|
|
||||||
nixosModule = {
|
nixosModule = {
|
||||||
|
|
Loading…
Reference in a new issue