-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update workflow to run coverage for all projects
- Loading branch information
Showing
6 changed files
with
99 additions
and
26 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
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Massa Web3 Workspace | ||
|
||
Welcome to the Massa Web3 Workspace. This space houses a collection of projects designed to bolster interaction with the Massa blockchain through TypeScript. Below is an overview of each project with links to their respective READMEs for more in-depth information. | ||
|
||
## Projects within the Workspace | ||
|
||
### 1. **Massa-web3** | ||
|
||
![check-code-coverage](https://img.shields.io/badge/coverage-95.25%25-green) | ||
|
||
**Description:** | ||
Massa-web3 is a TypeScript library that facilitates communication with the Massa blockchain. It's your key to extracting data, interfacing with smart contracts, monitoring blockchain events, and much more. | ||
|
||
- [📖 Read the full `Massa-web3` README](https://github.com/massalabs/massa-web3#readme) for detailed installation instructions, prerequisites, and additional resources. | ||
|
||
### 2. **Web3-Utils** | ||
|
||
![check-code-coverage](https://img.shields.io/badge/coverage-40%25-red) | ||
|
||
**Description:** | ||
Web3-Utils is a toolkit crafted for the Massa TypeScript projects. Although it currently lacks a dedicated README, this utility provides an array of essential tools to streamline and enhance your blockchain interactions. | ||
|
||
- README for `Web3-Utils` will be available soon. | ||
|
||
## Contributing | ||
|
||
Community contributions are the backbone of our projects. If you wish to be a part of our growth and improve our tools, we'd love to have you! Please consult the [CONTRIBUTING guidelines](CONTRIBUTING.md) of the respective project. | ||
|
||
## License | ||
|
||
All projects within the Massa Web3 Workspace are released under the [MIT License](LICENSE). | ||
|
||
## Powered By | ||
|
||
These tools are developed with ❤️ by MassaLabs. Check out the [Powered By](powered-by.md) section to see the open-source projects that make our tools possible. |
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
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
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
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 |
---|---|---|
@@ -1,28 +1,71 @@ | ||
#!/bin/bash | ||
|
||
color="red" | ||
# Define the color based on coverage threshold | ||
determine_color() { | ||
local coverage=$1 | ||
|
||
if [ "$(echo "$COVERAGE >= 80" | bc -l)" -eq 1 ]; then | ||
color="green" | ||
elif [ "$(echo "$COVERAGE >= 70" | bc -l)" -eq 1 ]; then | ||
color="orange" | ||
fi | ||
if (( $(echo "$coverage >= 80" | bc -l) )); then | ||
echo "green" | ||
elif (( $(echo "$coverage >= 70" | bc -l) )); then | ||
echo "orange" | ||
else | ||
echo "red" | ||
fi | ||
} | ||
|
||
filename="README.md" | ||
|
||
coverageLine=$(sed -n '3p' $filename) | ||
# Indexed arrays for projects and their corresponding line numbers | ||
projects=("massa-web3" "web3-utils") | ||
lines=(9 18) | ||
|
||
# Get line number for the given project | ||
get_line_number() { | ||
local project=$1 | ||
local i=0 | ||
for p in "${projects[@]}"; do | ||
if [ "$p" == "$project" ]; then | ||
echo "${lines[$i]}" | ||
return | ||
fi | ||
((i++)) | ||
done | ||
echo "" | ||
} | ||
|
||
regex="coverage-([0-9]+([.][0-9]+)?)%" | ||
line_number=$(get_line_number $PROJECT) | ||
|
||
# If no line number found, exit the script | ||
if [ -z "$line_number" ]; then | ||
echo "Project '$PROJECT' not found in the map." | ||
exit 1 | ||
fi | ||
|
||
# If no line number found, exit the script | ||
if [ -z "$line_number" ]; then | ||
echo "Project '$PROJECT' not found in the map." | ||
exit 1 | ||
fi | ||
|
||
# Extract the current coverage badge from the specified line | ||
coverageLine=$(sed -n "${line_number}p" $filename) | ||
|
||
# Regex to match the coverage percentage | ||
regex="${PROJECT}:\s*([0-9]+([.][0-9]+)?)%" | ||
|
||
if [[ $coverageLine =~ $regex ]]; then | ||
oldCoverage="${BASH_REMATCH[1]}" | ||
echo "Coverage is $COVERAGE%" | ||
echo "Coverage for $PROJECT is $COVERAGE%" | ||
else | ||
echo "No coverage found" | ||
echo "No coverage found for $PROJECT." | ||
fi | ||
|
||
if [ -z "$oldCoverage" ] || [ "$(echo "$COVERAGE - $oldCoverage >= 1" | bc -l)" -eq 1 ] || [ "$(echo "$oldCoverage - $COVERAGE >= 1" | bc -l)" -eq 1 ]; then | ||
echo "Updating badge" | ||
# Determine the color for the badge based on the coverage | ||
color=$(determine_color $COVERAGE) | ||
|
||
# Update the coverage badge if the difference in coverage is greater than or equal to 1% | ||
if [ -z "$oldCoverage" ] || (( $(echo "$COVERAGE - $oldCoverage >= 1" | bc -l) )) || (( $(echo "$oldCoverage - $COVERAGE >= 1" | bc -l) )); then | ||
echo "Updating badge for $PROJECT." | ||
newLine="![check-code-coverage](https://img.shields.io/badge/coverage-$COVERAGE%25-$color)" | ||
sed -i "3s#.*#${newLine}#" $filename | ||
sed -i "" "${line_number}s#.*#${newLine}#" $filename | ||
fi |