Skip to content

Commit

Permalink
Remove superfluous deps, use cargo-nextest (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
veehaitch authored Aug 5, 2024
1 parent 420168e commit bafab8f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 35 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: CI

on:
pull_request:
branches: [main]
push:
branches: [main]

jobs:
checks-linux:
name: CI (linux)
linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -22,13 +23,12 @@ jobs:
run: nix flake check -L
- name: Build Codecov report
run: |
nix build -L .#checks.x86_64-linux.systemd-credsubst-codecov
cp -L ./result ./codecov.json
nix build -L .#checks.x86_64-linux.systemd-credsubst-nextest
- name: Upload to Codecov
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
files: ./codecov.json
files: ./result/codecov.json
token: ${{ secrets.CODECOV_TOKEN }}
- name: Build static binary
run: nix build -L .#systemd-credsubst-static
Expand All @@ -40,8 +40,7 @@ jobs:
if-no-files-found: error
retention-days: ${{ github.event_name == 'pull_request' && 5 || 0 }}

checks-macos:
name: CI (macos)
macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
Expand Down
39 changes: 11 additions & 28 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,6 @@
commonArgs = {
inherit src;
strictDeps = true;

nativeBuildInputs = with pkgs; [
cmake
perl
pkg-config
];

buildInputs = (with pkgs; [
openssl
]) ++ lib.optionals pkgs.stdenv.isDarwin (with pkgs.darwin.apple_sdk.frameworks; [
Security
SystemConfiguration
]);

doCheck = false;
};

# Build *just* the cargo dependencies, so we can reuse
Expand All @@ -78,6 +63,7 @@
{
packages.systemd-credsubst = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;
doCheck = false;
meta.mainProgram = "systemd-credsubst";
passthru = { inherit cargoArtifacts commonArgs; };
});
Expand Down Expand Up @@ -116,6 +102,16 @@
systemd-credsubst-deny = craneLib.cargoDeny {
inherit src;
};

# Run tests with cargo-nextest and, on Linux, with coverage for Codecov
systemd-credsubst-nextest = craneLib.cargoNextest (commonArgs // {
inherit cargoArtifacts;
partitions = 1;
partitionType = "count";
} // lib.optionalAttrs pkgs.stdenv.isLinux {
withLlvmCov = true;
cargoLlvmCovExtraArgs = ''--codecov --output-path "$out/codecov.json"'';
});
};

apps.systemd-credsubst = flake-utils.lib.mkApp {
Expand All @@ -135,24 +131,11 @@
(flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (system:
let pkgs = pkgsFor system; in {
packages.systemd-credsubst-static = self.packages.${system}.systemd-credsubst.overrideAttrs (_: {
strictDeps = true;

CARGO_BUILD_TARGET = pkgs.pkgsStatic.stdenv.targetPlatform.rust.cargoShortTarget;
CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static";
# Tell openssl-sys where to find static OpenSSL
OPENSSL_LIB_DIR = "${pkgs.pkgsStatic.openssl.out}/lib";
OPENSSL_INCLUDE_DIR = "${pkgs.pkgsStatic.openssl.dev}";
});

packages.default = self.packages.${system}.systemd-credsubst-static;

checks.systemd-credsubst-codecov = pkgs.craneLib.cargoLlvmCov (
self.packages.${system}.systemd-credsubst.passthru.commonArgs // {
inherit (self.packages.${system}.systemd-credsubst.passthru) cargoArtifacts;
cargoLlvmCovExtraArgs = ''--codecov --output-path "$out"'';
}
);

checks.systemd-credsubst-nixos-test = pkgs.callPackage ./nixos/tests/nixos-test-systemd-credsubst.nix {
systemd-credsubst = self.packages.${system}.default;
};
Expand Down

0 comments on commit bafab8f

Please sign in to comment.