Skip to content

Commit

Permalink
ci/cd: use Nix for building and testing Pushup on GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
paulsmith committed Dec 15, 2023
1 parent 34a418a commit aeabcfd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 30 deletions.
22 changes: 7 additions & 15 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,12 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.20'
- name: Build
run: go build -o pushup -ldflags "-s -w -extldflags '-static'" -v
env:
CGO_ENABLED: 0
- name: Test
run: go test -v . ./_runtime
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v22
- run: nix flake check
- run: nix build
- name: Upload Pushup executable
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: pushup-exe
path: pushup
retention-days: 3
name: pushup
path: result/bin/pushup
37 changes: 22 additions & 15 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

outputs = { self, nixpkgs }:
let
version = "0.0.1"; # TODO(paulsmith): source from version.go
name = "pushup";
forEachSystem = fn:
nixpkgs.lib.genAttrs [ "x86_64-linux" "aarch64-darwin" "aarch64-linux" ]
(system:
Expand All @@ -14,29 +14,36 @@
inherit system;
});
in {
packages = forEachSystem ({ pkgs, system }: {
default = pkgs.buildGoModule rec {
pname = "pushup";
inherit version;
packages = forEachSystem ({ pkgs, system }:
let
pname = name;
version = "0.0.1"; # TODO(paulsmith): source from version.go
src = ./.;
vendorHash = null;
subPackages = ".";
CGO_ENABLED = 0;
doCheck = false;
nativeBuildInputs = with pkgs; [ makeWrapper ];
allowGoReference = true;
postInstall = ''
wrapProgram $out/bin/${pname} --prefix PATH : ${
pkgs.lib.makeBinPath (with pkgs; [ go ])
}
'';
meta = with nixpkgs.lib; {
description = "Pushup web framework for Go";
homepage = "https://pushup.adhoc.dev/";
license = licenses.mit;
};
};
});

in {
default = pkgs.buildGoModule rec {
inherit pname version src vendorHash subPackages CGO_ENABLED meta;
};

withGo = pkgs.buildGoModule rec {
inherit pname version src vendorHash subPackages CGO_ENABLED meta;
nativeBuildInputs = with pkgs; [ makeWrapper ];
allowGoReference = true;
postInstall = ''
wrapProgram $out/bin/${pname} --prefix PATH : ${
pkgs.lib.makeBinPath (with pkgs; [ go ])
}
'';
};
});

devShells = forEachSystem ({ pkgs, ... }: {
default =
Expand Down

0 comments on commit aeabcfd

Please sign in to comment.