From e7e9118856915bd5e1ed2ba8adb8fdd29c52ad54 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sat, 20 Aug 2022 18:55:43 +0200 Subject: [PATCH 1/3] Dockerfile: add test stage Signed-off-by: CrazyMax --- Dockerfile | 12 ++++++++++++ docker-bake.hcl | 16 ++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2f6d503c..d9342e45 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,6 +30,18 @@ FROM gobase AS base ARG TARGETPLATFORM RUN xx-apk add musl-dev gcc libsecret-dev pass +FROM base AS test +RUN --mount=type=bind,target=. \ + --mount=type=cache,target=/root/.cache \ + --mount=type=cache,target=/go/pkg/mod < Date: Sat, 20 Aug 2022 20:44:43 +0200 Subject: [PATCH 2/3] ci: add test jobs Signed-off-by: CrazyMax --- .github/workflows/build.yml | 66 ++++++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fd111c72..242f70b3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,10 +11,71 @@ on: env: DESTDIR: ./bin + GO_VERSION: 1.16.7 jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: + - ubuntu-20.04 + - macOS-11 + - windows-2022 + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: ${{ env.GO_VERSION }} + cache: true + - + name: Install deps + if: ${{ matrix.os == 'ubuntu-20.04' }} + run: | + sudo apt-get update + sudo apt-get install -y dbus-x11 gnome-keyring libsecret-1-dev pass + - + name: Test + run: | + go test -short -v -coverprofile=./coverage.txt -covermode=atomic ./... + go tool cover -func=./coverage.txt + shell: bash + - + name: Upload coverage + uses: codecov/codecov-action@v3 + with: + file: ./coverage.txt + + test-sandboxed: + runs-on: ubuntu-20.04 + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - + name: Test + uses: docker/bake-action@v2 + with: + targets: test + set: | + *.cache-from=type=gha,scope=test + *.cache-to=type=gha,scope=test,mode=max + - + name: Upload coverage + uses: codecov/codecov-action@v3 + with: + file: ${{ env.DESTDIR }}//coverage.txt + build: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Checkout @@ -30,6 +91,9 @@ jobs: uses: docker/bake-action@v2 with: targets: binaries + set: | + *.cache-from=type=gha,scope=build + *.cache-to=type=gha,scope=build,mode=max - name: Move artifacts run: | From 6f1a1a10c10b76d28fbff617ad4430aa01fe665d Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sat, 20 Aug 2022 20:40:43 +0200 Subject: [PATCH 3/3] update README with new build instructions and badges Signed-off-by: CrazyMax --- README.md | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c469c944..24d406d1 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +[![GitHub release](https://img.shields.io/github/release/docker/docker-credential-helpers.svg?style=flat-square)](https://github.com/docker/docker-credential-helpers/releases/latest) +[![PkgGoDev](https://img.shields.io/badge/go.dev-docs-007d9c?style=flat-square&logo=go&logoColor=white)](https://pkg.go.dev/github.com/docker/docker-credential-helpers) +[![Build Status](https://img.shields.io/github/workflow/status/docker/docker-credential-helpers/build?label=build&logo=github&style=flat-square)](https://github.com/docker/docker-credential-helpers/actions?query=workflow%3Abuild) +[![Codecov](https://img.shields.io/codecov/c/github/docker/docker-credential-helpers?logo=codecov&style=flat-square)](https://codecov.io/gh/docker/docker-credential-helpers) +[![Go Report Card](https://goreportcard.com/badge/github.com/docker/docker-credential-helpers?style=flat-square)](https://goreportcard.com/report/github.com/docker/docker-credential-helpers) + ## Introduction docker-credential-helpers is a suite of programs to use native stores to keep Docker credentials safe. @@ -6,9 +12,21 @@ docker-credential-helpers is a suite of programs to use native stores to keep Do Go to the [Releases](https://github.com/docker/docker-credential-helpers/releases) page and download the binary that works better for you. Put that binary in your `$PATH`, so Docker can find it. -### Building from scratch +## Building + +You can build the credential helpers using Docker: + +```shell +# create builder +$ docker buildx create --use +# build credential helpers from remote repository and output to ./bin/build +$ docker buildx bake "https://github.com/docker/docker-credential-helpers.git" +# or from local source +$ git clone https://github.com/docker/docker-credential-helpers.git +$ docker buildx bake +``` -The programs in this repository are written with the Go programming language. These instructions assume that you have previous knowledge about the language and you have it installed in your machine. +Or if the toolchain is already installed on your machine: 1 - Download the source and put it in your `$GOPATH` with `go get`.