Merge branch 'ci/dynamic-badge'
This commit is contained in:
commit
c35912fd4a
|
@ -0,0 +1,26 @@
|
||||||
|
name: Badges
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update-badges:
|
||||||
|
name: Update Badges
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Get the Numbers
|
||||||
|
run: |
|
||||||
|
echo "dep_counts=$(./scripts/count-dependencies.sh)" >> $GITHUB_ENV
|
||||||
|
- name: Create Dependency-Count-Badge
|
||||||
|
uses: schneegans/dynamic-badges-action@v1.0.0
|
||||||
|
with:
|
||||||
|
auth: ${{ secrets.GIST_SECRET }}
|
||||||
|
gistID: a2128afe12bf05d85a0d68346236a4f5
|
||||||
|
filename: sailfish-dep-counts.json
|
||||||
|
label: Dependencies
|
||||||
|
message: ${{ env.dep_counts }}
|
||||||
|
color: blueviolet
|
|
@ -6,6 +6,7 @@ Simple, small, and extremely fast template engine for Rust
|
||||||
|
|
||||||
[![Tests](https://github.com/Kogia-sima/sailfish/workflows/Tests/badge.svg)](https://github.com/Kogia-sima/sailfish/actions?query=workflow%3ATests)
|
[![Tests](https://github.com/Kogia-sima/sailfish/workflows/Tests/badge.svg)](https://github.com/Kogia-sima/sailfish/actions?query=workflow%3ATests)
|
||||||
[![Version](https://img.shields.io/crates/v/sailfish)](https://crates.io/crates/sailfish)
|
[![Version](https://img.shields.io/crates/v/sailfish)](https://crates.io/crates/sailfish)
|
||||||
|
![Dependency counts](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/Kogia-sima/a2128afe12bf05d85a0d68346236a4f5/raw/sailfish-dep-counts.json)
|
||||||
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/Kogia-sima/sailfish/blob/master/LICENSE)
|
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/Kogia-sima/sailfish/blob/master/LICENSE)
|
||||||
|
|
||||||
[User Guide](https://sailfish.netlify.app/en/) | [API Docs](https://docs.rs/sailfish) | [Examples](./examples)
|
[User Guide](https://sailfish.netlify.app/en/) | [API Docs](https://docs.rs/sailfish) | [Examples](./examples)
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
IFS=$'\n'
|
||||||
|
PACKAGES=("sailfish" "sailfish-macros" "sailfish-compiler")
|
||||||
|
|
||||||
|
git-root () {
|
||||||
|
if git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
||||||
|
cd `git rev-parse --show-toplevel`;
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
get_dependencies() {
|
||||||
|
cargo tree -p "$1" | while read line; do
|
||||||
|
dev_dependencies_re="\[dev-dependencies\]"
|
||||||
|
crate_re="[a-zA-Z0-9_-]+ v[^ ]+"
|
||||||
|
|
||||||
|
if [[ "$line" =~ $crate_re ]]; then
|
||||||
|
echo ${BASH_REMATCH[0]}
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$line" =~ $dev_dependencies_re ]]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
remove_packages() {
|
||||||
|
local found
|
||||||
|
|
||||||
|
for dep in $@; do
|
||||||
|
found=0
|
||||||
|
for pkg in ${PACKAGES[@]}; do
|
||||||
|
pat="$pkg v[^ ]"
|
||||||
|
if [[ "$dep" =~ $pat ]]; then
|
||||||
|
found=1
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ $found == 0 ]]; then
|
||||||
|
echo $dep
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# go to root directory
|
||||||
|
cd `git rev-parse --show-toplevel`
|
||||||
|
|
||||||
|
deps=()
|
||||||
|
|
||||||
|
for pkg in ${PACKAGES[@]}; do
|
||||||
|
deps+=( `get_dependencies $pkg` )
|
||||||
|
done
|
||||||
|
|
||||||
|
deps=( $(printf "%s\n" "${deps[@]}" | sort -u) )
|
||||||
|
|
||||||
|
remove_packages ${deps[*]} |wc -l
|
Loading…
Reference in New Issue