feat: adjust minimum coverage threshold in test execution for improve… #100
Workflow file for this run
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
name: Auto Tagging | |
on: | |
pull_request: | |
branches: | |
- main | |
types: | |
- closed | |
push: | |
branches: | |
- develop | |
jobs: | |
auto-tag: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Git | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Actions" | |
- name: Create 0.0.0 tag if no tag exists | |
id: initial_tag | |
run: | | |
# Check if there is any tags in the repository | |
TAG=$(git tag --list) | |
if [[ -z "$TAG" ]]; then | |
# Se não houver nenhuma tag, cria a tag '0.0.0' | |
TAG="0.0.0" | |
echo "No tags found. Creating initial '0.0.0' tag." | |
git tag "$TAG" | |
git push origin "$TAG" | |
echo "'0.0.0' tag created successfully: $TAG" | |
else | |
echo "Tags already exist in the repository." | |
fi | |
- name: Get the last valid tag | |
id: last_tag | |
run: | | |
# Get the last stable version (X.Y.Z), ignoring dev-* | |
LAST_STABLE_TAG=$(git tag --list --sort=-v:refname | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1) | |
# Get the last feature version (dev-X.Y.Z-N) | |
LAST_FEATURE_TAG=$(git tag --list --sort=-v:refname "dev-*" | head -n 1 | sed 's/dev-//') | |
# Set the base for the new version | |
if [[ -z "$LAST_STABLE_TAG" ]]; then | |
LAST_STABLE_TAG="0.0.0" | |
fi | |
echo "Last stable version: $LAST_STABLE_TAG" | |
echo "Last feature version: $LAST_FEATURE_TAG" | |
echo "tag=$LAST_STABLE_TAG" >> $GITHUB_ENV | |
echo "feature_tag=$LAST_FEATURE_TAG" >> $GITHUB_ENV | |
- name: Determine new version number | |
id: new_tag | |
run: | | |
STABLE_TAG="${{ env.tag }}" | |
FEATURE_TAG="${{ env.feature_tag }}" | |
BASE_TAG="$STABLE_TAG" | |
# Fix the assignment of BRANCH for the push event | |
if [[ "${{ github.event_name }}" == "push" ]]; then | |
BRANCH="${{ github.ref }}" # Full ref: refs/heads/develop | |
BRANCH="${BRANCH/refs\/heads\//}" # Remove the 'refs/heads/' prefix | |
else | |
BRANCH="${GITHUB_HEAD_REF}" | |
fi | |
PREFIX="" | |
NEW_SUFFIX="" | |
if [[ "$BRANCH" =~ ^(release|perf)/.* || "$BRANCH" == "release" ]]; then | |
IFS='.' read -r -a VERSION <<< "$BASE_TAG" | |
VERSION[1]=$((VERSION[1] + 1)) | |
VERSION[2]=0 | |
NEW_SUFFIX="" | |
BASE_TAG="${VERSION[0]}.${VERSION[1]}.${VERSION[2]}" | |
elif [[ "$BRANCH" =~ ^(bugfix|hotfix)/.* ]]; then | |
IFS='.' read -r -a VERSION <<< "$BASE_TAG" | |
VERSION[2]=$((VERSION[2] + 1)) | |
NEW_SUFFIX="" | |
BASE_TAG="${VERSION[0]}.${VERSION[1]}.${VERSION[2]}" | |
else | |
PREFIX="dev-" | |
# If the last feature was based on the last stable version, continue the increment | |
if [[ "$FEATURE_TAG" == "$STABLE_TAG"-* ]]; then | |
LAST_SUFFIX=$(echo "$FEATURE_TAG" | grep -oE '[0-9]+$' || echo "-1") | |
else | |
# Otherwise, start counting from the new stable version | |
LAST_SUFFIX="-1" | |
fi | |
NEW_SUFFIX=$((LAST_SUFFIX + 1)) | |
fi | |
if [[ -n "$NEW_SUFFIX" ]]; then | |
NEW_TAG="${PREFIX}${BASE_TAG}-${NEW_SUFFIX}" | |
else | |
NEW_TAG="${PREFIX}${BASE_TAG}" | |
fi | |
echo "New tag: $NEW_TAG" | |
echo "new_tag=$NEW_TAG" >> $GITHUB_ENV | |
- name: Create and push new tag | |
run: | | |
# Check if the PR was merged or if it's a direct push to develop | |
if [[ "${{ github.event.pull_request.merged }}" != "true" && "${{ github.event_name }}" != "push" ]]; then | |
echo "The PR was not merged or the event is not a push. Ending the workflow." | |
exit 0 | |
fi | |
if [[ "${{ env.disabled }}" == "true" ]]; then | |
echo "Process is disabled. Skipping tag creation." | |
exit 0 | |
fi | |
git tag "${{ env.new_tag }}" | |
git push origin "${{ env.new_tag }}" |