-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ci: add nix env and gha workflows #12
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
use flake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: rust | ||
on: | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
name: cargo test | ||
runs-on: buildjet-8vcpu-ubuntu-2204 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
lfs: true | ||
|
||
- name: install nix | ||
uses: nixbuild/nix-quick-install-action@v28 | ||
|
||
- name: setup nix cache | ||
uses: nix-community/cache-nix-action@v5 | ||
with: | ||
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix') }} | ||
restore-prefixes-first-match: nix-${{ runner.os }}- | ||
backend: buildjet | ||
|
||
- name: Load rust cache | ||
uses: astriaorg/[email protected] | ||
|
||
- name: run cargo test | ||
run: >- | ||
nix develop --command | ||
just test | ||
|
||
check: | ||
name: cargo check | ||
runs-on: buildjet-8vcpu-ubuntu-2204 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
lfs: true | ||
|
||
- name: install nix | ||
uses: nixbuild/nix-quick-install-action@v28 | ||
|
||
- name: setup nix cache | ||
uses: nix-community/cache-nix-action@v5 | ||
with: | ||
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix') }} | ||
restore-prefixes-first-match: nix-${{ runner.os }}- | ||
backend: buildjet | ||
|
||
- name: load rust cache | ||
uses: astriaorg/[email protected] | ||
|
||
- name: run cargo check, failing on warnings | ||
run: >- | ||
nix develop --command | ||
just check | ||
|
||
fmt: | ||
name: cargo fmt | ||
runs-on: buildjet-8vcpu-ubuntu-2204 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: install nix | ||
uses: nixbuild/nix-quick-install-action@v28 | ||
|
||
- name: setup nix cache | ||
uses: nix-community/cache-nix-action@v5 | ||
with: | ||
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix') }} | ||
restore-prefixes-first-match: nix-${{ runner.os }}- | ||
backend: buildjet | ||
|
||
- name: load rust cache | ||
uses: astriaorg/[email protected] | ||
|
||
- name: run cargo fmt, failing on reformatting | ||
run: >- | ||
nix develop --command | ||
just fmt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,7 @@ | |
|
||
# Rust / Cargo | ||
/target | ||
|
||
# Ignore .envrc; copy from .envrc.example to get started | ||
.envrc | ||
.direnv/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
[package] | ||
name = "penumbra-reindexer" | ||
authors = ["Penumbra Labs <[email protected]"] | ||
description = "A reindexing tool for Penumbra ABCI event data" | ||
homepage = "https://penumbra.zone" | ||
repository = "https://github.com/penumbra-zone/reindexer" | ||
version = "0.1.0" | ||
edition = "2021" | ||
license = "MIT OR Apache-2.0" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
{ | ||
description = "A nix development shell and build environment for penumbra-reindexer"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
fenix = { | ||
url = "github:nix-community/fenix"; | ||
inputs.nixpkgs.follows = "nixpkgs"; | ||
inputs.rust-analyzer-src.follows = ""; | ||
}; | ||
crane = { | ||
url = "github:ipetkov/crane"; | ||
inputs = { nixpkgs.follows = "nixpkgs"; }; | ||
}; | ||
}; | ||
|
||
outputs = { self, nixpkgs, flake-utils, crane, ... }: | ||
flake-utils.lib.eachDefaultSystem | ||
(system: | ||
let | ||
pkgs = import nixpkgs { inherit system; }; | ||
# Permit version declarations, but default to unset, | ||
# meaning the local working copy will be used. | ||
penumbraReindexerRelease = null; | ||
|
||
# Set up for Rust builds. | ||
craneLib = crane.mkLib pkgs; | ||
|
||
# Important environment variables so that the build can find the necessary libraries | ||
LIBCLANG_PATH="${pkgs.libclang.lib}/lib"; | ||
ROCKSDB_LIB_DIR="${pkgs.rocksdb.out}/lib"; | ||
in with pkgs; with pkgs.lib; let | ||
# All the Penumbra binaries | ||
penumbraReindexer = (craneLib.buildPackage { | ||
pname = "penumbra-reindexer"; | ||
# what | ||
src = cleanSourceWith { | ||
src = if penumbraReindexerRelease == null then craneLib.path ./. else fetchFromGitHub { | ||
owner = "penumbra-zone"; | ||
repo = "reindexer"; | ||
rev = "v${penumbraReindexerRelease.version}"; | ||
sha256 = "${penumbraReindexerRelease.sha256}"; | ||
}; | ||
filter = path: type: | ||
# Retain non-rust files as build inputs: | ||
# * sql: database schema files for indexing | ||
# * go, mod, sum: golang files for linking in cometbft | ||
(builtins.match ".*\.(sql|go|mod|sum)$" path != null) || | ||
# ... as well as all the normal cargo source files: | ||
(craneLib.filterCargoSources path type); | ||
}; | ||
nativeBuildInputs = [ pkg-config ]; | ||
buildInputs = if stdenv.hostPlatform.isDarwin then | ||
with pkgs.darwin.apple_sdk.frameworks; [clang openssl rocksdb SystemConfiguration CoreServices go] | ||
else | ||
[clang openssl rocksdb go]; | ||
|
||
inherit system LIBCLANG_PATH ROCKSDB_LIB_DIR; | ||
cargoExtraArgs = "-p penumbra-reindexer"; | ||
meta = { | ||
description = "A reindexing tool for Penumbra ABCI event data"; | ||
homepage = "https://penumbra.zone"; | ||
license = [ licenses.mit licenses.asl20 ]; | ||
}; | ||
}).overrideAttrs (_: { doCheck = false; }); # Disable tests to improve build times | ||
|
||
in rec { | ||
packages = { inherit penumbraReindexer ; }; | ||
apps = { | ||
penumbra-reindexer.type = "app"; | ||
penumbra-reindexer.program = "${penumbraReindexer}/bin/penumbra-reindexer"; | ||
}; | ||
defaultPackage = symlinkJoin { | ||
name = "penumbra-reindexer"; | ||
paths = [ penumbraReindexer ]; | ||
}; | ||
devShells.default = craneLib.devShell { | ||
inherit LIBCLANG_PATH ROCKSDB_LIB_DIR; | ||
inputsFrom = [ penumbraReindexer ]; | ||
packages = [ | ||
cargo-nextest | ||
cargo-watch | ||
go | ||
just | ||
nix-prefetch-scripts | ||
sqlfluff | ||
]; | ||
shellHook = '' | ||
export LIBCLANG_PATH=${LIBCLANG_PATH} | ||
export ROCKSDB_LIB_DIR=${ROCKSDB_LIB_DIR} | ||
''; | ||
}; | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Run cargo check, failing on warnings | ||
check: | ||
# The `-D warnings` option causes an error on warnings. | ||
RUSTFLAGS="-D warnings" \ | ||
cargo check --release --all-targets | ||
|
||
# Run cargo fmt, failing on warnings | ||
fmt: | ||
cargo fmt --all -- --check | ||
|
||
# Run cargo nextest | ||
test: | ||
cargo nextest run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
multi_thread
annotations were necessary for me to getcargo test
passing locally. If you were using a different invocation to force a multithreaded runtime rather than current-thread on the CLI, I'm curious to know it, otherwise I think this is a sane strategy.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird, I just ran cargo test locally with no issues, but that seems like a possibility given SQLX relying on tokio