Skip to content

Commit

Permalink
Update go in tests and Dockerfile
Browse files Browse the repository at this point in the history
Some other dockerfile changes for cross compilation support and making
it easier to swap out the build image/go-version.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
  • Loading branch information
cpuguy83 committed Apr 22, 2022
1 parent d33c36c commit 4a927df
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
27 changes: 13 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,32 @@ name: Go

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

jobs:

test:
name: Build
strategy:
matrix:
go-version: [1.13.x, 1.15.x, 1.16.x]
go-version: [1.13.x, 1.15.x, 1.16.x, 1.17.x, 1.18.x]
platform: [ubuntu-20.04]
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}

- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: Build
run: go build -v ./...
- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...
- name: Test
run: go test -v ./...

lint:
runs-on: ubuntu-20.04
Expand Down
16 changes: 14 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
FROM golang:1.8 AS build
ARG GO_VERSION=1.18
ARG GO_IMAGE=golang:${GO_VERSION}

FROM --platform=$BUILDPLATFORM $GO_IMAGE AS build
COPY . /go/src/github.com/cpuguy83/go-md2man
WORKDIR /go/src/github.com/cpuguy83/go-md2man
RUN CGO_ENABLED=0 go build
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
RUN \
export GOOS="${TARGETOS}"; \
export GOARCH="${TARGETARCH}"; \
if [ "${TARGETARCH}" = "arm" ] && [ "${TARGETVARIANT}" ]; then \
export GOARM="${TARGETVARIANT#v}"; \
fi; \
CGO_ENABLED=0 go build

FROM scratch
COPY --from=build /go/src/github.com/cpuguy83/go-md2man/go-md2man /go-md2man
Expand Down

0 comments on commit 4a927df

Please sign in to comment.