🏡 index : ~doyle/rgit.git

author Jordan Doyle <jordan@doyle.la> 2025-01-07 3:04:53.0 +07:00:00
committer Jordan Doyle <jordan@doyle.la> 2025-01-07 3:04:53.0 +07:00:00
commit
6da532458d7d6c15435d5d79c9616fc57efb15a0 [patch]
tree
a7a2d1e18c7e78365c32e400846dedbfb7354787
parent
1d58bbd905bd36b8e614b444d96705ecf3910554
download
6da532458d7d6c15435d5d79c9616fc57efb15a0.tar.gz

Run CI on a matrix of OSes and platforms



Diff

 flake.lock               | 21 +++++++++++++++++++++
 flake.nix                | 23 +++++++++++++++++++----
 .github/workflows/ci.yml | 91 +++++++++++++++++++++++++++++++++++++++++++-------------------------------------
 3 files changed, 66 insertions(+), 69 deletions(-)

diff --git a/flake.lock b/flake.lock
index 4822a91..dbf5152 100644
--- a/flake.lock
+++ a/flake.lock
@@ -47,6 +47,26 @@
        "type": "github"
      }

    },

    "nix-github-actions": {
      "inputs": {
        "nixpkgs": [
          "nixpkgs"
        ]

      },

      "locked": {
        "lastModified": 1731952509,
        "narHash": "sha256-p4gB3Rhw8R6Ak4eMl8pqjCPOLCZRqaehZxdZ/mbFClM=",
        "owner": "nix-community",
        "repo": "nix-github-actions",
        "rev": "7b5f051df789b6b20d259924d349a9ba3319b226",
        "type": "github"
      },

      "original": {
        "owner": "nix-community",
        "repo": "nix-github-actions",
        "type": "github"
      }

    },

    "nixpkgs": {
      "locked": {
        "lastModified": 1727731257,
@@ -84,6 +104,7 @@
        "advisory-db": "advisory-db",
        "crane": "crane",
        "helix": "helix",
        "nix-github-actions": "nix-github-actions",
        "nixpkgs": "nixpkgs",
        "treefmt-nix": "treefmt-nix",
        "utils": "utils"
diff --git a/flake.nix b/flake.nix
index 0b2c313..196e052 100644
--- a/flake.nix
+++ a/flake.nix
@@ -15,9 +15,20 @@
      url = "github:JordanForks/helix";
      flake = false;
    };

    nix-github-actions = {
      url = "github:nix-community/nix-github-actions";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { self, nixpkgs, utils, crane, advisory-db, treefmt-nix, helix }:
  outputs = { self, nixpkgs, utils, crane, advisory-db, treefmt-nix, helix, nix-github-actions }:
    {
      githubActions = nix-github-actions.lib.mkGithubMatrix {
        checks = { inherit (self.checks) x86_64-linux x86_64-darwin aarch64-darwin; };
      };
    }
    //
    utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs { inherit system; };
@@ -57,11 +68,11 @@
      in
      {
        checks = {
          inherit rgit;
          rgit-clippy = craneLib.cargoClippy buildArgs;
          rgit-doc = craneLib.cargoDoc buildArgs;
          rgit-audit = craneLib.cargoAudit { inherit advisory-db; src = cargoOnlySrc; };
          rgit-test = craneLib.cargoNextest (buildArgs // {
          build = rgit;
          clippy = craneLib.cargoClippy buildArgs;
          doc = craneLib.cargoDoc buildArgs;
          audit = craneLib.cargoAudit { inherit advisory-db; src = cargoOnlySrc; };
          test = craneLib.cargoNextest (buildArgs // {
            partitions = 1;
            partitionType = "count";
          });
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index e147f96..99e637d 100644
--- a/.github/workflows/ci.yml
+++ a/.github/workflows/ci.yml
@@ -1,69 +1,34 @@
on: [push, pull_request]

name: CI

jobs:
  check:
    name: Check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true
      - uses: actions-rs/cargo@v1
        with:
          command: check

  # TODO: the build for this started failing in 1b34a74891423e118c567368c95b7e04f3b9ca63
  #test:
  #  name: Test Suite
  #  runs-on: ubuntu-latest
  #  steps:
  #    - uses: actions/checkout@v2
  #    - uses: actions-rs/toolchain@v1
  #      with:
  #        profile: minimal
  #        toolchain: stable
  #        override: true
  #    - uses: actions-rs/cargo@v1
  #      with:
  #        command: test

  fmt:
    name: Rustfmt
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true
      - run: rustup component add rustfmt
      - uses: actions-rs/cargo@v1
        with:
          command: fmt

  cargo-deny:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - uses: EmbarkStudios/cargo-deny-action@v1
  nix-matrix:
    runs-on: ubuntu-latest
    outputs:
      matrix: ${{ steps.set-matrix.outputs.matrix }}
    steps:
      - uses: actions/checkout@v4
      - uses: cachix/install-nix-action@v30
      - id: set-matrix
        name: Generate Nix Matrix
        run: |

          set -Eeu
          matrix="$(nix eval --json '.#githubActions.matrix')"
          echo "matrix=$matrix" >> "$GITHUB_OUTPUT"

  clippy:
    name: Clippy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true
      - run: rustup component add clippy
      - uses: actions-rs/cargo@v1
        with:
          command: clippy
  check:
    name: ${{ matrix.name }} (${{ matrix.system }})
    needs: nix-matrix
    runs-on: ${{ matrix.os }}
    strategy:
      matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}}
    steps:
      - uses: actions/checkout@v4
      - uses: cachix/install-nix-action@v30
      - name: Authenticate with Cachix
        uses: cachix/cachix-action@v15
        with:
          name: rgit
          authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
      - run: nix build -L '.#${{ matrix.attr }}'