Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Commit

Permalink
Scaffold
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemcordoba committed Jun 26, 2024
0 parents commit 792a418
Show file tree
Hide file tree
Showing 56 changed files with 9,954 additions and 0 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake .
61 changes: 61 additions & 0 deletions .github/actions/extend-space/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Extends disk space on github hosted runners


name: "Extend space"
description: "Teases out as much free space as possible"

runs:
using: "composite"
steps:
- name: Create mountpoint for extended space
shell: "bash"
run: sudo mkdir /mnt/extended

- name: Maximize build space
uses: easimon/maximize-build-space@v6
# uses: AdityaGarg8/remove-unwanted-software@v1
with:
remove-dotnet: true
remove-android: true
remove-haskell: true
build-mount-path: /mnt/extended
root-reserve-mb: 512
swap-size-mb: 1024

# after we've got the extended space mounted, we can use overlayfs and bind
# mounts as appropriate to make this space available to all paths that are
# expected to be written to.
#
# for new directories (such as /nix), a bind mount is enough for existing
# directories (such as $HOME and /tmp), we use an overlay to preserve access
# to the existing files, while redirecting changes to the extended space.
- name: Use extended space for /nix, /tmp, /var/tmp, and $HOME
shell: "bash"
run: |
export EXTENDED_PATH=/mnt/extended
sudo mkdir $EXTENDED_PATH/{tmp,nix,home}
sudo mkdir $EXTENDED_PATH/tmp/{upper,work}
sudo mv /tmp{,_lower}
sudo mkdir /tmp
sudo mount -t overlay overlay \
-o lowerdir=/tmp_lower,upperdir=$EXTENDED_PATH/tmp/upper,workdir=$EXTENDED_PATH/tmp/work \
/tmp
sudo chown $(id -u):$(id -g) /tmp
sudo mkdir -p $EXTENDED_PATH/var/tmp/{upper,work}
sudo mv /var/tmp{,_lower}
sudo mkdir -p /var/tmp
sudo mount -t overlay overlay \
-o lowerdir=/var/tmp_lower,upperdir=$EXTENDED_PATH/var/tmp/upper,workdir=$EXTENDED_PATH/var/tmp/work \
/var/tmp
sudo chown $(id -u):$(id -g) /var/tmp
sudo mkdir /nix
sudo mount -o bind $EXTENDED_PATH/nix /nix
sudo mkdir $EXTENDED_PATH/home/{upper,work}
sudo mv ${HOME} ${HOME}_lower
sudo mkdir ${HOME}
sudo chown $(id -u):$(id -g) $HOME
sudo mount -t overlay overlay \
-o lowerdir=${HOME}_lower,upperdir=$EXTENDED_PATH/home/upper,workdir=$EXTENDED_PATH/home/work \
$HOME
sudo chown $(id -u):$(id -g) $HOME
df -h
47 changes: 47 additions & 0 deletions .github/workflows/build-and-cache.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: "Build and cache nix packages"
on:
push:
branches: [ main ]

jobs:
testbuild:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install nix
uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-unstable

- uses: cachix/cachix-action@v14
with:
name: holochain-ci

- uses: cachix/cachix-action@v14
with:
name: holochain-open-dev

