feat(ci-cd): Use nix build to build the program

This commit is contained in:
Myzel394 2024-08-19 23:05:07 +02:00
parent 70b05e19fe
commit 91f0b0b52b
No known key found for this signature in database
GPG Key ID: DEC4AAB876F73185
2 changed files with 35 additions and 30 deletions

View File

@ -11,16 +11,14 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
# You can test your matrix by printing the current Go version
- name: Display Go version
run: go version
- name: Get dependencies - uses: cachix/install-nix-action@v27
run: go mod download with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Check Nix flake
run: nix flake check
- name: Run tests - name: Run tests
run: go test -v ./... run: nix develop --command bash -c 'go test ./...'

View File

@ -15,28 +15,35 @@
utils.lib.eachDefaultSystem (system: utils.lib.eachDefaultSystem (system:
let let
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
overlays = [ overlays = [
(final: prev: { (final: prev: {
go = prev.go_1_22; go = prev.go_1_22;
buildGoModule = prev.buildGo122Module; buildGoModule = prev.buildGo122Module;
}) })
gomod2nix.overlays.default gomod2nix.overlays.default
];
};
in {
defaultPackage = pkgs.buildGoModule {
pname = "github.com/Myzel394/config-lsp";
version = "v0.0.1";
src = ./.;
vendorHash = "sha256-KhyqogTyb3jNrGP+0Zmn/nfx+WxzjgcrFOp2vivFgT0=";
};
devShell = pkgs.mkShell {
buildInputs = [
pkgs.go_1_22
pkgs.wireguard-tools
]; ];
}; };
inputs = [
pkgs.go_1_22
pkgs.wireguard-tools
];
in {
packages = {
default = pkgs.buildGoModule {
nativeBuildInputs = inputs;
pname = "github.com/Myzel394/config-lsp";
version = "v0.0.1";
src = ./.;
vendorHash = "sha256-KhyqogTyb3jNrGP+0Zmn/nfx+WxzjgcrFOp2vivFgT0=";
checkPhase = ''
go test -v $(pwd)/...
'';
};
};
devShells.default = pkgs.mkShell {
buildInputs = inputs;
};
} }
); );
} }