-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from wandera/setup-repo
Bump dependencies, use GitHub Actions instead of Travis CI
- Loading branch information
Showing
44 changed files
with
452 additions
and
304 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "docker" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
reviewers: | ||
- "wandera/delta" | ||
|
||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
reviewers: | ||
- "wandera/delta" | ||
|
||
- package-ecosystem: "gomod" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
reviewers: | ||
- "wandera/delta" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Lint | ||
on: | ||
pull_request: | ||
jobs: | ||
golangci: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Install Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: go.mod | ||
- name: Lint | ||
uses: wandera/golangci-lint-action@v3 | ||
with: | ||
version: v1.51.2 | ||
args: --out-${NO_FUTURE}format colored-line-number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*.*.*" | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
BINARY_NAME: ${{ github.event.repository.name }} | ||
IMAGE_NAME: ${{ github.repository }} | ||
TAG: ${{ github.ref_name }} | ||
|
||
jobs: | ||
release-binary: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
goos: [linux, windows, darwin] | ||
goarch: [386, arm64, amd64] | ||
exclude: | ||
- goarch: "386" | ||
goos: darwin | ||
steps: | ||
- name: Checkout the latest code | ||
uses: actions/checkout@v3 | ||
- name: Install Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: go.mod | ||
- name: Build ${{ matrix.goos }}/${{ matrix.goarch }} | ||
env: | ||
GOOS: ${{ matrix.goos }} | ||
GOARCH: ${{ matrix.goarch }} | ||
shell: bash | ||
run: | | ||
if [ "$GOOS" = "windows" ]; then | ||
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o dist/${{ env.BINARY_NAME }}.exe -ldflags '-w -s -X 'github.com/wandera/${{ env.BINARY_NAME }}/cmd.Version=${{ env.TAG }} | ||
else | ||
CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o dist/${{ env.BINARY_NAME }} -ldflags '-w -s -X 'github.com/wandera/${{ env.BINARY_NAME }}/cmd.Version=${{ env.TAG }} | ||
fi | ||
tar -czvf ${{ env.BINARY_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz -C dist/ . | ||
- name: Release | ||
uses: wandera/action-gh-release@v1 | ||
with: | ||
files: ${{ env.BINARY_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz | ||
|
||
release-docker-image: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
tags: | | ||
type=semver,pattern={{raw}} | ||
type=semver,pattern=v{{major}}.{{minor}} | ||
type=semver,pattern=v{{major}} | ||
type=sha | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Docker build & push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
push: true | ||
context: . | ||
platforms: linux/amd64,linux/arm64 | ||
build-args: | | ||
VERSION=${{ github.ref_name }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
issue_comment: | ||
types: | ||
- created | ||
|
||
jobs: | ||
unit: | ||
if: (github.event.issue.pull_request != '' && contains(github.event.comment.body, '/test')) || github.event_name == 'pull_request' || github.event_name == 'push' | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Install Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: go.mod | ||
- name: Test | ||
run: go test -v ./... | ||
build: | ||
if: (github.event.issue.pull_request != '' && contains(github.event.comment.body, '/test')) || github.event_name == 'pull_request' || github.event_name == 'push' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Docker build | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
build-args: | | ||
VERSION=${{ github.ref_name }} | ||
vulncheck: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Scan for Vulnerabilities in Code | ||
uses: wandera/govulncheck-action@v0.0.10 | ||
with: | ||
go-version: 1.20.0 | ||
package: ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
run: | ||
timeout: 5m | ||
linters: | ||
disable-all: true | ||
enable: | ||
- gci | ||
- godot | ||
- gofumpt | ||
- gosimple | ||
- govet | ||
- gosec | ||
- ineffassign | ||
- staticcheck | ||
- typecheck | ||
- unparam | ||
- unused | ||
- whitespace | ||
|
||
linters-settings: | ||
gosec: | ||
global: | ||
audit: true | ||
excludes: | ||
- G104 | ||
- G304 | ||
- G401 | ||
- G501 | ||
|
||
issues: | ||
exclude-rules: | ||
# Exclude some linters from running on tests files. | ||
- path: _test\.go | ||
linters: | ||
- ineffassign | ||
- gosec | ||
|
||
- linters: | ||
- staticcheck | ||
text: "SA4006:" #SA4006: this value of `not_used` is never used (staticcheck) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,18 @@ | ||
# Builder image | ||
FROM golang:1.14.3 AS builder | ||
FROM golang:1.20.3-alpine3.17 AS builder | ||
|
||
WORKDIR /build | ||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
|
||
# Docker Cloud args, from hooks/build. | ||
ARG CACHE_TAG | ||
ENV CACHE_TAG ${CACHE_TAG} | ||
ARG VERSION | ||
|
||
COPY . . | ||
RUN CGO_ENABLED=0 GOOS=linux go build -v -ldflags '-w -s -X 'github.com/wandera/scccmd/cmd.Version=${CACHE_TAG} | ||
RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build GOMODCACHE=/go/pkg/mod GOCACHE=/root/.cache/go-build go build -v -ldflags '-w -s -X 'github.com/wandera/scccmd/cmd.Version=${VERSION} | ||
|
||
# Runtime image | ||
FROM alpine:3.12 | ||
FROM alpine:3.17.3 | ||
RUN apk --no-cache add ca-certificates | ||
|
||
COPY --from=builder /build/scccmd /app/scccmd | ||
WORKDIR /app | ||
|
||
ENTRYPOINT ["./scccmd"] | ||
ENTRYPOINT ["./scccmd"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.