- name: Install and test
run: |
nix develop --command bash -c "pnpm i && pnpm t && pnpm -F @holochain-open-dev/roles build"
- name: Build zomes
env:
CACHIX_AUTH_TOKEN: "$"
run: |
nix build -L .#roles_integrity
cachix push holochain-open-dev $(nix path-info --accept-flake-config .#roles_integrity)
cachix pin holochain-open-dev roles_integrity_debug $(nix path-info --accept-flake-config .#roles_integrity)
nix build -L .#roles_integrity.meta.release
cachix push holochain-open-dev $(nix path-info --accept-flake-config .#roles_integrity)
cachix pin holochain-open-dev roles_integrity $(nix path-info --accept-flake-config .#roles_integrity.meta.release)
nix build -L .#roles
cachix push holochain-open-dev $(nix path-info --accept-flake-config .#roles)
cachix pin holochain-open-dev roles_debug $(nix path-info --accept-flake-config .#roles)
nix build -L .#roles.meta.release
cachix push holochain-open-dev $(nix path-info --accept-flake-config .#roles.meta.release)
cachix pin holochain-open-dev roles $(nix path-info --accept-flake-config .#roles.meta.release)
36 changes: 36 additions & 0 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Publish docs
on:
push:
branches: [ main ]
permissions:
contents: write
jobs:
build-and-deploy:
concurrency: ci-$ # Recommended if you intend to make multiple deployments in quick succession.
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3

- name: Install nix
uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-unstable

- uses: cachix/cachix-action@v14
with:
name: holochain-ci

- uses: cachix/cachix-action@v14
with:
name: holochain-open-dev

- name: Install and Build 🔧
run: |
nix develop --command bash -c "pnpm i && pnpm -F docs build"
- name: Deploy 🚀
uses: JamesIves/[email protected]
with:
branch: gh-pages # The branch the action should deploy to.
folder: docs/.vitepress/dist # The folder the action should deploy.
31 changes: 31 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "test"
on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

jobs:
testbuild:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install nix
uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-unstable

- uses: cachix/cachix-action@v14
with:
name: holochain-ci

- uses: cachix/cachix-action@v14
with:
name: holochain-open-dev

- name: Install and test
run: |
nix develop --command bash -c "pnpm i && pnpm t && pnpm -F @holochain-open-dev/roles build"
56 changes: 56 additions & 0 deletions .github/workflows/update-flake-inputs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Update flake inputs
on:
schedule:
- cron: "0 7 * * *" # Run every day at 7AM

permissions:
pull-requests: write
contents: write

jobs:
automerge:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install nix
uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-unstable

- uses: cachix/cachix-action@v14
with:
name: holochain-ci

- uses: cachix/cachix-action@v14
with:
name: holochain-open-dev

- name: Update Flake
run: |
nix flake update
nix develop
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
flake_lock:
- 'flake.lock'
package_json:
- '**/*/package.json'
- name: Create Pull Request
id: cpr
if: steps.changes.outputs.flake_lock == 'true' || steps.changes.outputs.package_json == 'true'
uses: peter-evans/create-pull-request@v3
with:
token: $

- name: Enable Pull Request Automerge
if: (steps.changes.outputs.flake_lock == 'true' || steps.changes.outputs.package_json == 'true') && steps.cpr.outputs.pull-request-operation == 'created'
uses: peter-evans/enable-pull-request-automerge@v3
with:
token: $
pull-request-number: $
merge-method: squash
35 changes: 35 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
## editors
/.idea
/.vscode

## system files
.DS_Store

## npm
node_modules/
/npm-debug.log

## testing
/coverage/

## temp folders
/.tmp/

# build
/_site/
dist/
/out-tsc/

storybook-static
*.tsbuildinfo

# holochain
*.happ
*.webhapp
*.dna

# cargo
/target/
/.cargo/

/.direnv/
10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"singleQuote": true,
"arrowParens": "avoid",
"useTabs": true,
"plugins": ["@trivago/prettier-plugin-sort-imports"],
"importOrder": ["<THIRD_PARTY_MODULES>", "^[./]"],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true,
"importOrderParserPlugins": ["typescript", "decorators-legacy"]
}
18 changes: 18 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[profile.dev]
opt-level = "z"

[profile.release]
opt-level = "z"

[workspace]
members = ["zomes/coordinator/*", "zomes/integrity/*"]
resolver = "2"

[workspace.dependencies]
holochain = { version = "0.3.1-rc.1", default-features = false, features = [
"test_utils",
] }
hdi = "0.4.1-rc.1"
hdk = "0.3.1-rc.1"
serde = "1"

59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Roles

## Environment Setup

> PREREQUISITE: set up the [holochain development environment](https://developer.holochain.org/docs/install/).
Enter the nix shell by running this in the root folder of the repository:

```bash
nix develop
npm install
```

**Run all the other instructions in this README from inside this nix shell, otherwise they won't work**.

## Running 2 agents

```bash
npm start
```

This will create a network of 2 nodes connected to each other and their respective UIs.
It will also bring up the Holochain Playground for advanced introspection of the conductors.

## Running the backend tests

```bash
npm test
```

## Bootstrapping a network

Create a custom network of nodes connected to each other and their respective UIs with:

```bash
npm run network 3
```

Substitute the "3" for the number of nodes that you want to bootstrap in your network.
This will also bring up the Holochain Playground for advanced introspection of the conductors.

## Packaging

To package the web happ:
``` bash
npm run package
```

You'll have the `roles.webhapp` in `workdir`. This is what you should distribute so that the Holochain Launcher can install it.
You will also have its subcomponent `roles.happ` in the same folder`.

## Documentation

This repository is using these tools:
- [NPM Workspaces](https://docs.npmjs.com/cli/v7/using-npm/workspaces/): npm v7's built-in monorepo capabilities.
- [hc](https://github.com/holochain/holochain/tree/develop/crates/hc): Holochain CLI to easily manage Holochain development instances.
- [@holochain/tryorama](https://www.npmjs.com/package/@holochain/tryorama): test framework.
- [@holochain/client](https://www.npmjs.com/package/@holochain/client): client library to connect to Holochain from the UI.
- [@holochain-playground/cli](https://www.npmjs.com/package/@holochain-playground/cli): introspection tooling to understand what's going on in the Holochain nodes.
3 changes: 3 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.vitepress/cache
.vitepress/dist
public/backend
Loading

0 comments on commit 792a418

Please sign in to comment.