Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Development improvements: Refactor "ddev next" command. Add issues templates. Add code of conduct file, add contributing file, update licence. Remove Scrutinizer test. #95

Merged
merged 2 commits into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 73 additions & 18 deletions .ddev/commands/web/next
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,93 @@
## Usage: next
## Example: "ddev next, ddev next patch, ddev next minor, ddev next major"

INCREASE_PATCH="patch"
INCREASE_MINOR="minor"
INCREASE_MAJOR="major"
DEFAULT_BRANCH=$(git remote show origin | grep 'HEAD branch' | cut -d' ' -f5)

versionType=${1:-$INCREASE_PATCH}
# Ensure DEFAULT_BRANCH is set
if [ -z "$DEFAULT_BRANCH" ]; then
echo "Error: DEFAULT_BRANCH could not be determined."
exit 1
fi

IFS='.' read -ra lastTagParts <<< "$(git tag -l --sort=v:refname | tail -1)"
# Check if on '${DEFAULT_BRANCH}' branch
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ "$CURRENT_BRANCH" != "$DEFAULT_BRANCH" ]; then
echo "You are on branch '$CURRENT_BRANCH'. Before tagging please switch to the '$DEFAULT_BRANCH' branch and make sure it's up to date by running 'git pull'. Then run 'ddev next' command again."
exit 1
fi

# Fetch the latest state of the remote branch
if ! git fetch -q origin $DEFAULT_BRANCH; then
echo "Error: Failed to fetch from origin. Please check your network connection and remote repository configuration."
exit 1
fi

# Check if the local branch is behind the remote branch
LOCAL=$(git rev-parse @)
REMOTE=$(git rev-parse @{u})
BASE=$(git merge-base @ @{u})

if [ "$LOCAL" != "$REMOTE" ]; then
if [ "$LOCAL" == "$BASE" ]; then
echo "Your local '$DEFAULT_BRANCH' branch is behind the remote. Please update it with 'git pull' and run 'ddev next' command again."
exit 1
elif [ "$REMOTE" == "$BASE" ]; then
echo "Your local '$DEFAULT_BRANCH' branch has commits that are not pushed to the remote. Please push your changes with 'git push' and run 'ddev next' command again."
exit 1
else
echo "Your local '$DEFAULT_BRANCH' branch has diverged from the remote. Please resolve the divergence before proceeding."
exit 1
fi
fi


versionType=${1:-patch}
if [ ! -z "$versionType" ]; then
if [ "$versionType" != "patch" ] && [ "$versionType" != "minor" ] && [ "$versionType" != "major" ]; then
echo "Error: Invalid argument. Please use 'patch', 'minor', or 'major'."
exit 1
fi
fi

# Validate and increment version
lastTag=$(git tag -l --sort=v:refname | tail -1)
if ! [[ $lastTag =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Last tag '$lastTag' does not follow semantic versioning."
exit 1
fi

IFS='.' read -ra lastTagParts <<< "$lastTag"
major=${lastTagParts[0]}
minor=${lastTagParts[1]}
patch=${lastTagParts[2]}

case $versionType in
$INCREASE_MINOR)
major)
((major++))
minor=0
patch=0
minor=$((minor+1))
;;
$INCREASE_MAJOR)
minor)
((minor++))
patch=0
minor=0
major=$((major+1))
;;
$INCREASE_PATCH)
patch=$((patch+1))
patch)
((patch++))
;;
esac

nextTag="$major.$minor.$patch"
NEXT_TAG="$major.$minor.$patch"

sed -i "s/'version' => '[0-9]\+\.[0-9]\+\.[0-9]\+'/'version' => '$nextTag'/g" ./ext_emconf.php
if git rev-parse "$NEXT_TAG" >/dev/null 2>&1; then
echo "Error: Tag '$NEXT_TAG' already exists. Please check the current version."
exit 1
fi

sed -i "s/release=\"[0-9]\+\.[0-9]\+\.[0-9]\+\"/release=\"$nextTag\"/g" ./Documentation/guides.xml
sed -i'' -E "s/(<project[^>]* version=\")[^\"]+(\")/\1$nextTag\2/" ./Documentation/guides.xml
# Update files with the new version
sed -i "s/'version' => '[0-9]\+\.[0-9]\+\.[0-9]\+'/'version' => '$NEXT_TAG'/g" ./ext_emconf.php
sed -i "s/release=\"[0-9]\+\.[0-9]\+\.[0-9]\+\"/release=\"$NEXT_TAG\"/g" ./Documentation/guides.xml
sed -i'' -E "s/(<project[^>]* version=\")[^\"]+(\")/\1$NEXT_TAG\2/" ./Documentation/guides.xml

