diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 43ca3df378d..c3b783b0b77 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,6 +72,7 @@ jobs: uses: actions/upload-artifact@v3 with: name: libmithril + if-no-files-found: error path: | mithril-core/target/release/libmithril.so mithril-core/target/include/mithril.h @@ -80,6 +81,7 @@ jobs: uses: actions/upload-artifact@v3 with: name: libmithril-doc + if-no-files-found: error path: | mithril-core/target/doc/ @@ -162,9 +164,13 @@ jobs: path: | ./**/test-results-*.xml - build-mithril-common: + build-mithril: if: github.event.pull_request.draft == false runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + project: [ mithril-common, mithril-aggregator, mithril-client, mithril-signer ] steps: - name: Checkout sources uses: actions/checkout@v2 @@ -178,13 +184,13 @@ jobs: override: true - uses: actions/cache@v2.1.5 - name: Cache mithril-common/Cargo.lock + name: Cache ${{ matrix.project }}/Cargo.lock with: path: | ~/.cargo/registry ~/.cargo/git - mithril-common/target - key: ${{ runner.os }}-${{ hashFiles('mithril-common/Cargo.lock') }} + ${{ matrix.project }}/target + key: ${{ runner.os }}-${{ hashFiles('${{ matrix.project }}/Cargo.lock') }} restore-keys: | ${{ runner.os }}-key @@ -201,26 +207,26 @@ jobs: uses: actions-rs/cargo@v1 with: command: build - args: --release --manifest-path ./mithril-common/Cargo.toml + args: --release --manifest-path ./${{ matrix.project }}/Cargo.toml - name: Cargo check uses: actions-rs/cargo@v1 with: command: check - args: --release --all-targets --manifest-path ./mithril-common/Cargo.toml + args: --release --all-targets --manifest-path ./${{ matrix.project }}/Cargo.toml - name: Cargo fmt uses: actions-rs/cargo@v1 with: command: fmt - args: --all --manifest-path ./mithril-common/Cargo.toml -- --check + args: --all --manifest-path ./${{ matrix.project }}/Cargo.toml -- --check - name: Clippy Check uses: actions-rs/clippy-check@v1 with: - name: clippy-mithril-common + name: clippy-${{ matrix.project }} token: ${{ secrets.GITHUB_TOKEN }} - args: --manifest-path ./mithril-common/Cargo.toml --all-features + args: --manifest-path ./${{ matrix.project }}/Cargo.toml --all-features - name: Install cargo2junit run: | @@ -229,433 +235,50 @@ jobs: - name: Run cargo test shell: bash - working-directory: mithril-common + working-directory: ${{ matrix.project }} run: | - set -o pipefail && cargo test --release -- -Z unstable-options --format json --report-time | tee >(cargo2junit > test-results-mithril-common.xml) + set -o pipefail && cargo test --release -- -Z unstable-options --format json --report-time | tee >(cargo2junit > test-results-${{ matrix.project }}.xml) - - name: Mithril Aggregator / Generate doc + - name: Generate ${{ matrix.project }} doc uses: actions-rs/cargo@v1 with: command: doc - args: --no-deps --release --manifest-path ./mithril-common/Cargo.toml + args: --no-deps --release --manifest-path ./${{ matrix.project }}/Cargo.toml - - name: Publish common + - name: Publish ${{ matrix.project }} uses: actions/upload-artifact@v3 with: - name: mithril-common - path: mithril-common/target/release/mithril-common - - - name: Publish common-doc - uses: actions/upload-artifact@v3 - with: - name: mithril-common-doc - path: | - mithril-common/target/doc/ - - - name: Upload Unit Test Results - if: always() - uses: actions/upload-artifact@v3 - with: - name: test-results-mithril-common - path: | - ./**/test-results-*.xml - - build-mithril-aggregator: - 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-aggregator/Cargo.lock - with: - path: | - ~/.cargo/registry - ~/.cargo/git - mithril-aggregator/target - key: ${{ runner.os }}-${{ hashFiles('mithril-aggregator/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-key - - - uses: actions/cache@v2.1.5 - name: Cache cargo2junit - with: - path: | - ~/.cargo/bin/cargo2junit - key: ${{ runner.os }}-${{ hashFiles('~/.cargo/bin/cargo2junit') }} - restore-keys: | - ${{ runner.os }}-cargo2junit-key - - - name: Cargo build - uses: actions-rs/cargo@v1 - with: - command: build - args: --release --manifest-path ./mithril-aggregator/Cargo.toml - - - name: Cargo check - uses: actions-rs/cargo@v1 - with: - command: check - args: --release --all-targets --manifest-path ./mithril-aggregator/Cargo.toml - - - name: Cargo fmt - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all --manifest-path ./mithril-aggregator/Cargo.toml -- --check - - - name: Clippy Check - uses: actions-rs/clippy-check@v1 - with: - name: clippy-mithril-aggregator - token: ${{ secrets.GITHUB_TOKEN }} - args: --manifest-path ./mithril-aggregator/Cargo.toml --all-features - - - name: Install cargo2junit - run: | - # Suppress the "binary `cargo2junit` already exists in destination" error - cargo install cargo2junit 2>/dev/null || true - - - name: Run cargo test - shell: bash - working-directory: mithril-aggregator - run: | - set -o pipefail && cargo test --release -- -Z unstable-options --format json --report-time | tee >(cargo2junit > test-results-mithril-aggregator.xml) - - - name: Mithril Aggregator / Generate doc - uses: actions-rs/cargo@v1 - with: - command: doc - args: --no-deps --release --manifest-path ./mithril-aggregator/Cargo.toml - - - name: Publish aggregator - uses: actions/upload-artifact@v3 - with: - name: mithril-aggregator - path: mithril-aggregator/target/release/mithril-aggregator - - - name: Publish aggregator-doc - uses: actions/upload-artifact@v3 - with: - name: mithril-aggregator-doc - path: | - mithril-aggregator/target/doc/ - - - name: Upload Unit Test Results - if: always() - uses: actions/upload-artifact@v3 - with: - name: test-results-mithril-aggregator - path: | - ./**/test-results-*.xml - - 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-client/Cargo.toml - with: - path: | - ~/.cargo/registry - ~/.cargo/git - mithril-client/target - key: ${{ runner.os }}-${{ hashFiles('mithril-client/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-key - - - uses: actions/cache@v2.1.5 - name: Cache cargo2junit - with: - path: | - ~/.cargo/bin/cargo2junit - key: ${{ runner.os }}-${{ hashFiles('~/.cargo/bin/cargo2junit') }} - restore-keys: | - ${{ runner.os }}-cargo2junit-key - - - name: Cargo build - uses: actions-rs/cargo@v1 - with: - command: build - args: --release --manifest-path ./mithril-client/Cargo.toml - - - name: Cargo check - uses: actions-rs/cargo@v1 - with: - command: check - args: --release --all-targets --manifest-path ./mithril-client/Cargo.toml - - - name: Cargo fmt - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all --manifest-path ./mithril-client/Cargo.toml -- --check - - - name: Clippy Check - uses: actions-rs/clippy-check@v1 - with: - name: clippy-mithril-client - token: ${{ secrets.GITHUB_TOKEN }} - args: --manifest-path ./mithril-client/Cargo.toml --all-features - - - name: Install cargo2junit - run: | - # Suppress the "binary `cargo2junit` already exists in destination" error - cargo install cargo2junit 2>/dev/null || true - - - name: Run cargo test - shell: bash - working-directory: mithril-client - run: | - set -o pipefail && cargo test --release -- -Z unstable-options --format json --report-time | tee >(cargo2junit > test-results-mithril-client.xml) - - - name: Mithril Client / Generate doc - uses: actions-rs/cargo@v1 - with: - command: doc - args: --no-deps --release --manifest-path ./mithril-client/Cargo.toml - - - name: Publish client - uses: actions/upload-artifact@v3 - with: - name: mithril-client - path: mithril-client/target/release/mithril-client - - - name: Publish client-doc - uses: actions/upload-artifact@v3 - with: - name: mithril-client-doc - path: | - mithril-client/target/doc/ - - - name: Upload Unit Test Results - if: always() - uses: actions/upload-artifact@v3 - with: - name: test-results-mithril-client - path: | - ./**/test-results-*.xml - - build-mithril-signer: - 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-signer/Cargo.toml - with: + name: ${{ matrix.project }} path: | - ~/.cargo/registry - ~/.cargo/git - mithril-signer/target - key: ${{ runner.os }}-${{ hashFiles('mithril-signer/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-key - - - uses: actions/cache@v2.1.5 - name: Cache cargo2junit - with: - path: | - ~/.cargo/bin/cargo2junit - key: ${{ runner.os }}-${{ hashFiles('~/.cargo/bin/cargo2junit') }} - restore-keys: | - ${{ runner.os }}-cargo2junit-key - - - name: Cargo build - uses: actions-rs/cargo@v1 - with: - command: build - args: --release --manifest-path ./mithril-signer/Cargo.toml + ${{ matrix.project }}/target/release/${{ matrix.project }} + ${{ matrix.project }}/target/release/lib*.so + if-no-files-found: error - - name: Cargo check - uses: actions-rs/cargo@v1 - with: - command: check - args: --release --all-targets --manifest-path ./mithril-signer/Cargo.toml - - - name: Cargo fmt - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all --manifest-path ./mithril-signer/Cargo.toml -- --check - - - name: Clippy Check - uses: actions-rs/clippy-check@v1 - with: - name: clippy-mithril-signer - token: ${{ secrets.GITHUB_TOKEN }} - args: --manifest-path ./mithril-signer/Cargo.toml --all-features - - - name: Install cargo2junit - run: | - # Suppress the "binary `cargo2junit` already exists in destination" error - cargo install cargo2junit 2>/dev/null || true - - - name: Run cargo test - shell: bash - working-directory: mithril-signer - run: | - set -o pipefail && cargo test --release -- -Z unstable-options --format json --report-time | tee >(cargo2junit > test-results-mithril-signer.xml) - - - name: Mithril Signer / Generate doc - uses: actions-rs/cargo@v1 - with: - command: doc - args: --no-deps --release --manifest-path ./mithril-signer/Cargo.toml - - - name: Publish Signer - uses: actions/upload-artifact@v3 - with: - name: mithril-signer - path: mithril-signer/target/release/mithril-signer - - - name: Publish Signer-doc + - name: Publish ${{ matrix.project }}-doc uses: actions/upload-artifact@v3 with: - name: mithril-signer-doc + name: ${{ matrix.project }}-doc + if-no-files-found: error path: | - mithril-signer/target/doc/ + ${{ matrix.project }}/target/doc/ - name: Upload Unit Test Results if: always() uses: actions/upload-artifact@v3 with: - name: test-results-mithril-signer + name: test-results-${{ matrix.project }} path: | ./**/test-results-*.xml - docker-mithril-aggregator: - runs-on: ubuntu-latest - if: ${{ github.event_name == 'push' }} - needs: [ build-mithril-core, build-mithril-common, build-mithril-aggregator ] - 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-aggregator - DOCKER_FILE: ./mithril-aggregator/Dockerfile.ci - CONTEXT: . - GITHUB_REF: ${{ github.ref}} - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Log in to the Container registry - uses: docker/login-action@v1 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v3 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: - type=raw,value={{branch}}-{{sha}} - - - name: Download mithril aggregator executable - uses: actions/download-artifact@v3 - with: - name: mithril-aggregator - path: mithril-aggregator - - - name: Build and push Docker image - uses: docker/build-push-action@v2 - with: - context: ${{ env.CONTEXT }} - file: ${{ env.DOCKER_FILE }} - push: ${{ env.PUSH_PACKAGES }} - tags: ${{ steps.meta.outputs.tags }} - - docker-mithril-client: - runs-on: ubuntu-latest - if: ${{ github.event_name == 'push' }} - needs: [ build-mithril-core, build-mithril-common, 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-client/Dockerfile.ci - CONTEXT: . - GITHUB_REF: ${{ github.ref}} - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Log in to the Container registry - uses: docker/login-action@v1 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v3 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: - type=raw,value={{branch}}-{{sha}} - - - name: Download mithril client executable - uses: actions/download-artifact@v3 - with: - name: mithril-client - path: mithril-client - - - name: Build and push Docker image - uses: docker/build-push-action@v2 - with: - context: ${{ env.CONTEXT }} - file: ${{ env.DOCKER_FILE }} - push: ${{ env.PUSH_PACKAGES }} - tags: ${{ steps.meta.outputs.tags }} - - docker-mithril-signer: + docker-mithril: runs-on: ubuntu-latest if: ${{ github.event_name == 'push' }} - needs: [ build-mithril-core, build-mithril-common, build-mithril-signer ] + needs: [ build-mithril-core, build-mithril ] + strategy: + fail-fast: false + matrix: + project: [ mithril-aggregator, mithril-client, mithril-signer ] + permissions: contents: read packages: write @@ -663,8 +286,8 @@ jobs: env: PUSH_PACKAGES: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository_owner }}/mithril-signer - DOCKER_FILE: ./mithril-signer/Dockerfile.ci + IMAGE_NAME: ${{ github.repository_owner }}/${{ matrix.project }} + DOCKER_FILE: ./${{ matrix.project }}/Dockerfile.ci CONTEXT: . GITHUB_REF: ${{ github.ref}} @@ -687,11 +310,11 @@ jobs: tags: type=raw,value={{branch}}-{{sha}} - - name: Download mithril signer executable + - name: Download ${{ matrix.project }} executable uses: actions/download-artifact@v3 with: - name: mithril-signer - path: mithril-signer + name: ${{ matrix.project }} + path: ${{ matrix.project }} - name: Build and push Docker image uses: docker/build-push-action@v2 @@ -704,12 +327,7 @@ jobs: publish-tests-results: if: github.event.pull_request.draft == false && ${{ always() }} runs-on: ubuntu-latest - needs: - - build-mithril-common - - build-mithril-aggregator - - build-mithril-client - - build-mithril-signer - - test-mithril-core + needs: [ build-mithril, test-mithril-core ] steps: - name: Download mithril-core Tests Results if: always() @@ -751,12 +369,10 @@ jobs: if: github.event.pull_request.draft == false runs-on: ubuntu-latest needs: - - docker-mithril-aggregator - - docker-mithril-client - - docker-mithril-signer - - build-mithril-common - - test-mithril-core - - build-test-lab + - build-mithril + - docker-mithril + - test-mithril-core + - build-test-lab steps: - name: Checkout sources uses: actions/checkout@v2 @@ -822,7 +438,7 @@ jobs: build-test-lab: runs-on: ubuntu-latest - needs: [ build-mithril-core, build-mithril-aggregator, build-mithril-signer, build-mithril-client ] + needs: [ build-mithril-core, build-mithril ] steps: - name: Checkout sources uses: actions/checkout@v2 @@ -885,9 +501,7 @@ jobs: terraform: runs-on: ubuntu-latest needs: - - docker-mithril-aggregator - - docker-mithril-client - - docker-mithril-signer + - docker-mithril - test-mithril-core - build-test-lab env: