File tree Expand file tree Collapse file tree 4 files changed +111
-5
lines changed
Expand file tree Collapse file tree 4 files changed +111
-5
lines changed Original file line number Diff line number Diff line change 1111
1212env :
1313 DESTDIR : ./bin
14+ GO_VERSION : 1.16.7
1415
1516jobs :
17+ test :
18+ runs-on : ${{ matrix.os }}
19+ strategy :
20+ fail-fast : false
21+ matrix :
22+ os :
23+ - ubuntu-20.04
24+ - macOS-11
25+ - windows-2022
26+ steps :
27+ -
28+ name : Checkout
29+ uses : actions/checkout@v3
30+ -
31+ name : Set up Go
32+ uses : actions/setup-go@v3
33+ with :
34+ go-version : ${{ env.GO_VERSION }}
35+ cache : true
36+ -
37+ name : Install deps
38+ if : ${{ matrix.os == 'ubuntu-20.04' }}
39+ run : |
40+ sudo apt-get update
41+ sudo apt-get install -y dbus-x11 gnome-keyring libsecret-1-dev pass
42+ -
43+ name : Test
44+ run : |
45+ go test -short -v -coverprofile=./coverage.txt -covermode=atomic ./...
46+ go tool cover -func=./coverage.txt
47+ shell : bash
48+ -
49+ name : Upload coverage
50+ uses : codecov/codecov-action@v3
51+ with :
52+ file : ./coverage.txt
53+
54+ test-sandboxed :
55+ runs-on : ubuntu-20.04
56+ steps :
57+ -
58+ name : Checkout
59+ uses : actions/checkout@v3
60+ -
61+ name : Set up Docker Buildx
62+ uses : docker/setup-buildx-action@v2
63+ -
64+ name : Test
65+ uses : docker/bake-action@v2
66+ with :
67+ targets : test
68+ set : |
69+ *.cache-from=type=gha,scope=test
70+ *.cache-to=type=gha,scope=test,mode=max
71+ -
72+ name : Upload coverage
73+ uses : codecov/codecov-action@v3
74+ with :
75+ file : ${{ env.DESTDIR }}//coverage.txt
76+
1677 build :
17- runs-on : ubuntu-latest
78+ runs-on : ubuntu-20.04
1879 steps :
1980 -
2081 name : Checkout
3091 uses : docker/bake-action@v2
3192 with :
3293 targets : binaries
94+ set : |
95+ *.cache-from=type=gha,scope=build
96+ *.cache-to=type=gha,scope=build,mode=max
3397 -
3498 name : Move artifacts
3599 run : |
Original file line number Diff line number Diff line change @@ -30,6 +30,18 @@ FROM gobase AS base
3030ARG TARGETPLATFORM
3131RUN xx-apk add musl-dev gcc libsecret-dev pass
3232
33+ FROM base AS test
34+ RUN --mount=type=bind,target=. \
35+ --mount=type=cache,target=/root/.cache \
36+ --mount=type=cache,target=/go/pkg/mod <<EOT
37+ set -e
38+ xx-go test -short -v -coverprofile=/tmp/coverage.txt -covermode=atomic ./...
39+ xx-go tool cover -func=/tmp/coverage.txt
40+ EOT
41+
42+ FROM scratch AS test-coverage
43+ COPY --from=test /tmp/coverage.txt /coverage.txt
44+
3345FROM base AS build-linux
3446ARG TARGETOS
3547ARG TARGETARCH
Original file line number Diff line number Diff line change 1+ [ ![ 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 )
2+ [ ![ 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 )
3+ [ ![ 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 )
4+ [ ![ 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 )
5+ [ ![ 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 )
6+
17## Introduction
28
39docker-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
612
713Go 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.
814
9- ### Building from scratch
15+ ## Building
16+
17+ You can build the credential helpers using Docker:
18+
19+ ``` shell
20+ # create builder
21+ $ docker buildx create --use
22+ # build credential helpers from remote repository and output to ./bin/build
23+ $ docker buildx bake " https://github.com/docker/docker-credential-helpers.git"
24+ # or from local source
25+ $ git clone https://github.com/docker/docker-credential-helpers.git
26+ $ docker buildx bake
27+ ```
1028
11- 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.
29+ Or if the toolchain is already installed on your machine:
1230
13311 - Download the source and put it in your ` $GOPATH ` with ` go get ` .
1432
Original file line number Diff line number Diff line change 11variable "GO_VERSION" {
22 default = " 1.16.7"
33}
4+
5+ # Defines the output folder
46variable "DESTDIR" {
5- default = " ./bin"
7+ default = " "
8+ }
9+ function "bindir" {
10+ params = [defaultdir ]
11+ result = DESTDIR != " " ? DESTDIR : " ./bin/${ defaultdir } "
612}
713
814target "_common" {
@@ -15,10 +21,16 @@ group "default" {
1521 targets = [" binaries" ]
1622}
1723
24+ target "test" {
25+ inherits = [" _common" ]
26+ target = " test-coverage"
27+ output = [bindir (" coverage" )]
28+ }
29+
1830target "binaries" {
1931 inherits = [" _common" ]
2032 target = " binaries"
21- output = [DESTDIR ]
33+ output = [bindir ( " build " ) ]
2234 platforms = [
2335 " darwin/amd64" ,
2436 " darwin/arm64" ,
You can’t perform that action at this time.
0 commit comments