Skip to content

Commit

Permalink
github: ci
Browse files Browse the repository at this point in the history
Signed-off-by: Paweł Gronowski <[email protected]>
  • Loading branch information
vvoland committed Nov 29, 2024
1 parent ae4ccb3 commit ef69f42
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "Dockerfile",
"build": {
"context": "..",
"target": "devcontainer",
"dockerfile": "../Dockerfile"
},
"customizations": {
"vscode": {
"extensions": [
"golang.go",
"github.copilot",
"github.vscode-github-actions"
]
}
}
}
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: test

on:
pull_request:
push:
branches:
- 'master'
tags:
- 'v*'

jobs:
test:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Test
uses: docker/bake-action@v5
with:
targets: test
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM --platform=$BUILDPLATFORM golang:1.23-bullseye AS base

# devcontainer
FROM base AS gopls
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
GOBIN=/build/ GO111MODULE=on go install "golang.org/x/tools/gopls@latest" \
&& /build/gopls version

FROM base AS devcontainer
COPY --from=gopls /build/gopls /usr/local/bin/gopls

# deps
FROM base AS deps

WORKDIR /go/src

RUN --mount=type=bind,src=./go.mod,target=./go.mod \
--mount=type=bind,src=./go.sum,target=./go.sum \
go mod download

# test
FROM deps AS test

ARG TARGETOS
ARG TARGETARCH
RUN --mount=type=bind,target=/go/src \
--mount=type=cache,target=/root/.cache/go-build \
go test -v
9 changes: 9 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
group "default" {
targets = ["test"]
}

target "test" {
target = "test"
output = ["type=cacheonly"]
}

0 comments on commit ef69f42

Please sign in to comment.