default_branch=$(git remote show origin | grep 'HEAD branch' | cut -d' ' -f5)
echo "git add Documentation/guides.xml ext_emconf.php && git commit -m 'Tag new version' && git tag -a '$nextTag' -m '$nextTag' -s && git push origin $default_branch --tags"
# Prepare command to tag the new version
echo "Copy the command below and run it to tag the new version:"
echo "git add Documentation/guides.xml ext_emconf.php && git commit -m 'Tag version $NEXT_TAG' && git tag -a '$NEXT_TAG' -m 'Version $NEXT_TAG' -s && git push origin $DEFAULT_BRANCH --tags"
82 changes: 82 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Bug report
description: Create a report to help improve the extension.
title: "[BUG]"
labels:
- bug
assignees:
- kszymukowicz
body:
- type: input
id: typo3-version
attributes:
label: TYPO3 version
description: What TYPO3 version are you using?
placeholder: 'e.g. 12.4.2'
validations:
required: true
- type: input
id: php-version
attributes:
label: PHP version
description: What PHP version are you using?
placeholder: 'e.g. 8.3.23'
validations:
required: true
- type: input
id: extension-version
attributes:
label: Extension version
description: What version of EXT:t3api are you using?
placeholder: 'e.g. 3.0.1'
validations:
required: true
- type: checkboxes
id: composer-mode
attributes:
label: Composer mode
description: Are you running TYPO3 in composer mode?
options:
- label: I'm running TYPO3 in composer mode.
- type: input
id: operating-system
attributes:
label: Operating system
description: What operating system are you using?
placeholder: 'e.g. macOS 14.5'
validations:
required: true
- type: textarea
attributes:
label: Current behavior
description: A clear description of what the bug is.
- type: textarea
attributes:
label: Expected behavior
description: A clear description of what you expected to happen.
- type: textarea
attributes:
label: Steps to reproduce
description: If possible, describe steps to reproduce the behavior.
placeholder: |
1. [First Step]
2. [Second Step]
3. [and so on...]
- type: textarea
attributes:
label: Additional context
description: Add any other context about the problem here.
- type: checkboxes
id: terms
attributes:
label: Code of Conduct
description: >
By submitting this issue, you agree to follow our
[Code of Conduct](https://github.com/sourcebroker/t3api/blob/main/CODE_OF_CONDUCT.md).
options:
- label: I agree to follow this project's Code of Conduct.
required: true
- type: markdown
attributes:
value: >
:bulb: **Tip:** Have you already looked into our https://github.com/sourcebroker/t3api/discussions/categories/q-a?
Maybe your problem has already been discussed there.
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Community support
url: https://github.com/sourcebroker/t3api/discussions
about: Please ask and answer questions here.
44 changes: 44 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Feature request
description: Suggest an idea for this extension.
title: "[FEATURE]"
labels:
- enhancement
assignees:
- kszymukowicz
body:
- type: textarea
attributes:
label: Is your feature request related to a problem?
description: A clear description of what the problem is.
placeholder: I'm always frustrated when [...]
validations:
required: true
- type: textarea
attributes:
label: Describe the solution you'd like
description: A clear description of what you want to happen.
validations:
required: true
- type: textarea
attributes:
label: Describe alternatives you've considered
description: A clear description of any alternative solutions or features you've considered.
- type: textarea
attributes:
label: Additional context
description: Add any other context or screenshots about the feature request here.
- type: checkboxes
id: terms
attributes:
label: Code of Conduct
description: >
By submitting this issue, you agree to follow our
[Code of Conduct](https://github.com/sourcebroker/t3api/blob/main/CODE_OF_CONDUCT.md).
options:
- label: I agree to follow this project's Code of Conduct.
required: true
- type: markdown
attributes:
value: >
:bulb: **Tip:** Have you already looked into https://github.com/sourcebroker/t3api/discussions/categories/ideas?
Maybe your idea has already been discussed there.
3 changes: 0 additions & 3 deletions .scrutinizer.yml

This file was deleted.

5 changes: 5 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Code of Conduct

This project uses following code of conduct: https://typo3.org/community/values/code-of-conduct

By contributing to this project or engaging with community members, you agree to abide by this code of conduct.
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Contributing

Please have a look in the [development section][1] in documentation.

[1]: https://docs.typo3.org/p/sourcebroker/t3api/main/en-us/Miscellaneous/Development/Index.html
18 changes: 12 additions & 6 deletions Documentation/Miscellaneous/Development/CommandsList/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,22 @@ Example:
.. _development_commands_list_ddev_next:
:bash:`ddev next [major|minor|patch]`
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
This command will prepare t3api for next release.
This command will help to tag next release of extension.

For now, the following files are changed with info about next version:
It does several checks. Amongst other it:

* :file:`/ext_emconf.php`
* :file:`/Documentation/guides.xml`
1. Checks if you are on default branch.
2. Checks if you are are up to date with remote default branch.
3. Checks if you do not have any not pushed changes to remote.
4. Checks validity of last tag.
5. Increase version in few files:

Additionally it outputs a command you need to run to push changes and tag to git.
* :file:`/ext_emconf.php`
* :file:`/Documentation/guides.xml`

After all checks it outputs a command you need to run to push changes and tag to git.

Example output:

.. code-block:: bash
git add Documentation/guides.xml ext_emconf.php && git commit -m 'Tag new version' && git tag -a '2.0.4' -m '2.0.4' && git push origin master --tags
git add Documentation/guides.xml ext_emconf.php && git commit -m 'Tag version 3.1.0' && git tag -a '3.1.0' -m 'Version 3.1.0' -s && git push origin main --tags
Loading
Loading