69 lines
2.3 KiB
YAML
69 lines
2.3 KiB
YAML
name: Build crates individually
|
|
|
|
# We need to keep the `matrix` job in this workflow as-is, as we need the results
|
|
# to actually match the same `build` job names from the original file.
|
|
on:
|
|
pull_request:
|
|
paths-ignore:
|
|
# production code and test code
|
|
- '**/*.rs'
|
|
# dependencies
|
|
- '**/Cargo.toml'
|
|
- '**/Cargo.lock'
|
|
# workflow definitions
|
|
- '.github/workflows/build-crates-individually.yml'
|
|
|
|
jobs:
|
|
matrix:
|
|
name: Crates matrix
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
|
steps:
|
|
- uses: actions/checkout@v3.0.2
|
|
|
|
- uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
profile: minimal
|
|
override: true
|
|
|
|
- uses: actions-rs/cargo@v1.0.3
|
|
# This step is meant to dynamically create a JSON containing the values of each crate
|
|
# available in this repo in the root directory. We use `cargo tree` to accomplish this task.
|
|
#
|
|
# The result from `cargo tree` is then transform to JSON values between double quotes,
|
|
# and separated by commas, then added to a `crates.txt` and assigned to a $JSON_CRATES variable.
|
|
#
|
|
# A JSON object is created and assigned to a $MATRIX variable, which is use to create an output
|
|
# named `matrix`, which is then used as the input in following steps,
|
|
# using ` ${{ fromJson(needs.matrix.outputs.matrix) }}`
|
|
- id: set-matrix
|
|
name: Dynamically build crates JSON
|
|
run: |
|
|
TEMP_DIR=$(mktemp -d)
|
|
echo "$(cargo tree --depth 0 --edges no-normal,no-dev,no-build,no-proc-macro --prefix none | cut -d ' ' -f1 | sed '/^$/d' | awk '{ printf "\"%s\",\n", $0 }' | sed '$ s/.$//')" > $TEMP_DIR/crates.txt
|
|
MATRIX=$( (
|
|
echo '{ "crate" : ['
|
|
echo "$(cat $TEMP_DIR/crates.txt)"
|
|
echo " ]}"
|
|
) | jq -c .)
|
|
echo $MATRIX
|
|
echo $MATRIX | jq .
|
|
echo "::set-output name=matrix::$MATRIX"
|
|
|
|
check-matrix:
|
|
runs-on: ubuntu-latest
|
|
needs: [ matrix ]
|
|
steps:
|
|
- run: 'echo "No job required"'
|
|
|
|
build:
|
|
name: Build ${{ matrix.crate }} crate
|
|
needs: [ matrix, check-matrix ]
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
|
|
|
|
steps:
|
|
- run: 'echo "No job required"' |