Skip to content
This repository was archived by the owner on Jun 22, 2021. It is now read-only.

Commit f319142

Browse files
authored
Merge pull request #1 from docker/ci-setup
Initial CI setup
2 parents 713e755 + 55a68b7 commit f319142

File tree

10 files changed

+140
-1
lines changed

10 files changed

+140
-1
lines changed

.github/workflows/main.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: CI
2+
on: [push, pull_request]
3+
jobs:
4+
build:
5+
name: build
6+
runs-on: ubuntu-latest
7+
steps:
8+
9+
- name: Checkout
10+
uses: actions/checkout@v2
11+
12+
- name: Build
13+
run: make -f docker.Makefile

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bin/

Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
ARG GO_VERSION=1.13.7
2+
ARG GOLANGCI_LINT_VERSION=v1.23.6
3+
ARG ALPINE_VERSION=3.11.3
4+
5+
6+
7+
FROM golang:${GO_VERSION} AS builder
8+
9+
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION}
10+
11+
ARG MAKE_TARGET=all
12+
ENV CGO_ENABLED=0
13+
WORKDIR /src
14+
15+
COPY . .
16+
17+
RUN make ${MAKE_TARGET}
18+
19+
20+
21+
FROM scratch AS cli
22+
COPY --from=builder /src/bin/github-actions github-actions
23+
24+
25+
26+
FROM alpine:${ALPINE_VERSION}
27+
28+
COPY --from=builder /src/bin/github-actions /github-actions
29+
30+
ENTRYPOINT ["/github-actions"]

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
all: build lint test
2+
3+
build:
4+
@$(call mkdir,bin)
5+
go build -o bin/github-actions ./cmd
6+
7+
lint:
8+
golangci-lint run --config golangci.yml ./...
9+
10+
test:
11+
go test ./...

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
11
# github-actions
2-
Core code for all Docker's github actions
2+
The core code base for Docker's GitHub Actions (https://github.com/features/actions). This code is used to build the docker/github-actions image that provides the functionality used by the published Docker GitHub Actions
3+
4+
5+
## Building github-actions
6+
The code is written in Go v1.13 with `go mod`. It can be built locally using the `Makefile` or in docker using the `docker.Makefile`.
7+
8+
`make -f docker.Makefile` will build the code, check the linting using golangci-lint, run the go tests, and build the image with a tag of docker/github-actions:latest
9+
10+
`make -f docker.Makefile TAG=foo` will build the code, check the linting using golangci-lint, run the go tests, and build the image with a tag of docker/github-actions:foo
11+
12+
`make -f docker.Makefile image` will build the github-actions image without a tag and without running test or lint checking
13+
14+
`make -f docker.Makefile cli` will build the cli and copy it to `./bin/github-actions`
15+
16+
`make -f docker.Makefile test` will run the go tests

cmd/main.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
7+
commandLine "github.com/urfave/cli/v2"
8+
)
9+
10+
func main() {
11+
app := &commandLine.App{
12+
Name: "docker github actions",
13+
Usage: "Used in GitHub Actions to run Docker workflows",
14+
}
15+
16+
err := app.Run(os.Args)
17+
if err != nil {
18+
fmt.Println(err)
19+
os.Exit(1)
20+
}
21+
}

docker.Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
TAG ?= latest
2+
STATIC_FLAGS = BUILDKIT_PROGRESS=plain
3+
DOCKER_BUILD = $(STATIC_FLAGS) docker build
4+
5+
all:
6+
$(DOCKER_BUILD) -t docker/github-actions:$(TAG) .
7+
8+
image:
9+
$(DOCKER_BUILD) -t docker/github-actions:$(TAG) --build-arg MAKE_TARGET=build .
10+
11+
cli:
12+
@$(call mkdir,bin)
13+
$(DOCKER_BUILD) -t github-actions-cli --target=cli --output type=local,dest=./bin/ --build-arg MAKE_TARGET=build .
14+
15+
lint:
16+
$(DOCKER_BUILD) -t github-actions-lint --build-arg MAKE_TARGET=lint .
17+
18+
test:
19+
$(DOCKER_BUILD) -t github-actions-test --build-arg MAKE_TARGET=test .

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module github.com/docker/github-actions
2+
3+
go 1.13
4+
5+
require github.com/urfave/cli/v2 v2.1.1

go.sum

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
2+
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
3+
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
4+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
5+
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
6+
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
7+
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
8+
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
9+
github.com/urfave/cli/v2 v2.1.1 h1:Qt8FeAtxE/vfdrLmR3rxR6JRE0RoVmbXu8+6kZtYU4k=
10+
github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
11+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
12+
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

golangci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
run:
2+
deadline: 2m
3+
4+
linters:
5+
disable-all: true
6+
enable:
7+
- gofmt
8+
- goimports
9+
- golint
10+
- gosimple
11+
- ineffassign
12+
- misspell
13+
- govet

0 commit comments

Comments
 (0)