Skip to content

Commit 29dfd04

Browse files
authored
fix: e2e tests re-org (#259)
Minor code re-org to move CLI and SDK tests to their own directory (`rust-recall/tests`). Closes #242, #262.
1 parent b6e3d91 commit 29dfd04

File tree

22 files changed

+11846
-336
lines changed

22 files changed

+11846
-336
lines changed

.dockerignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Generated by Cargo
2+
# will have compiled files and executables
3+
debug/
4+
target/
5+
6+
# These are backup files generated by rustfmt
7+
**/*.rs.bk
8+
9+
# MSVC Windows builds of rustc generate these, which store debugging information
10+
*.pdb
11+
12+
.env
13+
.vscode

.github/workflows/ci.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ env:
1111
CARGO_NET_GIT_FETCH_WITH_CLI: true
1212
DOCKER_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
1313
DOCKER_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
14-
TEST_TARGET_NETWORK: localnet
15-
RECALL_PRIVATE_KEY: "0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97"
1614
DO_NOT_TRACK: 1
1715
DAGGER_NO_NAG: 1
16+
# TODO: Use the latest localnet image once it can build with the latest IPC code
17+
LOCALNET_IMAGE: "textile/recall-localnet:sha-dc4da8c-3e80bf0"
1818

1919
concurrency:
2020
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
@@ -46,25 +46,17 @@ jobs:
4646
target
4747
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
4848

49-
# Cache Dagger volumes
50-
- name: Cache Dagger volumes
51-
uses: actions/cache@v3
52-
with:
53-
path: |
54-
~/.cache/dagger
55-
key: ${{ runner.os }}-dagger-${{ hashFiles('**/Cargo.lock') }}
56-
5749
- name: Build
5850
run: make build
5951

6052
- name: Run tests
6153
uses: dagger/dagger-for-github@8.0.0
6254
with:
63-
version: '0.18.1'
55+
version: '0.18.2'
6456
workdir: 'dagger'
6557
verb: call
6658
module: ci
67-
args: test --source ../ --docker-username $DOCKER_USERNAME --docker-password env://DOCKER_PASSWORD --recall-private-key env://RECALL_PRIVATE_KEY
59+
args: test --source ../ --localnet-image "$LOCALNET_IMAGE" --docker-username "$DOCKER_USERNAME" --docker-password env://DOCKER_PASSWORD 2>&1 | grep -vi -E "resolve|containerd|libnetwork|client|daemon|checkpoint|task|^$"
6860
dagger-flags: '--progress plain'
6961

7062
- name: Run linter

Cargo.lock

Lines changed: 15 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace]
2-
members = ["cli", "provider", "sdk", "signer"]
2+
members = ["cli", "provider", "sdk", "signer", "tests/sdk"]
33
resolver = "2"
44

55
[workspace.package]

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@ docker run --privileged --rm --name recall-localnet \
7979

8080
If you'd like to test against a specific IPC commit, look for the corresponding `localnet` image in the
8181
[Docker Hub repository](https://hub.docker.com/r/textile/recall-localnet/tags) using the first 7 characters of the IPC
82-
commit hash. For example, for commit `8c6792f5c306420a6915e9a83fefb10520417a8b`, the corresponding `localnet` image
83-
would be tagged `sha-8c6792f-*` (in this case, `sha-8c6792f-be1693d`). You can then run the following command:
82+
commit hash. For example, for commit `dc4da8c14c541e1ef9e398a594e65660465c47f5`, the corresponding `localnet` image
83+
would be tagged `sha-dc4da8c-*` (in this case, `sha-dc4da8c-3e80bf0`). You can then run the following command:
8484

8585
```bash
8686
docker run --privileged --rm -d --name recall-localnet \
8787
-p 8545:8545 \
8888
-p 8645:8645 \
8989
-p 26657:26657 \
90-
textile/recall-localnet:sha-8c6792f-be1693d
90+
textile/recall-localnet:sha-dc4da8c-3e80bf0
9191
```
9292

9393
Note that it can take several minutes for the `localnet` container to start up and be ready for testing. You can check
@@ -103,25 +103,25 @@ The following logs should appear when the container is ready:
103103
All containers started. Waiting for termination signal...
104104
```
105105

106-
Also note that some tests (e.g. the SDK tests) require additional environment variables to be set. You can set these
107-
environment variables in your shell before running the tests. For example, you can run the following command:
106+
### Extracting Network Config
107+
108+
To extract the network config from the `localnet` container, you can run the following command:
108109

109110
```bash
110-
export RECALL_PRIVATE_KEY=0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97
111+
docker exec -it recall-localnet bash -c "cat /workdir/localnet-data/networks.toml"
111112
```
112113

114+
Add the `localnet` configuration to your `~/.config/recall/networks.toml` file.
115+
113116
### Adding New Integration Tests
114117

115118
All the tests in the repo are written as Rust unit tests, even the integration tests. New integration tests can be added
116-
to the `sdk/tests` directory. The tests are run using the `cargo test` command, but note that you will need to set the
117-
`RECALL_PRIVATE_KEY` environment variable and start the `localnet` container before running the tests.
119+
to the `sdk/tests` directory.
118120

119121
### Adding New CLI Tests
120122

121-
CLI tests are currently bash scripts located in the `dagger/ci/cli-tests` directory. These tests are run through the
122-
[CI pipeline](./dagger/README.md) and run against a `localnet` Docker image launched through Dagger. You can add new
123-
tests by creating a new bash script in this directory. The test scripts are numbered to ensure a deterministic order of
124-
execution.
123+
CLI tests are currently bash scripts located in the `tests/cli` directory. You can add new tests by creating a new bash
124+
script in this directory. The test scripts are numbered to ensure a deterministic order of execution.
125125

126126
## Contributing
127127

cli/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ fn apply_flags_on_network_spec(mut spec: NetworkSpec, cli: &Cli) -> NetworkSpec
284284
spec.subnet_config.evm_registry_address = x;
285285
}
286286

287-
if let Some(parent) = spec.parent_config.as_mut() {
287+
if let Some(parent) = spec.parent_network_config.as_mut() {
288288
if let Some(ref x) = cli.parent_evm_rpc_url {
289289
parent.evm_rpc_url = x.clone();
290290
}

dagger/README.md

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ This module contains the code for the Recall CI pipeline. It uses [Dagger](https
44
Recall CLI and SDK tests against a `localnet` Docker image. It can be run identically both locally and in CI.
55

66
## Prerequisites
7-
- [Dagger](https://dagger.io/docs/install) installed
7+
- [Dagger](https://docs.dagger.io/install) installed
88
- [Docker](https://docs.docker.com/get-docker/) installed and running
9-
- [Golang](https://golang.org/doc/install) installed (for `dagger` CLI)
109

1110
## Initializing the pipeline
1211

@@ -24,15 +23,40 @@ To run the pipeline, use the following command:
2423
```bash
2524
DAGGER_NO_NAG=1 \
2625
DO_NOT_TRACK=1 \
27-
RECALL_PRIVATE_KEY=0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97 \
28-
DOCKER_PASSWORD=[password] \
26+
dagger call test --progress plain \
27+
--source ../ \
28+
2>&1 | grep -vi -E "resolve|containerd|libnetwork|client|daemon|checkpoint|task|^$"
29+
```
30+
31+
The `grep` command is used to filter out some of the Dagger output that is not relevant to the pipeline. You can remove
32+
it if you want to see all the output.
33+
34+
### Specifying Docker Credentials
35+
36+
Docker credentials can optionally be passed in to avoid throttling issues with Docker Hub:
37+
38+
```bash
39+
DAGGER_NO_NAG=1 \
40+
DO_NOT_TRACK=1 \
2941
dagger call test --progress plain \
30-
--docker-username [username] \
42+
--source ../ \
43+
--docker-username $DOCKER_USERNAME \
3144
--docker-password env://DOCKER_PASSWORD \
32-
--recall-private-key env://RECALL_PRIVATE_KEY \
33-
--source ../
45+
2>&1 | grep -vi -E "resolve|containerd|libnetwork|client|daemon|checkpoint|task|^$"
3446
```
3547

36-
Docker credentials are passed in to avoid throughput issues with Docker Hub. These can be made optional in a future PR.
48+
### Specifying the Localnet Docker image
3749

38-
The `RECALL_PRIVATE_KEY` environment variable is for one of the wallets created by `anvil`.
50+
The pipeline uses the latest `textile/recall-localnet` Docker image by default. If you want to use a different image,
51+
perhaps a locally built one, you can specify it using the `--localnet-image` flag:
52+
53+
```bash
54+
DAGGER_NO_NAG=1 \
55+
DO_NOT_TRACK=1 \
56+
dagger call test --progress plain \
57+
--source ../ \
58+
--localnet-image "textile/recall-localnet:sha-dc4da8c-3e80bf0" \
59+
--docker-username $DOCKER_USERNAME \
60+
--docker-password env://DOCKER_PASSWORD \
61+
2>&1 | grep -vi -E "resolve|containerd|libnetwork|client|daemon|checkpoint|task|^$"
62+
```

dagger/ci/cli-tests/00-account-deposit.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)