Skip to content
This repository was archived by the owner on Feb 28, 2025. It is now read-only.

Commit efad19c

Browse files
committed
26: light refactor, command line arguments, production support, codecov
1 parent 4bf3d4b commit efad19c

File tree

16 files changed

+458
-105
lines changed

16 files changed

+458
-105
lines changed

.devcontainer/devcontainer.json

+4-16
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,8 @@
77
"context": "..",
88
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
99
"dockerfile": "../Dockerfile"
10+
},
11+
"containerEnv": {
12+
"RPC_URL": "${localEnv:RPC_URL}"
1013
}
11-
12-
// Features to add to the dev container. More info: https://containers.dev/features.
13-
// "features": {},
14-
15-
// Use 'forwardPorts' to make a list of ports inside the container available locally.
16-
// "forwardPorts": [],
17-
18-
// Uncomment the next line to run commands after the container is created.
19-
// "postCreateCommand": "cat /etc/os-release",
20-
21-
// Configure tool-specific properties.
22-
// "customizations": {},
23-
24-
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
25-
// "remoteUser": "devcontainer"
26-
}
14+
}

.github/workflows/coverage.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ jobs:
1818
- name: Generate code coverage
1919
run: RUST_LOG=lib_didethresolver=info cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
2020
- name: Upload coverage to Codecov
21-
uses: codecov/codecov-action@v1
21+
uses: codecov/codecov-action@v3
2222
with:
23+
token: ${{ secrets.CODECOV_TOKEN }}
2324
files: lcov.info
2425
fail_ci_if_error: true

.github/workflows/ghcr-image.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Docker Image Build Push
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
8+
concurrency:
9+
group: "docker-image"
10+
cancel-in-progress: true
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
-
17+
name: Checkout
18+
uses: actions/checkout@v3
19+
-
20+
name: Set up QEMU
21+
uses: docker/setup-qemu-action@v2
22+
-
23+
name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v2
25+
26+
- name: Generate repository name
27+
run: |
28+
echo "REPOSITORY_PATH=$( echo ${GITHUB_REPOSITORY} | tr '[:upper:]' '[:lower:]' )" >> ${GITHUB_ENV}
29+
echo "REPOSITORY_SHA=$( echo ${GITHUB_SHA} | cut -c 1-8 )" >> ${GITHUB_ENV}
30+
-
31+
name: Login to GitHub Container Registry
32+
uses: docker/login-action@v2
33+
with:
34+
registry: ghcr.io
35+
username: ${{ github.repository_owner }}
36+
password: ${{ secrets.GITHUB_TOKEN }}
37+
-
38+
name: Build and Push
39+
uses: docker/build-push-action@v3
40+
with:
41+
context: .
42+
file: ./prod/Dockerfile
43+
platforms: linux/amd64,linux/arm64
44+
push: true
45+
build-args: |
46+
VERSION=${{ github.ref_name }}
47+
CARGO_INCREMENTAL=0
48+
tags: |
49+
ghcr.io/${{ env.REPOSITORY_PATH }}:v${{ github.ref_name }}
50+
ghcr.io/${{ env.REPOSITORY_PATH }}:${{ env.REPOSITORY_SHA }}
51+
ghcr.io/${{ env.REPOSITORY_PATH }}:latest
52+
-
53+
name: GitHub Release
54+
uses: actions/create-release@v1
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
with:
58+
draft: false
59+
prerelease: false
60+
tag_name: ${{ github.ref_name }}
61+
release_name: v${{ github.ref_name }}
62+
body_path: CHANGELOG.md

.github/workflows/github-pages.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
- name: Invoke cargo doc
4343
run: |
4444
rm -rf ./_site
45-
cargo doc --lib --no-deps
45+
cargo doc --workspace --no-deps
4646
rm -f target/doc/.lock
4747
cp -r target/doc _site
4848
echo "<meta http-equiv=\"refresh\" content=\"0; url=didethresolver\">" > _site/index.html

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# 0.1.0 (2024-01-24)
2+
3+
* inital production support
4+
* light refactor
5+
* command line and environment variables
6+
* url parser

Cargo.lock

+124-27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[workspace]
22
members = [
33
"lib",
4-
"gateway",
5-
"examples/*",
4+
"resolver",
5+
"examples/*",
66
]
77

88
exclude = [ ]

Dockerfile

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
FROM ghcr.io/xmtp/rust:latest
2-
ARG CARGO_INCREMENTAL
32
ARG PROJECT=didethresolver
3+
ARG CARGO_INCREMENTAL
4+
45
WORKDIR /workspaces/${PROJECT}
56

67
RUN sudo apt update && sudo apt install -y pkg-config openssl libssl-dev
78

89
USER xmtp
910
ENV USER=xmtp
10-
ENV PATH=/home/${USER}/.cargo/bin:$PATH
11+
ENV PATH=~${USER}/.cargo/bin:$PATH
1112
# source $HOME/.cargo/env
1213

1314
COPY --from=ghcr.io/xmtp/foundry:latest /usr/local/bin/anvil /usr/local/bin/anvil
1415

1516
COPY --chown=xmtp:xmtp . .
1617

1718
ENV CARGO_INCREMENTAL=${CARGO_INCREMENTAL:-1}
19+
RUN cargo check --all-features
1820
RUN cargo fmt --check --all
1921
RUN cargo clippy --all-features --no-deps -- -D warnings
2022
RUN cargo test --workspace --all-features
23+
RUN CARGO_TARGET_DIR=/workspaces/${PROJECT}/target cargo install --path resolver --bin=resolver --root ~${USER}/.cargo/
24+
RUN valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose ~${USER}/.cargo/bin/resolver --help
2125

22-
CMD cargo run
26+
ENV RUST_LOG=info
27+
CMD cargo run --package=resolver -- --host 0.0.0.0 --port 8080

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# didethresolver
22

33
[![Test](https://github.com/xmtp/didethresolver/actions/workflows/ci-image.yml/badge.svg)](https://github.com/xmtp/didethresolver/actions/workflows/ci-image.yml)
4+
[![codecov](https://codecov.io/gh/xmtp/didethresolver/graph/badge.svg?token=94DHM3ODWQ)](https://codecov.io/gh/xmtp/didethresolver)
45

56
This resolver service implements a DID registry resolver to resolve
67
decentralized identifiers for the XMTP client sdk.
@@ -70,6 +71,6 @@ See the `examples/` folder for more usage examples
7071
## Organization
7172

7273
The workspace is organized into a binary and library crate. the binary,
73-
`didethresolver`, runs a standalone JSON-RPC server which resolves DIDs. The
74+
`resolver`, runs a standalone JSON-RPC server which resolves DIDs. The
7475
library, `lib-didethresolver` provides methods and types used to resolve dids,
7576
as well as build a JSON-RPC client and server.

example.env

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
ADDRESS="127.0.0.1:9944"
2-
PROVIDER="http://127.0.0.1:8545"
1+
RESOLVER_HOST=127.0.0.1
2+
RESOLVER_PORT=9944
3+
RPC_URL=http://127.0.0.1:8545

0 commit comments

Comments
 (0)