-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(ci): build job matrix dinamically
- Loading branch information
1 parent
ed2a8df
commit 3bcd8a0
Showing
1 changed file
with
29 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -36,21 +36,37 @@ jobs: | |
outputs: | ||
matrix: ${{ steps.set-matrix.outputs.matrix }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- 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: | | ||
CRATES=$(echo $(cat .github/workflows/scripts/crates.json) | sed 's/ //g' ) | ||
echo "::set-output name=matrix::$CRATES" | ||
TEMP_DIR=$(mktemp -d) | ||
CRATES=$(cargo tree --depth 0 --edges no-normal,no-dev,no-build,no-proc-macro --format {p} --prefix none) | ||
echo "$( echo '${CRATES}' | cut -d ' ' -f1 | sed '/^$/d' | awk '{ printf "\"%s\",\n", $0 }' | sed '$ s/.$//')" > $TEMP_DIR/crates.txt | ||
MATRIX=$(( | ||
echo '{ "crates" : [' | ||
echo "$(cat $TEMP_DIR/crates.txt)" | ||
echo " ]}" | ||
) | jq -c .) | ||
echo $MATRIX | ||
echo $MATRIX | jq . | ||
echo "::set-output name=matrix::$MATRIX" | ||
test: | ||
name: Test ${{ matrix.crate.name }} crate on ${{ matrix.os }} | ||
name: Test ${{ matrix.crate }} crate | ||
needs: [ matrix ] | ||
runs-on: ${{ matrix.os }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
os: [ ubuntu-latest ] | ||
crate: ${{ fromJson(needs.matrix.outputs.matrix) }} | ||
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }} | ||
|
||
steps: | ||
- uses: actions/[email protected] | ||
|
@@ -63,20 +79,20 @@ jobs: | |
profile: minimal | ||
override: true | ||
|
||
- name: Build ${{ matrix.crate.name }} crate normally | ||
- name: Build ${{ matrix.crate }} crate normally | ||
uses: actions-rs/[email protected] | ||
with: | ||
command: build | ||
args: --package ${{ matrix.crate.name }} | ||
args: --package ${{ matrix.crate }} | ||
|
||
- name: Build ${{ matrix.crate.name }} crate with all features | ||
uses: actions-rs/[email protected] | ||
with: | ||
command: build | ||
args: --package ${{ matrix.crate.name }} --all-features | ||
args: --package ${{ matrix.crate }} --all-features | ||
|
||
- name: Build ${{ matrix.crate.name }} crate with no default features | ||
- name: Build ${{ matrix.crate }} crate with no default features | ||
uses: actions-rs/[email protected] | ||
with: | ||
command: build | ||
args: --package ${{ matrix.crate.name }} --no-default-features | ||
args: --package ${{ matrix.crate }} --no-default-features |