mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-03 10:14:06 +02:00
nix ci
This commit is contained in:
parent
6659d673ea
commit
da6a2d62bd
5 changed files with 123 additions and 84 deletions
66
.github/workflows/ci.yml
vendored
Normal file
66
.github/workflows/ci.yml
vendored
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: Check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: cachix/install-nix-action@v20
|
||||
- uses: icewind1991/attic-action@v1
|
||||
with:
|
||||
name: ci
|
||||
instance: https://cache.icewind.me
|
||||
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- uses: lriesebos/nix-develop-command@6f5f4830884d1957767e920c51d6118c9b0ac828
|
||||
with:
|
||||
command: "cargo check"
|
||||
|
||||
test:
|
||||
name: Test
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: cachix/install-nix-action@v20
|
||||
- uses: icewind1991/attic-action@v1
|
||||
with:
|
||||
name: ci
|
||||
instance: https://cache.icewind.me
|
||||
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- uses: lriesebos/nix-develop-command@6f5f4830884d1957767e920c51d6118c9b0ac828
|
||||
with:
|
||||
command: "cargo test"
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target:
|
||||
- x86_64-unknown-linux-gnu
|
||||
- x86_64-unknown-linux-musl
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: cachix/install-nix-action@v20
|
||||
- uses: icewind1991/attic-action@v1
|
||||
with:
|
||||
name: ci
|
||||
instance: https://cache.icewind.me
|
||||
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
||||
- run: nix build .#${{ matrix.target }}
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: parser-${{ matrix.target }}
|
||||
path: result/bin/parse_demo
|
||||
30
.github/workflows/release.yml
vendored
30
.github/workflows/release.yml
vendored
|
|
@ -5,28 +5,22 @@ on:
|
|||
types: [created]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build Static Linux Binaries
|
||||
release-binaries:
|
||||
name: Build release binaries
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: build dependencies
|
||||
run: |
|
||||
sudo apt-get install musl-tools
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
- uses: actions/checkout@v3
|
||||
- uses: cachix/install-nix-action@v20
|
||||
- uses: icewind1991/attic-action@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
target: x86_64-unknown-linux-musl
|
||||
- uses: Swatinem/rust-cache@v1
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: build
|
||||
args: --release --target x86_64-unknown-linux-musl
|
||||
- uses: svenstaro/upload-release-action@v2
|
||||
name: ci
|
||||
instance: https://cache.icewind.me
|
||||
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
||||
- run: nix build .#x86_64-unknown-linux-musl
|
||||
- name: Upload binary to release
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
file: target/x86_64-unknown-linux-musl/release/parse_demo
|
||||
file: result/bin/parse_demo
|
||||
asset_name: parse_demo
|
||||
tag: ${{ github.ref }}
|
||||
|
||||
|
|
|
|||
58
.github/workflows/rust.yml
vendored
58
.github/workflows/rust.yml
vendored
|
|
@ -1,58 +0,0 @@
|
|||
on: [ push, pull_request ]
|
||||
|
||||
name: CI
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: Check
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
- uses: Swatinem/rust-cache@v1
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: check
|
||||
|
||||
|
||||
test:
|
||||
name: Test
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
- uses: Swatinem/rust-cache@v1
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
|
||||
build:
|
||||
name: Build Binaries
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
steps:
|
||||
- name: musl-tools
|
||||
run: |
|
||||
sudo apt-get install musl-tools
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
target: x86_64-unknown-linux-musl
|
||||
- uses: Swatinem/rust-cache@v1
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: build
|
||||
args: --release --target x86_64-unknown-linux-musl
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: parse_demo
|
||||
path: target/x86_64-unknown-linux-musl/release/parse_demo
|
||||
24
flake.lock
generated
24
flake.lock
generated
|
|
@ -39,9 +39,33 @@
|
|||
"inputs": {
|
||||
"naersk": "naersk",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay",
|
||||
"utils": "utils"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"flake-utils": [
|
||||
"utils"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1685759304,
|
||||
"narHash": "sha256-I3YBH6MS3G5kGzNuc1G0f9uYfTcNY9NYoRc3QsykLk4=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "c535b4f3327910c96dcf21851bbdd074d0760290",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"utils": {
|
||||
"locked": {
|
||||
"lastModified": 1667395993,
|
||||
|
|
|
|||
23
flake.nix
23
flake.nix
|
|
@ -4,6 +4,9 @@
|
|||
utils.url = "github:numtide/flake-utils";
|
||||
naersk.url = "github:nix-community/naersk";
|
||||
naersk.inputs.nixpkgs.follows = "nixpkgs";
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
||||
rust-overlay.inputs.flake-utils.follows = "utils";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
|
|
@ -11,20 +14,30 @@
|
|||
nixpkgs,
|
||||
utils,
|
||||
naersk,
|
||||
rust-overlay,
|
||||
}:
|
||||
utils.lib.eachDefaultSystem (system: let
|
||||
overlays = [ (import rust-overlay) ];
|
||||
pkgs = (import nixpkgs) {
|
||||
inherit system;
|
||||
inherit system overlays;
|
||||
};
|
||||
naersk' = pkgs.callPackage naersk {};
|
||||
hostTarget = pkgs.hostPlatform.config;
|
||||
targets = ["x86_64-unknown-linux-musl" hostTarget];
|
||||
lib = pkgs.lib;
|
||||
naerskForTarget = target: let
|
||||
toolchain = pkgs.rust-bin.stable.latest.default.override { targets = [target]; };
|
||||
in pkgs.callPackage naersk {
|
||||
cargo = toolchain;
|
||||
rustc = toolchain;
|
||||
};
|
||||
src = lib.sources.sourceByRegex (lib.cleanSource ./.) ["Cargo.*" "(src|tests|benches)(/.*)?"];
|
||||
in rec {
|
||||
packages = rec {
|
||||
tf-demo-parser = naersk'.buildPackage {
|
||||
packages = (lib.attrsets.genAttrs targets (target: (naerskForTarget target).buildPackage {
|
||||
pname = "tf-demo-parser";
|
||||
root = src;
|
||||
};
|
||||
})) // rec {
|
||||
tf-demo-parser = packages.${hostTarget};
|
||||
default = tf-demo-parser;
|
||||
};
|
||||
|
||||
|
|
@ -37,7 +50,7 @@
|
|||
};
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
nativeBuildInputs = with pkgs; [rustc cargo bacon cargo-edit cargo-outdated rustfmt clippy cargo-audit hyperfine valgrind];
|
||||
nativeBuildInputs = with pkgs; [rust-bin.stable.latest.default bacon cargo-edit cargo-outdated rustfmt clippy cargo-audit hyperfine valgrind];
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue