Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
version: 2
updates:
# Enable version updates for Go modules
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
time: "06:00"
open-pull-requests-limit: 10
reviewers:
- "drzombey"
assignees:
- "drzombey"
commit-message:
prefix: "deps"
prefix-development: "deps-dev"
labels:
- "dependencies"
- "go"

# Enable version updates for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
time: "06:00"
open-pull-requests-limit: 5
reviewers:
- "drzombey"
assignees:
- "drzombey"
commit-message:
prefix: "ci"
labels:
- "dependencies"
- "github-actions"

# Enable version updates for Docker
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
time: "06:00"
open-pull-requests-limit: 5
reviewers:
- "drzombey"
assignees:
- "drzombey"
commit-message:
prefix: "docker"
labels:
- "dependencies"
- "docker"
34 changes: 25 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,47 @@ on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ '1.21' ]
go-version: [ '1.24' ]

steps:
- uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Install dependencies
run: go mod tidy

- name: Verify dependencies
run: go mod verify

- name: Vet
run: go vet ./...

- name: Lint with golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
args: --timeout=5m

- name: Build
run: go build cmd/api/main.go
run: go build ./...

- name: Build API binary
run: go build -o aur-package-builder-api cmd/api/main.go

- name: Docker Setup Buildx
uses: docker/setup-buildx-action@v2.1.0
uses: docker/setup-buildx-action@v3

- name: Build and push
uses: docker/build-push-action@v3
- name: Build Docker image
uses: docker/build-push-action@v6
with:
context: .
push: false
platforms: linux/386, linux/amd64, linux/arm64
platforms: linux/amd64, linux/arm64
49 changes: 33 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

strategy:
fail-fast: false
max-parallel: 1
max-parallel: 2
matrix:
# build and publish in parallel: linux/386, linux/amd64, linux/arm64, windows/386, windows/amd64, darwin/amd64, darwin/arm64
goos: [ linux, windows, darwin ]
Expand All @@ -28,17 +28,25 @@ jobs:
steps:
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%dT%H:%M:%S%z')"
- uses: actions/checkout@v2
- uses: wangyoucao577/go-release-action@v1.22
run: echo "date=$(date +'%Y-%m-%dT%H:%M:%S%z')" >> $GITHUB_OUTPUT

- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'

- uses: wangyoucao577/go-release-action@v1.51
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
pre_command: export CGO_ENABLED=0
project_path: "./cmd/api"
extra_files: LICENSE
ldflags: "-X 'main.BuildTime=${{ steps.date.outputs.date }}' -X 'main.BuildVersion=${{ github.ref_name }}'"
extra_files: LICENSE README.md
ldflags: "-s -w -X 'main.BuildTime=${{ steps.date.outputs.date }}' -X 'main.BuildVersion=${{ github.ref_name }}'"
binary_name: "aur-package-builder-api"
overwrite: true
retry: 8
Expand All @@ -47,32 +55,41 @@ jobs:
name: Release Docker image for api
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/checkout@v2

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}

- name: Build and push
uses: docker/build-push-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/386, linux/amd64, linux/arm64
platforms: linux/amd64, linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
41 changes: 32 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,39 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ '1.21' ]
go-version: [ '1.24' ]

services:
mongodb:
image: mongo:latest
ports:
- 27017:27017
options: >-
--health-cmd "mongosh --eval 'db.runCommand({ ping: 1 })'"
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Install dependencies
run: go mod tidy

- name: Run tests
run: go test -v ./...

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Run tests with coverage
run: go test -v -coverprofile=coverage.out -covermode=atomic ./...

- name: Run tests
run: go test -v ./...
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./coverage.out
fail_ci_if_error: false
87 changes: 87 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
run:
timeout: 5m
tests: true

linters-settings:
errcheck:
check-type-assertions: true

goconst:
min-len: 3
min-occurrences: 2

gocyclo:
min-complexity: 10

gofmt:
simplify: true

goimports:
local-prefixes: github.com/drzombey/aur-package-builder-api

govet:
check-shadowing: true

lll:
line-length: 120

misspell:
locale: US

linters:
disable-all: true
enable:
# Default linters
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- unused

# Additional linters
- asciicheck
- bodyclose
- dupl
- goconst
- gocyclo
- gofmt
- goimports
- gosec
- lll
- misspell
- prealloc
- revive
- stylecheck
- unconvert
- unparam
- whitespace

issues:
max-issues-per-linter: 0
max-same-issues: 0

exclude-rules:
# Exclude some linters from running on tests files
- path: _test\.go
linters:
- gocyclo
- errcheck
- dupl
- gosec
- lll
- goconst

# Allow init functions in main
- path: cmd/api/main.go
linters:
- gochecknoinits

# Allow globals in config
- path: cmd/api/config/
linters:
- gochecknoglobals

exclude-use-default: false
exclude-case-sensitive: false
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=$BUILDPLATFORM golang:alpine as BUILDER
FROM --platform=$BUILDPLATFORM golang:1.24-alpine as BUILDER
ARG TARGETPLATFORM
ARG BUILDPLATFORM
RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM"
Expand Down
Loading
Loading