Skip to content

Commit

Permalink
Add Mithril Client CI workflows #102
Browse files Browse the repository at this point in the history
  • Loading branch information
jpraynaud committed Apr 14, 2022
1 parent a727dab commit d994070
Showing 1 changed file with 116 additions and 3 deletions.
119 changes: 116 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,62 @@ 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/cache@v2.1.5
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

build-mithril-node-poc:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -311,10 +367,61 @@ 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
Expand Down Expand Up @@ -347,7 +454,13 @@ jobs:
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

- name: Mithril Client / Generate doc
uses: actions-rs/cargo@v1
with:
command: doc
args: --manifest-path ./mithril-network/mithril-aggregator/Cargo.toml --target-dir ./github-pages/mithril-network/mithril-client

- name: Mithril Aggregator / Generate OpenAPI UI
uses: Legion2/swagger-ui-action@v1
Expand Down Expand Up @@ -380,7 +493,7 @@ jobs:

build-test-lab:
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
Expand Down

0 comments on commit d994070

Please sign in to comment.