Repository: containrrr/watchtower
Pull request #870 (2021-03-30 12:10:33)

chore(ci): run code coverage on main push
Currently the code coverage breaks when main:HEAD does not have code coverage generated (from being in a PR).
This allows smaller fixes to be merged into main without breaking code coverage.

codecov[bot]: # [Codecov](https://codecov.io/gh/containrrr/watchtower/pull/870?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`main@da56c21`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/containrrr/watchtower/pull/870/graphs/tree.svg?width=650&height=150&src=pr&token=8pxWgB380Y)](https://codecov.io/gh/containrrr/watchtower/pull/870?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##             main     #870   +/-   ##
=======================================
  Coverage        ?   43.07%           
=======================================
  Files           ?       24           
  Lines           ?     1379           
  Branches        ?        0           
=======================================
  Hits            ?      594           
  Misses          ?      724           
  Partials        ?       61           
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/containrrr/watchtower/pull/870?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/containrrr/watchtower/pull/870?src=pr&el=footer). Last update [da56c21...94c949f](https://codecov.io/gh/containrrr/watchtower/pull/870?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/.github/workflows/release-dev.yaml b/.github/workflows/release-dev.yaml
index 5005b2e..7928e45 100644
--- a/.github/workflows/release-dev.yaml
+++ b/.github/workflows/release-dev.yaml
@@ -1,23 +1,47 @@
-name: Release (Develop)
+name: Push to main
 
 on:
+  workflow_dispatch: {}
   push:
     branches:
       - main
 
 jobs:
-
   build:
-
     runs-on: ubuntu-latest
-
     steps:
-    - uses: actions/checkout@v2
-
-    - uses: jerray/publish-docker-action@master
-      with:
-        username: ${{ secrets.DOCKERHUB_USERNAME }}
-        password: ${{ secrets.DOCKERHUB_PASSWORD }}
-        file: dockerfiles/Dockerfile.self-contained
-        repository: containrrr/watchtower
-        tags: latest-dev
+      - uses: actions/checkout@v2
+      - name: Set up Go
+        uses: actions/setup-go@v2
+        with:
+          go-version: 1.15
+      - name: Build
+        run: go build -v ./...
+  test:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - name: Set up Go
+        uses: actions/setup-go@v2
+        with:
+          go-version: 1.15
+      - name: Test
+        run: go test -v -coverprofile coverage.out -covermode atomic ./... 
+      - name: Publish coverage
+        uses: codecov/codecov-action@v1
+        with:
+          token: ${{ secrets.CODECOV_TOKEN }}
+  publish:
+    needs:
+      - build
+      - test
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - uses: jerray/publish-docker-action@master
+        with:
+          username: ${{ secrets.DOCKERHUB_USERNAME }}
+          password: ${{ secrets.DOCKERHUB_PASSWORD }}
+          file: dockerfiles/Dockerfile.self-contained
+          repository: containrrr/watchtower
+          tags: latest-dev
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 3083abb..de72102 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -1,6 +1,7 @@
 name: Release (Production)
 
 on:
+  workflow_dispatch: {}
   release:
     types:
       - created
diff --git a/build.sh b/build.sh
index 363dc74..47d2b5c 100644
--- a/build.sh
+++ b/build.sh
@@ -1,5 +1,5 @@
 #!/bin/bash
 
-VERSION=$(git describe)
+VERSION=$(git describe --tags)
 echo "Building $VERSION..."
-go build -o watchtower -ldflags "-X github.com/containrrr/watchtower/cmd.version=$VERSION"
\ No newline at end of file
+go build -o watchtower -ldflags "-X github.com/containrrr/watchtower/cmd.version=$VERSION"
diff --git a/dockerfiles/Dockerfile.dev-self-contained b/dockerfiles/Dockerfile.dev-self-contained
index 307ffbe..b22ef13 100644
--- a/dockerfiles/Dockerfile.dev-self-contained
+++ b/dockerfiles/Dockerfile.dev-self-contained
@@ -4,8 +4,8 @@
 
 FROM golang:alpine as builder
 
-# use version (for example "v0.3.3") or "master"
-ARG WATCHTOWER_VERSION=master
+# use version (for example "v0.3.3") or "main"
+ARG WATCHTOWER_VERSION=main
 
 RUN apk add --no-cache \
     alpine-sdk \
@@ -18,7 +18,7 @@ COPY . /watchtower
 RUN \
   cd /watchtower && \
   \
-  GO111MODULE=on CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' . && \
+  GO111MODULE=on CGO_ENABLED=0 GOOS=linux go build -a -ldflags "-extldflags '-static' -X github.com/containrrr/watchtower/cmd.version=$(git describe --tags)" . && \
   GO111MODULE=on go test ./... -v
 
 
diff --git a/dockerfiles/Dockerfile.self-contained b/dockerfiles/Dockerfile.self-contained
index 64d5dc0..f24701f 100644
--- a/dockerfiles/Dockerfile.self-contained
+++ b/dockerfiles/Dockerfile.self-contained
@@ -4,8 +4,8 @@
 
 FROM golang:alpine as builder
 
-# use version (for example "v0.3.3") or "master"
-ARG WATCHTOWER_VERSION=master
+# use version (for example "v0.3.3") or "main"
+ARG WATCHTOWER_VERSION=main
 
 RUN apk add --no-cache \
     alpine-sdk \
@@ -18,7 +18,7 @@ RUN git clone --branch "${WATCHTOWER_VERSION}" https://github.com/containrrr/wat
 RUN \
   cd watchtower && \
   \
-  GO111MODULE=on CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' . && \
+  GO111MODULE=on CGO_ENABLED=0 GOOS=linux go build -a -ldflags "-extldflags '-static' -X github.com/containrrr/watchtower/cmd.version=$(git describe --tags)" . && \
   GO111MODULE=on go test ./... -v
 
 
diff --git a/mkdocs.yml b/mkdocs.yml
index b40f794..67529aa 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -1,7 +1,7 @@
 site_name: Watchtower
 site_url: http://containrrr.github.io/watchtower/
 repo_url: https://github.com/containrrr/watchtower/
-edit_uri: edit/main/docs/index.md
+edit_uri: edit/main/docs/
 theme:
   name: 'material'
   palette:
diff --git a/pkg/notifications/notifier.go b/pkg/notifications/notifier.go
index b9e322e..ec313a5 100644
--- a/pkg/notifications/notifier.go
+++ b/pkg/notifications/notifier.go
@@ -55,6 +55,12 @@ func (n *Notifier) String() string {
 			sb.WriteString(", ")
 		}
 	}
+
+	if sb.Len() < 2 {
+		// No notification services are configured, return early as the separator strip is not applicable
+		return "none"
+	}
+
 	names := sb.String()
 
 	// remove the last separator


Test patch:
diff --git a/pkg/notifications/notifier_test.go b/pkg/notifications/notifier_test.go
index 5ef75a0..ecd228f 100644
--- a/pkg/notifications/notifier_test.go
+++ b/pkg/notifications/notifier_test.go
@@ -23,6 +23,22 @@ func TestActions(t *testing.T) {
 }
 
 var _ = Describe("notifications", func() {
+	Describe("the notifier", func() {
+		When("only empty notifier types are provided", func() {
+
+			command := cmd.NewRootCommand()
+			flags.RegisterNotificationFlags(command)
+
+			err := command.ParseFlags([]string{
+				"--notifications",
+				"shoutrrr",
+			})
+			Expect(err).NotTo(HaveOccurred())
+			notif := notifications.NewNotifier(command)
+
+			Expect(notif.String()).To(Equal("none"))
+		})
+	})
 	Describe("the slack notifier", func() {
 		builderFn := notifications.NewSlackNotifier