1
0
Fork 0
mirror of https://codeberg.org/demostf/sync.git synced 2026-06-03 08:34:08 +02:00

flake rework

This commit is contained in:
Robin Appelman 2024-11-22 21:30:45 +01:00
commit b0ae2c7927
14 changed files with 577 additions and 531 deletions

View file

@ -1,68 +1,17 @@
on: [push, pull_request] name: "CI"
on:
name: CI pull_request:
push:
jobs: jobs:
build: checks:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
matrix:
machine:
- platform: x86_64-linux
- platform: aarch64-linux
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- if: matrix.machine.platform != 'x86_64-linux'
uses: docker/setup-qemu-action@v3
- uses: cachix/install-nix-action@v26
with:
extra_nix_config: |
extra-platforms = aarch64-linux
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build --option system ${{ matrix.machine.platform }}
build-docker:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
machine:
- platform: x86_64-linux
- platform: aarch64-linux
steps:
- uses: actions/checkout@v4
- if: matrix.machine.platform != 'x86_64-linux'
uses: docker/setup-qemu-action@v3
- uses: cachix/install-nix-action@v26
with:
extra_nix_config: |
extra-platforms = aarch64-linux
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build --option system ${{ matrix.machine.platform }} .#docker
docker:
runs-on: ubuntu-latest
needs: [build-docker]
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: cachix/install-nix-action@v26 - uses: cachix/install-nix-action@v26
- uses: icewind1991/attic-action@v1 - uses: icewind1991/attic-action@v1
with: with:
name: ci name: ci
instance: https://cache.icewind.me instance: https://cache.icewind.me
- run: nix run .#dockerManifest authToken: "${{ secrets.ATTIC_TOKEN }}"
if: github.ref == 'refs/heads/master' - run: nix flake check --keep-going
env:
VERSION: "1.0.0"
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}

749
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -2,4 +2,4 @@
Websocket api to sync playback of demos Websocket api to sync playback of demos
By default the websocket server listens on port 80, this can be changed by settings the PORT environment variable. By default, the websocket server listens on port 80, this can be changed by settings the PORT environment variable.

146
flake.lock generated
View file

@ -1,131 +1,103 @@
{ {
"nodes": { "nodes": {
"flake-parts": { "crane": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": { "locked": {
"lastModified": 1701473968, "lastModified": 1730060262,
"narHash": "sha256-YcVE5emp1qQ8ieHUnxt1wCZCC3ZfAS+SRRWZ2TMda7E=", "narHash": "sha256-RMgSVkZ9H03sxC+Vh4jxtLTCzSjPq18UWpiM0gq6shQ=",
"owner": "hercules-ci", "owner": "ipetkov",
"repo": "flake-parts", "repo": "crane",
"rev": "34fed993f1674c8d06d58b37ce1e0fe5eebcb9f5", "rev": "498d9f122c413ee1154e8131ace5a35a80d8fa76",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "hercules-ci", "owner": "ipetkov",
"repo": "flake-parts", "repo": "crane",
"type": "github" "type": "github"
} }
}, },
"flocken": { "flakelight": {
"inputs": { "inputs": {
"flake-parts": "flake-parts",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
], ]
"systems": "systems"
}, },
"locked": { "locked": {
"lastModified": 1704105102, "lastModified": 1731933812,
"narHash": "sha256-c4VWO9plhINjQzYPHSKURWgQ2D2q24aI3OIN0MTPjz0=", "narHash": "sha256-PeuRDDq1DcHxbOmXWb3nWMp5PqWUn5PSKimNbUzWEaQ=",
"owner": "mirkolenz", "owner": "nix-community",
"repo": "flocken", "repo": "flakelight",
"rev": "3a846dfca17f989805d9f4177de85c96dc0f8542", "rev": "f4b26f683be5c9ac1ec05f968dbbcb35f4bb6346",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "mirkolenz", "owner": "nix-community",
"ref": "v2", "repo": "flakelight",
"repo": "flocken", "type": "github"
}
},
"mill-scale": {
"inputs": {
"crane": "crane",
"flakelight": [
"flakelight"
],
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1732306573,
"narHash": "sha256-wE12kIIE0qb9V9y0JiVm5RsRrMNX+KeeMwkzwefdHhY=",
"owner": "icewind1991",
"repo": "mill-scale",
"rev": "8b4cbf174a9728d7e58bbfde5b5a6685dcbf1015",
"type": "github"
},
"original": {
"owner": "icewind1991",
"repo": "mill-scale",
"type": "github" "type": "github"
} }
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1710695816, "lastModified": 1731797254,
"narHash": "sha256-3Eh7fhEID17pv9ZxrPwCLfqXnYP006RKzSs0JptsN84=", "narHash": "sha256-df3dJApLPhd11AlueuoN0Q4fHo/hagP75LlM5K1sz9g=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "614b4613980a522ba49f0d194531beddbb7220d3", "rev": "e8c38b73aeb218e27163376a2d617e61a2ad9b59",
"type": "github" "type": "github"
}, },
"original": { "original": {
"id": "nixpkgs", "id": "nixpkgs",
"ref": "release-23.11", "ref": "nixos-24.05",
"type": "indirect" "type": "indirect"
} }
}, },
"nixpkgs-lib": {
"locked": {
"dir": "lib",
"lastModified": 1701253981,
"narHash": "sha256-ztaDIyZ7HrTAfEEUt9AtTDNoCYxUdSd6NrRHaYOIxtk=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e92039b55bcd58469325ded85d4f58dd5a4eaf58",
"type": "github"
},
"original": {
"dir": "lib",
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"flocken": "flocken", "flakelight": "flakelight",
"nixpkgs": "nixpkgs", "mill-scale": "mill-scale",
"utils": "utils" "nixpkgs": "nixpkgs"
} }
}, },
"systems": { "rust-overlay": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"utils": {
"inputs": { "inputs": {
"systems": "systems_2" "nixpkgs": [
"mill-scale",
"flakelight",
"nixpkgs"
]
}, },
"locked": { "locked": {
"lastModified": 1710146030, "lastModified": 1731897198,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "narHash": "sha256-Ou7vLETSKwmE/HRQz4cImXXJBr/k9gp4J4z/PF8LzTE=",
"owner": "numtide", "owner": "oxalica",
"repo": "flake-utils", "repo": "rust-overlay",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "rev": "0be641045af6d8666c11c2c40e45ffc9667839b5",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "numtide", "owner": "oxalica",
"repo": "flake-utils", "repo": "rust-overlay",
"type": "github" "type": "github"
} }
} }

View file

@ -1,64 +1,14 @@
{ {
inputs = { inputs = {
utils.url = "github:numtide/flake-utils"; nixpkgs.url = "nixpkgs/nixos-24.05";
nixpkgs.url = "nixpkgs/release-23.11"; flakelight = {
flocken = { url = "github:nix-community/flakelight";
url = "github:mirkolenz/flocken/v2";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
mill-scale = {
url = "github:icewind1991/mill-scale";
inputs.flakelight.follows = "flakelight";
};
}; };
outputs = { mill-scale, ... }: mill-scale ./. { };
outputs = {
self,
nixpkgs,
utils,
flocken,
}:
utils.lib.eachDefaultSystem (system: let
overlays = [
(import ./overlay.nix)
];
pkgs = (import nixpkgs) {
inherit system overlays;
};
inherit (flocken.legacyPackages.${system}) mkDockerManifest;
inherit (builtins) fromTOML readFile;
version = (fromTOML (readFile ./Cargo.toml)).package.version;
in rec {
packages = rec {
sync = pkgs.demostf-sync;
docker = pkgs.demostf-sync-docker;
default = sync;
dockerManifest = mkDockerManifest {
tags = ["latest"];
registries = {
"docker.io" = {
enable = true;
repo = "demostf/sync";
username = "$DOCKERHUB_USERNAME";
password = "$DOCKERHUB_TOKEN";
};
};
inherit version;
images = with self.packages; [x86_64-linux.docker aarch64-linux.docker];
};
};
devShells.default = pkgs.mkShell {
OPENSSL_NO_VENDOR = 1;
nativeBuildInputs = with pkgs; [
cargo
rustc
bacon
cargo-edit
cargo-outdated
clippy
cargo-audit
cargo-watch
pkg-config
openssl
];
};
});
} }

View file

@ -1,6 +1,6 @@
{ { dockerTools
dockerTools, , demostf-sync
demostf-sync, ,
}: }:
dockerTools.buildLayeredImage { dockerTools.buildLayeredImage {
name = "demostf/sync"; name = "demostf/sync";
@ -11,9 +11,9 @@ dockerTools.buildLayeredImage {
dockerTools.caCertificates dockerTools.caCertificates
]; ];
config = { config = {
Cmd = ["sync"]; Cmd = [ "sync" ];
ExposedPorts = { ExposedPorts = {
"80/tcp" = {}; "80/tcp" = { };
}; };
}; };
} }

4
nix/overlay.nix Normal file
View file

@ -0,0 +1,4 @@
prev: final: {
demostf-sync = final.callPackage ./package.nix { };
demostf-sync-docker = final.callPackage ./docker.nix { };
}

26
nix/package.nix Normal file
View file

@ -0,0 +1,26 @@
{ stdenv
, rustPlatform
, lib
, pkg-config
, openssl
,
}:
let
inherit (lib.sources) sourceByRegex;
inherit (builtins) fromTOML readFile;
src = sourceByRegex ../. [ "Cargo.*" "(src)(/.*)?" ];
version = (fromTOML (readFile ../Cargo.toml)).package.version;
in
rustPlatform.buildRustPackage rec {
pname = "demostf-sync";
inherit src version;
buildInputs = [ openssl ];
nativeBuildInputs = [ pkg-config ];
cargoLock = {
lockFile = ../Cargo.lock;
};
}

View file

@ -1,4 +0,0 @@
prev: final: {
demostf-sync = final.callPackage ./package.nix {};
demostf-sync-docker = final.callPackage ./docker.nix {};
}

View file

@ -1,25 +0,0 @@
{
stdenv,
rustPlatform,
lib,
pkg-config,
openssl,
}: let
inherit (lib.sources) sourceByRegex;
inherit (builtins) fromTOML readFile;
src = sourceByRegex ./. ["Cargo.*" "(src|build|images|script|style|.sqlx)(/.*)?"];
version = (fromTOML (readFile ./Cargo.toml)).package.version;
in
rustPlatform.buildRustPackage rec {
pname = "demostf-sync";
inherit src version;
buildInputs = [openssl];
nativeBuildInputs = [pkg-config];
cargoLock = {
lockFile = ./Cargo.lock;
};
}

View file

@ -3,6 +3,7 @@ use parity_ws::{util::Token, Result, Sender};
#[enum_dispatch(Client)] #[enum_dispatch(Client)]
pub(crate) trait ClientTrait { pub(crate) trait ClientTrait {
#[allow(clippy::result_large_err)]
fn send(&self, msg: &str) -> Result<()>; fn send(&self, msg: &str) -> Result<()>;
fn token(&self) -> Token; fn token(&self) -> Token;

View file

@ -163,7 +163,7 @@ fn integration_tests() {
fn send<T: std::io::Write>(client: &mut Client<T>, command: SyncCommand) { fn send<T: std::io::Write>(client: &mut Client<T>, command: SyncCommand) {
client client
.send(Message::text(&serde_json::to_string(&command).unwrap())) .send(Message::text(serde_json::to_string(&command).unwrap()))
.unwrap(); .unwrap();
sleep(DELAY); sleep(DELAY);
} }

View file

@ -253,7 +253,7 @@ mod tests {
let sessions: RefCell<HashMap<String, Session>> = RefCell::new(HashMap::new()); let sessions: RefCell<HashMap<String, Session>> = RefCell::new(HashMap::new());
let sender = Client::mock(1); let sender = Client::mock(1);
let command = SyncCommand::Create { let command = SyncCommand::Create {
session: "test".into(), session: "test",
token: "bar", token: "bar",
}; };

View file

@ -1,38 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="RUST_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/examples" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/benches" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/byteorder-541037c38e614382/out" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/getrandom-492d00fbd9dd584b/out" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/getrandom-dc67b657af42ab9a/out" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/httparse-58311939ec3ae3f7/out" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/httparse-ece31b0013b2fb06/out" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/libc-5efc7c4996b307a9/out" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/libc-afe168503a796e74/out" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/log-371e270675b3708b/out" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/log-453889d46ca1ed12/out" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/proc-macro2-9b7d167b077a86e8/out" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/proc-macro2-b61e1bb2d2a4c8bd/out" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/ryu-f99552c5fa0b2a9b/out" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/serde-9d4a021e2785a264/out" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/serde-e0316e7a5d134d58/out" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/serde_derive-8532e376bf52852f/out" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/serde_derive-e502cf3ccba3719a/out" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/serde_json-5fdd038ccabd38f2/out" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/serde_json-e0c813d629c16450/out" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/syn-96d1e304334fc1df/out" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/syn-bdd43f78a1e519ba/out" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/typenum-a845ac8e04079320/out" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/target/debug/build/typenum-f6d195b3ffce7585/out" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Cargo &lt;sync&gt;" level="project" />
<orderEntry type="library" name="Rust &lt;sync&gt;" level="project" />
</component>
</module>