-
Notifications
You must be signed in to change notification settings - Fork 52
Init Mithril Client #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Init Mithril Client #110
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
34a4885
Add Mithril Aggregator library #102
jpraynaud 9c94f81
Add Mithril Client first version #102
jpraynaud fd73d47
Add Mithril Client Dockerfile #102
jpraynaud a727dab
Add Mithril Client README #102
jpraynaud d994070
Add Mithril Client CI workflows #102
jpraynaud 1b459fe
Fix tests client #102
jpraynaud c290ca7
Add AggregatorHTTPClient tests #102
jpraynaud c67d330
Enhanced implementation Mithril Client #102
jpraynaud fd5a849
Update CI workflows #102
jpraynaud File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ jobs: | |
| override: true | ||
|
|
||
| - uses: actions/[email protected] | ||
| name: Cache mithril-core/Cargo.toml | ||
| name: Cache mithril-core/Cargo.lock | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
|
|
@@ -116,7 +116,7 @@ jobs: | |
| override: true | ||
|
|
||
| - uses: actions/[email protected] | ||
| name: Cache mithril-network/mithril-aggregator/Cargo.toml | ||
| name: Cache mithril-network/mithril-aggregator/Cargo.lock | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
|
|
@@ -161,6 +161,68 @@ jobs: | |
| with: | ||
| name: mithril-aggregator | ||
| path: mithril-network/mithril-aggregator/target/release/mithril-aggregator | ||
|
|
||
| build-mithril-client: | ||
| if: github.event.pull_request.draft == false | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout sources | ||
| uses: actions/checkout@v2 | ||
|
|
||
| - name: Install stable toolchain | ||
| uses: actions-rs/toolchain@v1 | ||
| with: | ||
| profile: minimal | ||
| toolchain: stable | ||
| components: clippy, rustfmt | ||
| override: true | ||
|
|
||
| - uses: actions/[email protected] | ||
| name: Cache mithril-network/mithril-client/Cargo.toml | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
| ~/.cargo/git | ||
| mithril-network/mithril-client/target | ||
| key: ${{ runner.os }}-${{ hashFiles('mithril-network/mithril-client/Cargo.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-key | ||
|
|
||
| - name: Cargo build | ||
| uses: actions-rs/cargo@v1 | ||
| with: | ||
| command: build | ||
| args: --release --manifest-path ./mithril-network/mithril-client/Cargo.toml | ||
|
|
||
| - name: Cargo check | ||
| uses: actions-rs/cargo@v1 | ||
| with: | ||
| command: check | ||
| args: --release --all-targets --manifest-path ./mithril-network/mithril-client/Cargo.toml | ||
|
|
||
| - name: Cargo fmt | ||
| uses: actions-rs/cargo@v1 | ||
| with: | ||
| command: fmt | ||
| args: --all --manifest-path ./mithril-network/mithril-client/Cargo.toml -- --check | ||
|
|
||
| - name: Clippy Check | ||
| uses: actions-rs/clippy-check@v1 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| args: --manifest-path ./mithril-network/mithril-client/Cargo.toml --all-features | ||
|
|
||
| - name: Run cargo test | ||
| uses: actions-rs/cargo@v1 | ||
| with: | ||
| command: test | ||
| args: --release --manifest-path ./mithril-network/mithril-client/Cargo.toml | ||
|
|
||
| - name: Publish client | ||
| uses: actions/upload-artifact@v3 | ||
| with: | ||
| name: mithril-client | ||
| path: mithril-network/mithril-client/target/release/mithril-client | ||
|
|
||
| build-mithril-node-poc: | ||
| runs-on: ubuntu-latest | ||
|
|
@@ -311,20 +373,73 @@ jobs: | |
| push: ${{ env.PUSH_PACKAGES }} | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
|
|
||
| docker-mithril-client: | ||
| runs-on: ubuntu-latest | ||
| needs: [ build-mithril-core, build-mithril-client ] | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
|
|
||
| env: | ||
| PUSH_PACKAGES: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | ||
| REGISTRY: ghcr.io | ||
| IMAGE_NAME: ${{ github.repository_owner }}/mithril-client | ||
| DOCKER_FILE: ./mithril-network/mithril-client/Dockerfile | ||
| CONTEXT: . | ||
| GITHUB_REF: ${{ github.ref}} | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v2 | ||
|
|
||
| - name: Set outputs | ||
| id: vars | ||
| run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" | ||
|
|
||
| - name: Extract branch name | ||
| shell: bash | ||
| run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" | ||
| id: extract_branch | ||
|
|
||
| - name: Log in to the Container registry | ||
| uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 | ||
| with: | ||
| registry: ${{ env.REGISTRY }} | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Extract metadata (tags, labels) for Docker | ||
| id: meta | ||
| uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 | ||
| with: | ||
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
| tags: | ||
| type=raw,value={{branch}}-{{sha}} | ||
|
|
||
| - name: Build and push Docker image | ||
| uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc | ||
| with: | ||
| context: ${{ env.CONTEXT }} | ||
| file: ${{ env.DOCKER_FILE }} | ||
| push: ${{ env.PUSH_PACKAGES }} | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
|
|
||
| generate-publish-docs: | ||
| if: github.event.pull_request.draft == false | ||
| runs-on: ubuntu-latest | ||
| needs: [ build-mithril-core, build-mithril-aggregator ] | ||
| needs: [ build-mithril-core, build-mithril-aggregator, build-mithril-client ] | ||
| steps: | ||
| - name: Checkout sources | ||
| uses: actions/checkout@v2 | ||
|
|
||
| - name: Cache mithril-core/Cargo.toml | ||
| - name: Cache mithril-core/Cargo.lock | ||
| uses: actions/[email protected] | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
| ~/.cargo/git | ||
| mithril-core/target | ||
| key: ${{ runner.os }}-${{ hashFiles('mithril-core/Cargo.toml') }} | ||
| key: ${{ runner.os }}-${{ hashFiles('mithril-core/Cargo.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-key | ||
|
|
||
|
|
@@ -335,19 +450,38 @@ jobs: | |
| args: --manifest-path ./mithril-core/Cargo.toml --target-dir ./github-pages/mithril-core | ||
|
|
||
| - uses: actions/[email protected] | ||
| name: Cache mithril-network/mithril-aggregator/Cargo.toml | ||
| name: Cache mithril-network/mithril-aggregator/Cargo.lock | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
| ~/.cargo/git | ||
| mithril-network/mithril-aggregator/target | ||
| key: ${{ runner.os }}-${{ hashFiles('mithril-network/mithril-aggregator/Cargo.toml') }} | ||
| key: ${{ runner.os }}-${{ hashFiles('mithril-network/mithril-aggregator/Cargo.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-key | ||
|
|
||
| - name: Mithril Aggregator / Generate doc | ||
| uses: actions-rs/cargo@v1 | ||
| with: | ||
| command: doc | ||
| args: --manifest-path ./mithril-core/Cargo.toml --target-dir ./github-pages/mithril-network/mithril-aggregator | ||
| args: --manifest-path ./mithril-network/mithril-aggregator/Cargo.toml --target-dir ./github-pages/mithril-network/mithril-aggregator | ||
|
|
||
| - uses: actions/[email protected] | ||
| name: Cache mithril-network/mithril-client/Cargo.lock | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
| ~/.cargo/git | ||
| mithril-network/mithril-client/target | ||
| key: ${{ runner.os }}-${{ hashFiles('mithril-network/mithril-client/Cargo.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-key | ||
|
|
||
| - name: Mithril Client / Generate doc | ||
| uses: actions-rs/cargo@v1 | ||
| with: | ||
| command: doc | ||
| args: --manifest-path ./mithril-network/mithril-client/Cargo.toml --target-dir ./github-pages/mithril-network/mithril-client | ||
|
|
||
| - name: Mithril Aggregator / Generate OpenAPI UI | ||
| uses: Legion2/swagger-ui-action@v1 | ||
|
|
@@ -420,3 +554,4 @@ jobs: | |
|
|
||
| - name: Test | ||
| run: nix-shell --run '.github/workflows/ci-test.sh' | ||
|
|
||
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -38,5 +38,4 @@ WORKDIR /app/ | |
| USER appuser | ||
|
|
||
| # Run the executable | ||
| EXPOSE 8080 | ||
| ENTRYPOINT ["/app/bin/mithril-aggregator","-vvv"] | ||
This file contains hidden or 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
This file contains hidden or 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 @@ | ||
| pub mod apispec; | ||
| pub mod entities; | ||
| pub mod fake_data; | ||
| pub mod http_server; |
This file contains hidden or 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 @@ | ||
| target/ | ||
| mithril-client | ||
| .DS_Store |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps there's a way to have client and aggregator in the same project but as different exes or crates? That would speed things up and simplify build
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible to have multiple binary built in a src/bin configuration of the project: this would allow us to build all executable files in the same job.
We can investigate further to see if it is a wise architectural choice 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it introduces coupling between the client and the aggregator via the datatypes, and it can lead down the road to hard-to-change code and deep dependencies, if we are not cautious about more dependencies to creep in.