Compare commits

..

17 Commits

Author SHA1 Message Date
Ian Fijolek
0b2078c6c5 uncomment test stuff 2021-01-08 18:09:27 -05:00
Ian Fijolek
0ed96f6c22 Remove prerelease 2021-01-08 18:06:56 -05:00
Ian Fijolek
8c12e80ad2 Try to stop building on pushes to non-master 2021-01-08 18:05:33 -05:00
Ian Fijolek
f6a9199f25 Change exec find 2021-01-08 18:01:58 -05:00
Ian Fijolek
3c2cae3011 Switch to ubuntu 2021-01-08 17:59:28 -05:00
Ian Fijolek
f9c082d30f More debugging 2021-01-08 17:56:30 -05:00
Ian Fijolek
5bb4da6178 More debugging 2021-01-08 17:53:19 -05:00
Ian Fijolek
d810bcb61c Try to fix compress step again 2021-01-08 17:44:52 -05:00
Ian Fijolek
e7353bb8df Try to fix compress step 2021-01-08 17:38:55 -05:00
Ian Fijolek
06ea8bea30 Add branch name to unstable release 2021-01-08 17:36:24 -05:00
Ian Fijolek
2e5ab23bd1 Add darwin releases 2021-01-08 17:33:27 -05:00
Ian Fijolek
aa741eb49e Make check step faster 2021-01-08 17:31:56 -05:00
Ian Fijolek
96c9b7d74c Add prereleases 2021-01-08 17:29:57 -05:00
Ian Fijolek
31336280e6 Add release uploads 2021-01-08 17:21:02 -05:00
Ian Fijolek
a1b906b94a Update for go 1.15 2020-11-16 15:56:31 -08:00
Ian Fijolek
0a5be250b5 Scripts: Add echoing log lines to helper scripts
Rather than only returning the status of whether or not a container is
healhthy, the helper scripts will now optionally echo some of the latest
log lines.
2020-11-16 15:52:21 -08:00
Ian Fijolek
88f77aa27c Fix Makefile comment 2020-11-16 15:51:41 -08:00
5 changed files with 73 additions and 31 deletions
+43 -25
View File
@@ -3,33 +3,15 @@ kind: pipeline
name: test
steps:
- name: test
image: golang:1.12
environment:
VERSION: ${DRONE_TAG:-${DRONE_COMMIT}}
commands:
- make build
- make test
- name: check
image: python:3
commands:
- pip install pre-commit==1.20.0
- make check
- name: notify
image: drillster/drone-email
settings:
host:
from_secret: SMTP_HOST
username:
from_secret: SMTP_USER
password:
from_secret: SMTP_PASS
from: drone@iamthefij.com
when:
status: [changed, failure]
image: iamthefij/drone-pre-commit:personal
---
kind: pipeline
@@ -52,7 +34,31 @@ steps:
environment:
VERSION: ${DRONE_TAG:-${DRONE_COMMIT}}
commands:
- make all-linux
- make all
- name: compress binaries for release
image: ubuntu
commands:
- find ./dist -type f -executable -execdir tar -czvf {}.tar.gz {} \;
when:
event: tag
- name: upload gitea release
image: plugins/gitea-release
settings:
title: ${DRONE_TAG}
files: dist/*.tar.gz
checksum:
- md5
- sha1
- sha256
- sha512
base_url:
from_secret: gitea_base_url
api_key:
from_secret: gitea_token
when:
event: tag
- name: push image - arm
image: plugins/docker
@@ -104,15 +110,27 @@ steps:
password:
from_secret: docker_password
---
kind: pipeline
name: notify
depends_on:
- test
- publish
trigger:
status:
- failure
steps:
- name: notify
image: drillster/drone-email
settings:
host:
from_secret: SMTP_HOST
from_secret: SMTP_HOST # pragma: whitelist secret
username:
from_secret: SMTP_USER
from_secret: SMTP_USER # pragma: whitelist secret
password:
from_secret: SMTP_PASS
from_secret: SMTP_PASS # pragma: whitelist secret
from: drone@iamthefij.com
when:
status: [changed, failure]
+1 -1
View File
@@ -46,7 +46,7 @@ test:
install-hooks:
pre-commit install --install-hooks
# Checks files for encryption
# Runs pre-commit checks on files
.PHONY: check
check:
pre-commit run --all-files
+1 -1
View File
@@ -55,7 +55,7 @@ func (alert *Alert) BuildTemplates() error {
cmdPart = legacy.Replace(cmdPart)
}
alert.commandTemplate = append(alert.commandTemplate, template.Must(
template.New(alert.Name+string(i)).Parse(cmdPart),
template.New(alert.Name+fmt.Sprint(i)).Parse(cmdPart),
))
}
} else if alert.commandShellTemplate == nil && alert.Command.ShellCommand != "" {
+15 -3
View File
@@ -11,6 +11,7 @@ set -e
# To override, export DOCKER_HOST to a new hostname
DOCKER_HOST="${DOCKER_HOST:=socket}"
container_name="$1"
num_log_lines="$2"
# Curls Docker either using a socket or URL
function curl_docker {
@@ -31,21 +32,32 @@ function get_container_id {
# Returns container JSON
function inspect_container {
local container_id=$1
local container_id="$1"
curl_docker "containers/$container_id/json"
}
# Gets some lines from docker log
function get_logs {
container_id="$1"
num_lines="$2"
curl_docker "containers/$container_id/logs?stdout=1&stderr=1" | tail -n "$num_lines"
}
if [ -z "$container_name" ]; then
echo "Usage: $0 container_name"
echo "Usage: $0 container_name [num_log_lines]"
echo "Will exit with the last status code of continer with provided name"
exit 1
fi
container_id=$(get_container_id $container_name)
container_id=$(get_container_id "$container_name")
if [ -z "$container_id" ]; then
echo "ERROR: Could not find container with name: $container_name"
exit 1
fi
exit_code=$(inspect_container "$container_id" | jq -r .State.ExitCode)
if [ -n "$num_log_lines" ]; then
get_logs "$container_id" "$num_log_lines"
fi
exit "$exit_code"
+13 -1
View File
@@ -11,6 +11,7 @@ set -e
# To override, export DOCKER_HOST to a new hostname
DOCKER_HOST="${DOCKER_HOST:=socket}"
container_name="$1"
num_log_lines="$2"
# Curls Docker either using a socket or URL
function curl_docker {
@@ -35,8 +36,15 @@ function inspect_container {
curl_docker "containers/$container_id/json"
}
# Gets some lines from docker log
function get_logs {
container_id="$1"
num_lines="$2"
curl_docker "containers/$container_id/logs?stdout=1&stderr=1" | tail -n "$num_lines"
}
if [ -z "$container_name" ]; then
echo "Usage: $0 container_name"
echo "Usage: $0 container_name [num_log_lines]"
echo "Will return results of healthcheck for continer with provided name"
exit 1
fi
@@ -48,6 +56,10 @@ if [ -z "$container_id" ]; then
fi
health=$(inspect_container "$container_id" | jq -r '.State.Health.Status')
if [ -n "$num_log_lines" ]; then
get_logs "$container_id" "$num_log_lines"
fi
case "$health" in
null)
echo "No healthcheck results"