Merge pull request #260 from nix-community/no-garnix

CI: Garnix -> Github Actions
This commit is contained in:
adisbladis 2023-11-04 14:11:17 +13:00 committed by GitHub
commit 20a24e8b10
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 114 additions and 65 deletions

View file

@ -0,0 +1,60 @@
name: Nix actions
on:
pull_request:
push:
branches:
- main
- staging
- release-*
jobs:
nix-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v23
- id: set-matrix
name: Generate Nix Matrix
run: |
set -Eeu
echo "matrix=$(nix eval --json '.#githubActions.matrix')" >> "$GITHUB_OUTPUT"
nix-build:
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@v23
- run: nix build -L ".#${{ matrix.attr }}"
tests:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
# Nix Flakes doesn't work on shallow clones
fetch-depth: 0
- uses: cachix/install-nix-action@v23
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
extra_nix_config: |
accept-flake-config = true
- name: Build
run: nix develop -c bash -c 'meson build && cd build && ninja'
- name: Run tests
run: nix develop -c pytest ./tests
collect:
runs-on: ubuntu-latest
needs:
- nix-build
- tests
steps:
- run: true

View file

@ -1,28 +0,0 @@
name: "Tests"
on:
pull_request:
push:
branches:
- main
- staging
- release-*
jobs:
tests:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
# Nix Flakes doesn't work on shallow clones
fetch-depth: 0
- uses: cachix/install-nix-action@v23
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
extra_nix_config: |
accept-flake-config = true
- name: Build
run: nix develop -c bash -c 'meson build && cd build && ninja'
- name: Run tests
run: nix develop -c pytest ./tests

View file

@ -1,23 +0,0 @@
name: update-flake-lock
on:
workflow_dispatch: # allows manual triggering
schedule:
- cron: '0 0 * * 1,4' # Run twice a week
jobs:
lockfile:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v23
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Update flake.lock
uses: DeterminateSystems/update-flake-lock@v20
with:
token: ${{ secrets.GH_TOKEN_FOR_UPDATES }}
pr-labels: | # Labels to be set on the PR
merge-queue

View file

@ -1,18 +1,15 @@
queue_rules: queue_rules:
- name: default - name: default
merge_conditions: merge_conditions:
- check-success=Evaluate flake.nix - author=renovate[bot]
- check-success=check treefmt [x86_64-linux] - check-success=collect
- check-success=devShell default [x86_64-linux]
- check-success=package default [x86_64-linux]
- check-success=package nix-eval-jobs [x86_64-linux]
- check-success=tests (macos-latest)
- check-success=tests (ubuntu-latest)
defaults: defaults:
actions: actions:
queue: queue:
allow_merging_configuration_change: true allow_merging_configuration_change: true
method: rebase method: rebase
pull_request_rules: pull_request_rules:
- name: merge using the merge queue - name: merge using the merge queue
conditions: conditions:

View file

@ -20,6 +20,26 @@
"type": "github" "type": "github"
} }
}, },
"nix-github-actions": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1698974481,
"narHash": "sha256-yPncV9Ohdz1zPZxYHQf47S8S0VrnhV7nNhCawY46hDA=",
"owner": "nix-community",
"repo": "nix-github-actions",
"rev": "4bb5e752616262457bc7ca5882192a564c0472d2",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nix-github-actions",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1698977350, "lastModified": 1698977350,
@ -39,6 +59,7 @@
"root": { "root": {
"inputs": { "inputs": {
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"nix-github-actions": "nix-github-actions",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"treefmt-nix": "treefmt-nix" "treefmt-nix": "treefmt-nix"
} }

View file

@ -6,13 +6,8 @@
inputs.flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs"; inputs.flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
inputs.treefmt-nix.url = "github:numtide/treefmt-nix"; inputs.treefmt-nix.url = "github:numtide/treefmt-nix";
inputs.treefmt-nix.inputs.nixpkgs.follows = "nixpkgs"; inputs.treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
inputs.nix-github-actions.url = "github:nix-community/nix-github-actions";
nixConfig.extra-substituters = [ inputs.nix-github-actions.inputs.nixpkgs.follows = "nixpkgs";
"https://cache.garnix.io"
];
nixConfig.extra-trusted-public-keys = [
"cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="
];
outputs = inputs @ { flake-parts, ... }: outputs = inputs @ { flake-parts, ... }:
let let
@ -24,6 +19,14 @@
{ {
systems = inputs.nixpkgs.lib.systems.flakeExposed; systems = inputs.nixpkgs.lib.systems.flakeExposed;
imports = [ inputs.treefmt-nix.flakeModule ]; imports = [ inputs.treefmt-nix.flakeModule ];
flake.githubActions = inputs.nix-github-actions.lib.mkGithubMatrix {
checks = {
inherit (self.checks) x86_64-linux;
x86_64-darwin = builtins.removeAttrs self.checks.x86_64-darwin [ "treefmt" ];
};
};
perSystem = { pkgs, self', ... }: perSystem = { pkgs, self', ... }:
let let
drvArgs = { drvArgs = {
@ -37,6 +40,10 @@
packages.clangStdenv-nix-eval-jobs = pkgs.callPackage ./default.nix (drvArgs // { stdenv = pkgs.clangStdenv; }); packages.clangStdenv-nix-eval-jobs = pkgs.callPackage ./default.nix (drvArgs // { stdenv = pkgs.clangStdenv; });
packages.default = self'.packages.nix-eval-jobs; packages.default = self'.packages.nix-eval-jobs;
devShells.default = pkgs.callPackage ./shell.nix drvArgs; devShells.default = pkgs.callPackage ./shell.nix drvArgs;
checks = builtins.removeAttrs self'.packages [ "default" ] // {
shell = self'.devShells.default;
};
}; };
}; };
} }

15
renovate.json Normal file
View file

@ -0,0 +1,15 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base"
],
"lockFileMaintenance": {
"enabled": true,
"extends": [
"schedule:weekly"
]
},
"nix": {
"enabled": true
}
}