Skip to content
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

feat(ci): build each crate individually #4640

Merged
merged 17 commits into from
Jun 21, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions .github/workflows/build-crates-individually.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Build crates individually

on:
workflow_dispatch:
push:
branches:
- main
paths:
# production code and test code
- '**/*.rs'
# dependencies
- '**/Cargo.toml'
- '**/Cargo.lock'
# workflow definitions
- '.github/workflows/build-crates-individually.yml'
teor2345 marked this conversation as resolved.
Show resolved Hide resolved
pull_request:
paths:
# production code and test code
- '**/*.rs'
# dependencies
- '**/Cargo.toml'
- '**/Cargo.lock'
# workflow definitions
- '.github/workflows/build-crates-individually.yml'

env:
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: full
RUST_LIB_BACKTRACE: full
COLORBT_SHOW_HIDDEN: '1'

jobs:
matrix:
name: Crates matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/[email protected]

- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true

- uses: actions-rs/[email protected]
- id: set-matrix
name: Dinamically build crates JSON
run: |
TEMP_DIR=$(mktemp -d)
gustavovalverde marked this conversation as resolved.
Show resolved Hide resolved
echo "$( cargo tree --depth 0 --edges no-normal,no-dev,no-build,no-proc-macro --format {p} --prefix none | cut -d ' ' -f1 | sed '/^$/d' | awk '{ printf "\"%s\",\n", $0 }' | sed '$ s/.$//')" > $TEMP_DIR/crates.txt
JSON_CRATES=$(cat $TEMP_DIR/crates.txt)
MATRIX=$((
gustavovalverde marked this conversation as resolved.
Show resolved Hide resolved
echo '{ "crate" : ['
echo "${JSON_CRATES}"
echo " ]}"
) | jq -c .)
echo $MATRIX
echo $MATRIX | jq .
echo "::set-output name=matrix::$MATRIX"

check-matrix:
runs-on: ubuntu-latest
needs: [ matrix ]
steps:
- name: Install json2yaml
run: |
sudo npm install -g json2yaml

- name: Check matrix definition
run: |
matrix='${{ needs.matrix.outputs.matrix }}'
echo $matrix
echo $matrix | jq .
echo $matrix | json2yaml

build:
name: Build ${{ matrix.crates.crate }} crate
needs: [ matrix, check-matrix ]
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
features: ['', '--all-features', '--no-default-features']
gustavovalverde marked this conversation as resolved.
Show resolved Hide resolved
include: ${{ fromJson(needs.matrix.outputs.matrix) }}

steps:
- uses: actions/[email protected]
with:
persist-credentials: false

- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true

- name: Build ${{ matrix.crate }} with features ${{ matrix.features }}
uses: actions-rs/[email protected]
with:
command: build
args: --package ${{ matrix.crate }} ${{ matrix.features }}
15 changes: 6 additions & 9 deletions .github/workflows/continous-integration-os.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,14 @@ jobs:
args: --locked --all-features --all-targets

cargo-deny:
name: Check deny.toml ${{ matrix.checks }}
name: Check deny.toml ${{ matrix.checks }} ${{ matrix.features }}
runs-on: ubuntu-latest
strategy:
matrix:
checks:
- bans
- sources
features: ['', '--all-features', '--no-default-features']

# Prevent sudden announcement of a new advisory from failing ci:
continue-on-error: ${{ matrix.checks == 'advisories' }}
Expand All @@ -283,14 +284,10 @@ jobs:
with:
persist-credentials: false

- uses: EmbarkStudios/cargo-deny-action@v1
with:
command: check ${{ matrix.checks }}
args: --all-features --workspace

# this check runs with optional features off
# this check also runs with optional features off
# so we expect some warnings about "skip tree root was not found"
- uses: EmbarkStudios/cargo-deny-action@v1
- name: Check ${{ matrix.checks }} with features ${{ matrix.features }}
uses: EmbarkStudios/cargo-deny-action@v1
with:
command: check ${{ matrix.checks }}
args: --workspace
args: --workspace with features ${{ matrix.features }}
15 changes: 15 additions & 0 deletions .github/workflows/scripts/crates.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[
{"name":"tower-batch"},
{"name":"tower-fallback"},
{"name":"zebra-chain"},
{"name":"zebra-client"},
{"name":"zebra-consensus"},
{"name":"zebra-network"},
{"name":"zebra-node-services"},
{"name":"zebra-rpc"},
{"name":"zebra-script"},
{"name":"zebra-state"},
{"name":"zebra-test"},
{"name":"zebra-utils"},
{"name":"zebrad"}
]