Skip to content

Commit

Permalink
feat: add nix testing with devimint (#62)
Browse files Browse the repository at this point in the history
* feat: add nix testing with devimint

* chore: update testing docs

* chore: cleanup

* feat: Add Devimint to testing harness

* feat: Add nix setup to testing workflow

* fix: readd cachix to nix workflow

* fix: workflow nix develop

* fix: remove retry logic in test workflow

* chore: changet  fedimint target

* fix: tweak test
  • Loading branch information
alexlwn123 authored Oct 14, 2024
1 parent 93d7697 commit e50ec77
Show file tree
Hide file tree
Showing 26 changed files with 791 additions and 153 deletions.
5 changes: 5 additions & 0 deletions .changeset/great-mugs-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@fedimint/core-web': patch
---

Added Nix devshell to run Devimint within testing suite
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
25 changes: 25 additions & 0 deletions .github/actions/setup-nix/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Setup Nix
description: Sets up nix for running tests with devimint

inputs:
cachix_auth_token:
description: 'Cachix authentication token'
required: true

runs:
using: 'composite'
steps:
- name: Install Nix
uses: cachix/install-nix-action@V27
with:
nix_path: nixpkgs=channel:nixos-23.11
extra_nix_config: |
connect-timeout = 15
stalled-download-timeout = 15
- name: Setup Cachix
uses: cachix/cachix-action@v15
with:
name: fedimint
authToken: ${{ inputs.cachix_auth_token }}
continue-on-error: true
11 changes: 6 additions & 5 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,16 @@ jobs:
- name: Install dependencies
uses: ./.github/actions/install-deps

- name: Setup Nix
uses: ./.github/actions/setup-nix
with:
cachix_auth_token: ${{ secrets.CACHIX_AUTH_TOKEN }}

- name: Setup Playwright
run: pnpm exec playwright install

- name: Run Tests
uses: nick-fields/retry@v3
with:
command: pnpm test
max_attempts: 3
timeout_seconds: 180
run: nix develop -c pnpm test

build-docs:
name: Build Docs
Expand Down
8 changes: 1 addition & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ node_modules
tsconfig.tsbuildinfo
*.vitest-temp.json

# local env files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local
.envrc
.direnv
/test-results/
/playwright-report/
/blob-report/
Expand Down
30 changes: 30 additions & 0 deletions docs/core/dev/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,36 @@ Vitest [browser mode](https://vitest.dev/guide/browser/) + playwright (provider)

This framework should be suitable for all the additional libraries we have planned (e.g. react).

## Nix

The Fedimint Web SDK depends on several external pieces of infrastructure. In order to run high-fidelity tests, we utilize a tool from the [fedimint](https://github.com/fedimint/fedimint) repo called [Devimint](https://github.com/fedimint/fedimint/tree/master/devimint). Devimint includes several pieces of infrastructure for running a local testing environment for fedimint applications including a bitcoind node (regtest), multiple guardian servers (fedimintd), multiple lightning gateways (lnd, cln, ldk), and a faucet for minting tokens.

::: warning Note

Nix is NOT required to build or use the Fedimint Web SDK. It is ONLY required to run the tests.

:::

## Nix Installation & Setup

To setup nix, use the [Determinate Nix Installer](https://github.com/DeterminateSystems/nix-installer)

```sh
# The exact version might be different.
> nix --version
nix (Nix) 2.9.1
```

Next, [install direnv](https://direnv.net/docs/installation.html) and run the following command to initialize direnv in your shell:

```sh
direnv allow
```

::: tip
This takes a really long time to run for the first time. All future runs will be relatively quick.
:::

## Usage

```bash
Expand Down
Loading

0 comments on commit e50ec77

Please sign in to comment.