numtide / blueprint

Nix without the glue code
38 stars 3 forks source link

GitHub Actions integration #21

Open zimbatm opened 1 month ago

zimbatm commented 1 month ago

Output the build matrix so it integrates with GitHub Actions a bit like https://github.com/nix-community/nix-github-actions

getchoo commented 1 month ago

Just a suggestion, but maybe nix-fast-build could be used instead? When I first saw how checks are automatically created here, it instantly reminded me of it -- as that's how jobs are handled by default there as well

I think this would be pretty feasible given it's in nixpkgs as of https://github.com/NixOS/nixpkgs/pull/313554, comes from a reputable member of the community, and would allow for simple workflows like this to work in any setup

name: CI

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

jobs:
  build:
    name: Build flake outputs

    strategy:
      matrix:
        os: [ ubuntu-latest, macos-latest ]

    runs-on: ${{ matrix.os }}

    steps:
      - name: Checkout repository
         uses: actions/checkout@v4

      - name: Install Nix
        uses: cachix/install-nix-action@v27

      # Optional. See https://nix.dev/tutorials/nixos/continuous-integration-github-actions
      # - name: Setup Nix cache
      #   uses: cachix/cachix-action@v15

      - name: Run nix-fast-build
         run: |
           nix run \
             --inputs-from . \
             nixpkgs#nix-fast-build -- \
             --no-nom \
             --skip-cached

I've been using something similar with hydraJobs and flake-parts personally for a while now and it has worked wonders. A more simplistic approach like this would also probably make things easier to implement internally, and make things easier to reproduce locally for users (i.e., they can run nix-fast-build themselves to debug CI)