Skip to content

Commit

Permalink
✨ finished release command
Browse files Browse the repository at this point in the history
  • Loading branch information
jcaillon committed Mar 30, 2024
1 parent b7bb779 commit bc2a705
Show file tree
Hide file tree
Showing 16 changed files with 494 additions and 118 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ folder.ico
### PROJECT ###
**.received.md
bin/
valet.tar.gz
sandbox.sh
.tmp/
sandbox.sh
*.tag.gz
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ Please check the [CONTRIBUTING.md](CONTRIBUTING.md) documentation if you intend
- Add about option to hide the command in the menus.
- Add tests for self build.
- Implement self release command to tag and push to github.
- We can have fuzzy matching on options too; just make sure it is not ambiguous.

[fzf]: https://github.com/junegunn/fzf
[yq]: https://github.com/mikefarah/yq
Expand Down
10 changes: 10 additions & 0 deletions examples.d/commands
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ In addition to the environment variables defined for each options, you can defin
- VALET_LOG_COLUMNS=\"120\": the number of columns at which to wrap the logs (if wrap is enabled); defaults to the terminal width.
- VALET_CI_MODE=\"true\": will simplify the log output for CI/CD environments (or slow systems), will display the logs without colors, without wrapping lines and with the full date.
- VALET_REMEMBER_LAST_CHOICES=\"3\": number of last choices to remember when selecting an item from a menu. Set to 0 to disable this feature and always display items in the alphabetical order.
- VALET_DO_NOT_USE_LOCAL_BIN=\"false\": if true, valet will use the executable from the PATH even if they exist in the valet bin/ directory.
⌜Developer notes:⌝
Expand Down Expand Up @@ -261,6 +262,7 @@ This option can be set by exporting the variable VALET_USER_DIRECTORY=\"<path>\"
)
CMD_OPTIONS_NAME_selfDownloadBinaries=(
"-os, --force-os <name>"
"--destination <path>"
"-h, --help"
)
CMD_OPTIONS_DESCRIPTION_selfDownloadBinaries=(
Expand All @@ -270,6 +272,10 @@ You can force the download for a specific OS by providing the name of the OS.
Possible values are: linux, windows, macos.
This option can be set by exporting the variable VALET_FORCE_OS=\"<name>\"."
"By default, this command will download the binaries in valet bin/ directory.
You can force the download in a specific directory by providing the path.
This option can be set by exporting the variable VALET_DESTINATION=\"<path>\"."
"Display the help for this command"
)
CMD_OPTIONS_NAME_selfMenu=(
Expand Down Expand Up @@ -556,17 +562,21 @@ CMD_OPTS_NAME_SC_selfBuild=(
)
CMD_OPTS_selfDownloadBinaries=(
"-os --force-os"
"--destination"
"-h --help"
)
CMD_OPTS_HAS_VALUE_selfDownloadBinaries=(
"true"
"true"
)
CMD_OPTS_NAME_selfDownloadBinaries=(
"forceOs"
"destination"
"help"
)
CMD_OPTS_NAME_SC_selfDownloadBinaries=(
"FORCE_OS"
"DESTINATION"
)
CMD_OPTS_selfMenu=("-h --help")
CMD_OPTS_NAME_selfMenu=("help")
Expand Down
1 change: 1 addition & 0 deletions tests.d/0000-valet-cli/05.logging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ function resetLogOptions() {
unset VALET_CI_MODE
unset VALET_LOG_COLUMNS
unset _COLUMNS
export VALET_LOG_COLUMNS=120
}

function main() {
Expand Down
31 changes: 22 additions & 9 deletions tests.d/0000-valet-cli/results.approved.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ ABOUT
date.
- VALET_REMEMBER_LAST_CHOICES="3": number of last choices to remember when selecting an item from a menu. Set to 0 to disable this feature and always display items in the
alphabetical order.
- VALET_DO_NOT_USE_LOCAL_BIN="false": if true, valet will use the executable from the PATH even if they exist in the valet bin/ directory.
⌜Developer notes:⌝
Expand Down Expand Up @@ -434,7 +435,7 @@ cm2 This is command 2
sub cmd1 This is sub command 1
sub cmd2 This is sub command 2
another3 This is another command 3"
another3
```

**Error** output:
Expand Down Expand Up @@ -569,8 +570,11 @@ Exit code: 0
**Error** output:

```log
HH:MM:SS INFO   This is an info message with a super long sentence. The value of life is not in its duration, but in its donation. You are not important because of how long you live, you are important because of how effective you live. Give a man a fish and you
feed him for a day; teach a man to fish and you feed him for a lifetime. Surround yourself with the best people you can find, delegate authority, and don't interfere as long as the policy you've decided upon is being carried out.
HH:MM:SS INFO   This is an info message with a super long sentence. The value of life is not in its duration, but in
its donation. You are not important because of how long you live, you are important because of how
effective you live. Give a man a fish and you feed him for a day; teach a man to fish and you feed
him for a lifetime. Surround yourself with the best people you can find, delegate authority, and
don't interfere as long as the policy you've decided upon is being carried out.
HH:MM:SS SUCCESS   This is a success message.
HH:MM:SS WARNING   This is a warning message.
With a second line.
Expand All @@ -589,8 +593,11 @@ Exit code: 0
**Error** output:

```log
HH:MM:SS INFO  This is an info message with a super long sentence. The value of life is not in its duration, but in its donation. You are not important because of how long you live, you are important because of how effective you live. Give a man a fish and you
feed him for a day; teach a man to fish and you feed him for a lifetime. Surround yourself with the best people you can find, delegate authority, and don't interfere as long as the policy you've decided upon is being carried out.
HH:MM:SS INFO  This is an info message with a super long sentence. The value of life is not in its duration, but in
its donation. You are not important because of how long you live, you are important because of how
effective you live. Give a man a fish and you feed him for a day; teach a man to fish and you feed
him for a lifetime. Surround yourself with the best people you can find, delegate authority, and
don't interfere as long as the policy you've decided upon is being carried out.
HH:MM:SS SUCCESS  This is a success message.
HH:MM:SS WARNING  This is a warning message.
With a second line.
Expand Down Expand Up @@ -628,8 +635,11 @@ Exit code: 0
**Error** output:

```log
INFO  This is an info message with a super long sentence. The value of life is not in its duration, but in its donation. You are not important because of how long you live, you are important because of how effective you live. Give a man a fish and you feed him
for a day; teach a man to fish and you feed him for a lifetime. Surround yourself with the best people you can find, delegate authority, and don't interfere as long as the policy you've decided upon is being carried out.
INFO  This is an info message with a super long sentence. The value of life is not in its duration, but in its
donation. You are not important because of how long you live, you are important because of how effective you
live. Give a man a fish and you feed him for a day; teach a man to fish and you feed him for a lifetime.
Surround yourself with the best people you can find, delegate authority, and don't interfere as long as the
policy you've decided upon is being carried out.
SUCCESS  This is a success message.
WARNING  This is a warning message.
With a second line.
Expand All @@ -648,8 +658,11 @@ Exit code: 0
**Error** output:

```log
HH:MM:SS INFO This is an info message with a super long sentence. The value of life is not in its duration, but in its donation. You are not important because of how long you live, you are important because of how effective you live. Give a man a fish and you
feed him for a day; teach a man to fish and you feed him for a lifetime. Surround yourself with the best people you can find, delegate authority, and don't interfere as long as the policy you've decided upon is being carried out.
HH:MM:SS INFO This is an info message with a super long sentence. The value of life is not in its duration, but in
its donation. You are not important because of how long you live, you are important because of how
effective you live. Give a man a fish and you feed him for a day; teach a man to fish and you feed him
for a lifetime. Surround yourself with the best people you can find, delegate authority, and don't
interfere as long as the policy you've decided upon is being carried out.
HH:MM:SS SUCCESS This is a success message.
HH:MM:SS WARNING This is a warning message.
With a second line.
Expand Down
2 changes: 1 addition & 1 deletion tests.d/0001-core-functions/01.invoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function testInvoke() {

echo "→ invoke fakeexec2 --option argument1 argument2"
invoke fakeexec2 --option argument1 argument2 && exitCode=0 || exitCode=$?
echoInvokeOutput $exitCode true
echoInvokeOutput $exitCode false
endTest "Testing invoke, output to var" 0
}

Expand Down
10 changes: 6 additions & 4 deletions tests.d/0001-core-functions/results.approved.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,14 @@ Exit code: 0
```plaintext
→ invoke fakeexec2 --option argument1 argument2
Invoke function ended with exit code ⌈0⌉.
stdout from file:
stdout from var:
⌈▶ called fakeexec2 --option argument1 argument2
▶ fakeexec2 input stream was:
⌈⌉⌉
stderr from file:
⌈This is an error output from fakeexec2⌉
⌈⌉
stderr from var:
⌈This is an error output from fakeexec2
```

Expand Down
63 changes: 50 additions & 13 deletions tests.d/0003-self/01.self-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,70 @@ function testSelfRelease() {
echo "→ selfRelease -t token -b major --dry-run"
selfRelease -t token -b major --dry-run && exitCode=0 || exitCode=$?
endTest "Testing selfRelease, dry run major version" $exitCode

echo "→ LOG_LEVEL_INT=0 selfRelease -t token -b minor"
LOG_LEVEL_INT=0 selfRelease -t token -b minor && exitCode=0 || exitCode=$?
endTest "Testing selfRelease, minor version" $exitCode
}

# need to override git, curl
function git() {
echo "▶ called git $*" 1>&2
while [[ $# -gt 0 ]]; do
case "${1}" in
tag) echo "${LAST_GIT_TAG}."; return 0;;
log) echo "✨ feature"$'\n'"🐞 fix"; return 0;;
*) ;;
esac
shift
done
function invoke5() {
echo "▶ called invoke5 $*" 1>&2
if [[ "${5}" == "uname" ]]; then
echo -n "x86_64" > "${_TEMPORARY_STDOUT_FILE}"
LAST_RETURNED_VALUE="${_TEMPORARY_STDOUT_FILE}"
LAST_RETURNED_VALUE2=""
return 0
fi
LAST_RETURNED_VALUE=""
LAST_RETURNED_VALUE2=""
}

function invoke() {
echo "▶ called invoke $*" 1>&2
if [[ "${1}" == "git" ]]; then
while [[ $# -gt 0 ]]; do
case "${1}" in
tag) LAST_RETURNED_VALUE="${LAST_GIT_TAG}"; return 0;;
log) LAST_RETURNED_VALUE="✨ feature"$'\n'"🐞 fix"; return 0;;
*) ;;
esac
shift
done
fi
LAST_RETURNED_VALUE=""
LAST_RETURNED_VALUE2=""
}
function curl() {
echo "▶ called curl $*" 1>&2

function kurl() {
echo "▶ called kurl $*" 1>&2
echo -n 200
if [[ "$*" == *"tag_name"* ]]; then
# post on the release endpoint
echo '{ "upload_url": "https://uploads.github.com/repos/jcaillon/valet/releases/xxxx/assets{?name,label}" }'
LAST_RETURNED_VALUE='{ "upload_url": "https://uploads.github.com/repos/jcaillon/valet/releases/xxxx/assets{?name,label}" }'
return 0
fi
LAST_RETURNED_VALUE=""
}


function kurlFile() {
echo "▶ called kurlFile $*" 1>&2
echo -n 200
LAST_RETURNED_VALUE=""
}

function main() {
# make sure to source the file in which these known functions are defined
sourceForFunction "selfRelease" 2> /dev/null

createTempFile && local tmpFile="${LAST_RETURNED_VALUE}"
cp -f "${VALET_HOME}/valet.d/version" "${tmpFile}"
echo -n "1.2.3" > "${VALET_HOME}/valet.d/version"

testSelfRelease

mv -f "${tmpFile}" "${VALET_HOME}/valet.d/version"
}

main
Loading

0 comments on commit bc2a705

Please sign in to comment.