add tests
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
ci/woodpecker/pr/test-image Pipeline was successful

This commit is contained in:
OCram85 2024-05-17 08:49:26 +02:00
parent 0426f300c6
commit 803a79e380
2 changed files with 38 additions and 14 deletions

View File

@ -17,7 +17,6 @@ steps:
from_secret: gitea_user
password:
from_secret: gitea_passwd
debug: "true"
owner: "plugins"
package_name: "dummy_package"
package_version: "0.1.0"
@ -27,7 +26,8 @@ steps:
when:
event: pull_request
branch: ${CI_REPO_DEFAULT_BRANCH}
next-nodebug:
next-debug:
image: gitea.ocram85.com/plugins/gitea-package:next
pull: true
secrets: [ gitea_user, gitea_passwd]
@ -42,6 +42,27 @@ steps:
file_source: "./README.md"
file_name: "readme.md"
update: "true"
debug: "true"
when:
event: pull_request
branch: ${CI_REPO_DEFAULT_BRANCH}
next-no-update:
image: gitea.ocram85.com/plugins/gitea-package:next
pull: true
failure: ignore
secrets: [ gitea_user, gitea_passwd]
settings:
user:
from_secret: gitea_user
password:
from_secret: gitea_passwd
owner: "plugins"
package_name: "dummy_package"
package_version: "0.1.0"
file_source: "./README.md"
file_name: "readme.md"
debug: "true"
when:
event: pull_request
branch: ${CI_REPO_DEFAULT_BRANCH}

View File

@ -26,13 +26,16 @@ sayW() {
fi
}
showHelp() {
cat << HELP
🤖 gitea-package Woodpecker-CI Plugin
Syntax:
HELP
}
# TODO: Disabled for now. No default help output needed if just running as
# Woodpecker CI plugin.
#
#showHelp() {
# cat << HELP
# 🤖 gitea-package Woodpecker-CI Plugin
#
# Syntax:
#HELP
#}
showENV() {
env | sort
@ -75,23 +78,23 @@ deleteArtifact() {
}
uploadArtifact() {
say "Testing if the artifact already exists in give package version..." "uploadArtifact"
say "Testing if the given artifact already exists in the package registry..." "uploadArtifact"
fexist=$(testArtifact)
if [ "$fexist" = "true" ]; then
if [ -n "$PLUGIN_UPDATE" ]; then
sayW "Given file already exists. Updating package file..." "uploadArtifact"
sayW "🚧 Given file already exists. Removing remote file..." "uploadArtifact"
deleteArtifact
else
sayW "A file with the same name exist already in the package." "uploadArtifact"
sayW "🛑 File already exists in the package registry." "uploadArtifact"
exit 1
fi
fi
say "Starting file upload..." "uploadArtifact"
say "Starting file upload... ($PLUGIN_FILE_SOURCE)" "uploadArtifact"
cout=$(curl --silent --output /dev/null --write-out "%{http_code}" \
--user "$PLUGIN_USER:$PLUGIN_PASSWORD" \
--upload-file "$PLUGIN_FILE_SOURCE" \
"$CI_FORGE_URL/api/packages/$PLUGIN_OWNER/generic/$PLUGIN_PACKAGE_NAME/$PLUGIN_PACKAGE_VERSION/$PLUGIN_FILE_NAME")
say "Curl output is: $cout" "uploadArtifact"
say "Curl http response code: $cout" "uploadArtifact"
if [ "$cout" = "201" ]; then
say "Upload sucessfully finished." "uploadArtifact"