-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add initial project setup with OCaml and Nix configurations - Initialize `.envrc` for flake usage - Update `.gitignore` to include `.direnv` - Add `.ocamlformat` for OCaml code formatting - Create Dune configuration for the executable in `bin/dune` - Implement main functionality in `bin/main.ml` - Set up project metadata in `dune-project` - Lock dependencies in `flake.lock` - Define Nix flake setup in `flake.nix` - Configure library `store` in `lib/dune` - Prepare stubs for `lib/hash.ml` and `lib/store.ml` - Add test configuration in `test/dune` - Create an empty test file `test/test_vorpal.ml` - Generate `vorpal.opam` for package management * feat: integrate Vorpal library and refactor artifact build process - Replace `store` library with `vorpal` in dune configuration. - Refactor `main.ml` to use `Vorpal.Build` module, simplifying artifact creation logic. - Add `build.ml` in `lib` to handle artifact building with new `artifact` type. - Update `lib/dune` to rename library from `store` to `vorpal`. - Remove unused `hash.ml` file. - Refactor `store.ml` to `create_dir` and `copy_files` functions, adjusting to new artifact structure and simplifying file copying logic. * feat: add mirage-crypto support and hash generation for artifacts - Include mirage-crypto in the build environment and as a dependency for the vorpal package. - Implement hash generation for artifact files using mirage-crypto's SHA256. - Adjust artifact build process to generate and print file hashes. - Refactor store and build modules for improved type annotations and functionality. * feat: enhance artifact build process with hash-based directory creation and improved file handling - Implement hash combination for artifact builds to create unique directory names based on content. - Refactor build_artifact function to use a new get_file_paths function for better file filtering and handling. - Update artifact directory creation to include hash in the directory name for uniqueness. - Add error handling for directory existence checks to prevent overwriting. - Modify artifact build process to print file paths after copying, improving logging and traceability. * feat: add just tool and adjust dependencies in flake.nix - Include `just` in the inherited packages from `pkgs`. - Replace `mirage-crypto` with `just` in `nativeBuildInputs` for the default dev shell. - Fix typo from `propogatedBuildInputs` to `propagatedBuildInputs` in `packages.default`. - Add a new `justfile` with default and build commands. * feat: add flake workflow and update nix dependencies - Implement flake workflow for CI checks and builds on main branch - Update nixpkgs to latest revision for improved dependency management - Add `check`, `build`, and `update` commands to justfile for enhanced development workflow * feat: update README and enhance store module - Updated README.md with new overview and diagram for Vorpal. - Added a new image file vorpal.webp to the repository. - Enhanced the store.ml module by specifying the return type for get_file_paths function. * docs: add design section to README.md
- Loading branch information
1 parent
e439759
commit 80ba62a
Showing
19 changed files
with
340 additions
and
1 deletion.
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,39 @@ | ||
name: flake | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
env: | ||
CACHIX_BINARY_CACHE: altf4llc-os | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: cachix/install-nix-action@v26 | ||
with: | ||
nix_path: nixpkgs=channel:nixos-unstable | ||
- uses: cachix/cachix-action@v14 | ||
with: | ||
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} | ||
name: ${{ env.CACHIX_BINARY_CACHE }} | ||
- uses: actions/checkout@v4 | ||
- run: nix develop -c just check | ||
|
||
build: | ||
needs: | ||
- check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: cachix/install-nix-action@v26 | ||
with: | ||
nix_path: nixpkgs=channel:nixos-unstable | ||
- uses: cachix/cachix-action@v14 | ||
with: | ||
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} | ||
name: ${{ env.CACHIX_BINARY_CACHE }} | ||
- uses: actions/checkout@v4 | ||
- run: nix develop -c just build |
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,3 +1,4 @@ | ||
.direnv | ||
*.annot | ||
*.cmo | ||
*.cma | ||
|
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,2 @@ | ||
profile = default | ||
version = 0.26.2 |
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,2 +1,16 @@ | ||
# vorpal | ||
Next generation build tool that fits every situation. | ||
|
||
Maintain your entire supply chain with one magical tool. | ||
|
||
## Overview | ||
|
||
Vorpal is a unified build, development, and deployment system that manages all phases of the software lifecycle and supply chain. Vorpal can compile your code in a reproducible manner and then deliver the resulting "artifacts" for development and deployment environments. | ||
|
||
## Design | ||
|
||
Below is the existing working diagram that illustrates the platform's design: | ||
|
||
> [!CAUTION] | ||
> This design is subject to change at ANY moment and is a work in progress. | ||
![vorpal](./vorpal.webp) |
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,4 @@ | ||
(executable | ||
(public_name vorpal) | ||
(name main) | ||
(libraries vorpal)) |
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,10 @@ | ||
open Vorpal.Build | ||
|
||
let example : artifact = | ||
{ | ||
ignore = [ ".git"; ".gitignore"; ".direnv"; "_build" ]; | ||
name = "example"; | ||
source = "."; | ||
} | ||
|
||
let () = build_artifact example |> ignore |
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,26 @@ | ||
(lang dune 3.12) | ||
|
||
(name vorpal) | ||
|
||
(generate_opam_files true) | ||
|
||
(source | ||
(github ALT-F4-LLC/vorpal)) | ||
|
||
(authors "ALT F4 LLC") | ||
|
||
(maintainers "Erik Reinert") | ||
|
||
(license LICENSE) | ||
|
||
(documentation https://url/to/documentation) | ||
|
||
(package | ||
(name vorpal) | ||
(synopsis "A short synopsis") | ||
(description "A longer description") | ||
(depends ocaml dune) | ||
(tags | ||
(topics "to describe" your project))) | ||
|
||
; See the complete stanza docs at https://dune.readthedocs.io/en/stable/dune-files.html#dune-project |
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,35 @@ | ||
{ | ||
description = "vorpal"; | ||
|
||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | ||
|
||
outputs = inputs @ {flake-parts, ...}: | ||
flake-parts.lib.mkFlake {inherit inputs;} { | ||
systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"]; | ||
|
||
perSystem = { | ||
config, | ||
pkgs, | ||
... | ||
}: let | ||
inherit (pkgs) just ocamlPackages mkShell; | ||
inherit (ocamlPackages) buildDunePackage mirage-crypto; | ||
in { | ||
devShells = { | ||
default = mkShell { | ||
inputsFrom = [config.packages.default]; | ||
nativeBuildInputs = [just]; | ||
}; | ||
}; | ||
|
||
packages = { | ||
default = buildDunePackage { | ||
pname = "vorpal"; | ||
propagatedBuildInputs = [mirage-crypto]; | ||
src = ./.; | ||
version = "0.1.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
_default: | ||
just --list | ||
|
||
check: | ||
nix flake check | ||
|
||
build profile="default": | ||
nix build \ | ||
--json \ | ||
--no-link \ | ||
--print-build-logs \ | ||
'.#{{ profile }}' | ||
|
||
update: | ||
nix flake update |
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,11 @@ | ||
open Hash | ||
open Store | ||
|
||
type artifact = { ignore : string list; name : string; source : string } | ||
|
||
let build_artifact (artifact : artifact) = | ||
get_file_paths artifact.source artifact.ignore | ||
|> generate_hashes |> combine_hashes | ||
|> fun hash -> | ||
create_dir artifact.name hash |> fun dir -> | ||
copy_files artifact.source dir artifact.ignore |> List.iter print_endline |
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,3 @@ | ||
(library | ||
(name vorpal) | ||
(libraries mirage-crypto unix)) |
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,18 @@ | ||
open Mirage_crypto.Hash | ||
open Store | ||
|
||
let generate_hash (input : string) : string = | ||
let digest = SHA256.digest (Cstruct.of_string input) in | ||
Cstruct.to_hex_string digest | ||
|
||
let generate_hashes (files : string list) : string list = | ||
List.map | ||
(fun f -> | ||
let data = read_file f in | ||
let hash = generate_hash data in | ||
hash) | ||
files | ||
|
||
let combine_hashes (hashes : string list) : string = | ||
let combined = String.concat "" hashes in | ||
generate_hash combined |
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,70 @@ | ||
let store = "/tmp/vorpal/store" | ||
|
||
let rec get_file_paths (path : string) (ignore_files : string list) : | ||
string list = | ||
if Sys.is_directory path then | ||
Sys.readdir path | ||
|> Array.fold_left | ||
(fun acc file -> | ||
if not (List.mem file ignore_files) then | ||
let file_path = Unix.realpath (Filename.concat path file) in | ||
let files = get_file_paths file_path ignore_files in | ||
acc @ files | ||
else acc) | ||
[] | ||
else if not (List.mem (Filename.basename path) ignore_files) then [ path ] | ||
else [] | ||
|
||
let get_dir_path (name : string) (hash : string) : string = | ||
Filename.concat store (name ^ "-" ^ hash) | ||
|
||
let dir_exists (name : string) (hash : string) = | ||
try | ||
let stats = Unix.stat (get_dir_path name hash) in | ||
stats.st_kind = S_DIR | ||
with | ||
| Unix.Unix_error (ENOENT, _, _) -> false (* No such file or directory *) | ||
| Unix.Unix_error (EACCES, _, _) -> false (* Permission denied *) | ||
| _ -> false (* Any other error *) | ||
|
||
let create_dir (name : string) (hash : string) : string = | ||
let dir_path = get_dir_path name hash in | ||
Unix.mkdir dir_path 0o777; | ||
dir_path | ||
|
||
let copy_file (src : string) (dst : string) : unit = | ||
let ic = open_in src in | ||
let oc = open_out dst in | ||
try | ||
while true do | ||
output_char oc (input_char ic) | ||
done | ||
with End_of_file -> | ||
close_in ic; | ||
close_out oc | ||
|
||
let rec copy_files (src : string) (dst : string) (ignore_files : string list) : | ||
string list = | ||
if Sys.is_directory src then ( | ||
if not (Sys.file_exists dst) then Unix.mkdir dst 0o777; | ||
Sys.readdir src | ||
|> Array.fold_left | ||
(fun acc file -> | ||
if not (List.mem file ignore_files) then | ||
let src_file = Filename.concat src file in | ||
let dst_file = Filename.concat dst file in | ||
let copied_files = copy_files src_file dst_file ignore_files in | ||
acc @ copied_files | ||
else acc) | ||
[]) | ||
else if not (List.mem (Filename.basename src) ignore_files) then ( | ||
copy_file src dst; | ||
[ dst ]) | ||
else [] | ||
|
||
let read_file (file : string) : string = | ||
let ic = open_in file in | ||
let n = in_channel_length ic in | ||
let s = really_input_string ic n in | ||
close_in ic; | ||
s |
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,2 @@ | ||
(test | ||
(name test_vorpal)) |
Empty file.
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,31 @@ | ||
# This file is generated by dune, edit dune-project instead | ||
opam-version: "2.0" | ||
synopsis: "A short synopsis" | ||
description: "A longer description" | ||
maintainer: ["Erik Reinert"] | ||
authors: ["ALT F4 LLC"] | ||
license: "LICENSE" | ||
tags: ["topics" "to describe" "your" "project"] | ||
homepage: "https://github.com/ALT-F4-LLC/vorpal" | ||
doc: "https://url/to/documentation" | ||
bug-reports: "https://github.com/ALT-F4-LLC/vorpal/issues" | ||
depends: [ | ||
"ocaml" | ||
"dune" {>= "3.12"} | ||
"odoc" {with-doc} | ||
] | ||
build: [ | ||
["dune" "subst"] {dev} | ||
[ | ||
"dune" | ||
"build" | ||
"-p" | ||
name | ||
"-j" | ||
jobs | ||
"@install" | ||
"@runtest" {with-test} | ||
"@doc" {with-doc} | ||
] | ||
] | ||
dev-repo: "git+https://github.com/ALT-F4-LLC/vorpal.git" |
Binary file not shown.