feat(ci): enable github action ci

This commit is contained in:
Samuka007 2025-03-27 17:24:16 +08:00 committed by Samuel Dai
parent 3a513b525c
commit 35fb4a8232
5 changed files with 84 additions and 5 deletions

View File

@ -0,0 +1,32 @@
name: Nix Flake actions
on:
pull_request:
push:
jobs:
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"
nix-build:
name: ${{ matrix.name }} (${{ matrix.system }})
needs: nix-matrix
runs-on: ${{ matrix.os }}
continue-on-error: true
strategy:
matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
- run: nix build -L '.#${{ matrix.attr }}'

2
Cargo.lock generated
View File

@ -2028,7 +2028,7 @@ checksum = "106dd99e98437432fed6519dedecfade6a06a73bb7b2a1e019fdd2bee5778d94"
[[package]] [[package]]
name = "provider" name = "provider"
version = "0.0.1" version = "0.1.0"
dependencies = [ dependencies = [
"actix-service", "actix-service",
"actix-web", "actix-web",

View File

@ -3,7 +3,7 @@ members = ["crates/*"]
resolver = "3" resolver = "3"
[workspace.package] [workspace.package]
version = "0.0.1" version = "0.1.0"
authors = ["sparkzky", "Samuka007"] authors = ["sparkzky", "Samuka007"]
[workspace.metadata.crane] [workspace.metadata.crane]

35
flake.lock generated
View File

@ -33,7 +33,39 @@
"type": "github" "type": "github"
} }
}, },
"nix-github-actions": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1737420293,
"narHash": "sha256-F1G5ifvqTpJq7fdkT34e/Jy9VCyzd5XfJ9TO8fHhJWE=",
"owner": "nix-community",
"repo": "nix-github-actions",
"rev": "f4158fa080ef4503c8f4c820967d946c2af31ec9",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nix-github-actions",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": {
"lastModified": 1688646010,
"narHash": "sha256-kCeza5eKI2NEi8k0EoeZfv3lN1r1Vwx+L/VA6I8tmG4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5daaa32204e9c46b05cd709218b7ba733d07e80c",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1739866667, "lastModified": 1739866667,
"narHash": "sha256-EO1ygNKZlsAC9avfcwHkKGMsmipUk1Uc0TbrEZpkn64=", "narHash": "sha256-EO1ygNKZlsAC9avfcwHkKGMsmipUk1Uc0TbrEZpkn64=",
@ -53,7 +85,8 @@
"inputs": { "inputs": {
"crane": "crane", "crane": "crane",
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"nixpkgs": "nixpkgs", "nix-github-actions": "nix-github-actions",
"nixpkgs": "nixpkgs_2",
"rust-overlay": "rust-overlay" "rust-overlay": "rust-overlay"
} }
}, },

View File

@ -5,13 +5,14 @@
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
crane.url = "github:ipetkov/crane"; crane.url = "github:ipetkov/crane";
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
nix-github-actions.url = "github:nix-community/nix-github-actions";
rust-overlay = { rust-overlay = {
url = "github:oxalica/rust-overlay"; url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
}; };
outputs = { self, nixpkgs, crane, flake-utils, rust-overlay, ... }: outputs = { self, nixpkgs, crane, flake-utils, rust-overlay, nix-github-actions, ... }:
flake-utils.lib.eachDefaultSystem (system: flake-utils.lib.eachDefaultSystem (system:
let let
# reference: https://crane.dev/examples/quick-start-workspace.html # reference: https://crane.dev/examples/quick-start-workspace.html
@ -32,12 +33,15 @@
strictDeps = true; strictDeps = true;
# Add additional build inputs here # Add additional build inputs here
buildInputs = with pkgs; [ buildInputs = with pkgs; [
openssl
protobuf
pkg-config pkg-config
]; ];
nativeBuildInputs = with pkgs; [ nativeBuildInputs = with pkgs; [
openssl openssl
protobuf protobuf
pkg-config
]; ];
}; };
cargoArtifacts = craneLib.buildDepsOnly commonArgs; cargoArtifacts = craneLib.buildDepsOnly commonArgs;
@ -55,6 +59,8 @@
./Cargo.lock ./Cargo.lock
(craneLib.fileset.commonCargoSources ./crates/app) (craneLib.fileset.commonCargoSources ./crates/app)
(craneLib.fileset.commonCargoSources ./crates/service) (craneLib.fileset.commonCargoSources ./crates/service)
(craneLib.fileset.commonCargoSources ./crates/provider)
(craneLib.fileset.commonCargoSources ./crates/cni)
(craneLib.fileset.commonCargoSources ./crates/my-workspace-hack) (craneLib.fileset.commonCargoSources ./crates/my-workspace-hack)
(craneLib.fileset.commonCargoSources crate) (craneLib.fileset.commonCargoSources crate)
]; ];
@ -140,5 +146,13 @@
]; ];
}; };
} }
); )
// {
githubActions = nix-github-actions.lib.mkGithubMatrix {
checks.x86_64-linux = self.checks.x86_64-linux;
checks.x86_64-darwin.faas-rs-crate = self.checks.x86_64-darwin.faas-rs-crate;
checks.aarch64-linux.faas-rs-crate = self.checks.aarch64-linux.faas-rs-crate;
checks.aarch64-darwin.faas-rs-crate = self.checks.aarch64-darwin.faas-rs-crate;
};
};
} }