Skip to content

Commit

Permalink
chore: Bump go; use goreleaser for build (#281)
Browse files Browse the repository at this point in the history
* chore: Bump go version to 1.21

* chore: Use docker file for go-tools

* chore: Use goreleaser for build

* chore: Update workflows

* chore: Fix codeql workflow

* chore: Bump github.com/obalunenko/logger to v1.0.1
  • Loading branch information
obalunenko authored Dec 1, 2023
1 parent 2b14ee4 commit 9b4ebed
Show file tree
Hide file tree
Showing 80 changed files with 456 additions and 10,315 deletions.
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,19 @@ updates:
commit-message:
prefix: "chore"
include: "scope"


- package-ecosystem: "docker"
directory: "/build/docker/go-tools"
schedule:
interval: "daily"
labels:
- "dependencies"
- "docker"
assignees:
- "obalunenko"
reviewers:
- "obalunenko"
commit-message:
prefix: "chore"
include: "scope"
20 changes: 15 additions & 5 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,32 @@ on:
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: true
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support

language: [ 'go' ]
os: [ 'ubuntu-22.04' ]
go-version: [1.21]
steps:
- name: Checkout repository
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up go
uses: actions/[email protected]
with:
go-version: ${{ matrix.go-version }}
- run: |
go version
shell: bash
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/dockerfiles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: build-lint-docker-images

on:
push:
branches:
- "master"
pull_request:
types: [ opened, synchronize, reopened ]
branches:
- "*"
paths:
- "!**"
- "build/docker/**"
- "!build/docker/**.sh"
- ".github/workflows/dockerfiles.yml"

jobs:
lint-dockerfiles:
strategy:
fail-fast: false
max-parallel: 4
matrix:
dockerfile:
[
"./build/docker/go-tools/Dockerfile",
]
runs-on: "ubuntu-22.04"
name: Lint ${{ matrix.dockerfile }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Lint
uses: jbergstroem/hadolint-gh-action@v1
with:
dockerfile: ${{ matrix.dockerfile }}
annotate: true
error_level: 2
26 changes: 18 additions & 8 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
max-parallel: 3
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.20' ]
go-version: [1.21]
runs-on: ${{ matrix.os }}
name: Build
steps:
Expand All @@ -53,7 +53,7 @@ jobs:
- name: Set up go
uses: actions/[email protected]
with:
go-version: ${{ matrix.go }}
go-version: ${{ matrix.go-version }}

- run: |
go version
Expand All @@ -72,6 +72,11 @@ jobs:
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/tools/go.sum') }}
- name: Install tools
run: |
make install-tools
shell: bash

- name: Build
run: |
make build
Expand All @@ -93,7 +98,7 @@ jobs:
max-parallel: 2
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.20' ]
go-version: [1.21]
runs-on: ${{ matrix.os }}
name: Run Tests
steps:
Expand All @@ -105,7 +110,7 @@ jobs:
- name: Set up go
uses: actions/[email protected]
with:
go-version: ${{ matrix.go }}
go-version: ${{ matrix.go-version }}

- run: |
go version
Expand Down Expand Up @@ -140,7 +145,7 @@ jobs:
max-parallel: 2
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.20' ]
go-version: [1.21]
runs-on: ${{ matrix.os }}
name: Run linters
steps:
Expand All @@ -152,11 +157,16 @@ jobs:
- name: Set up go
uses: actions/[email protected]
with:
go-version: ${{ matrix.go }}
go-version: ${{ matrix.go-version }}
- run: |
go version
shell: bash
- name: Install tools
run: |
make install-tools
shell: bash

- name: Vet
run: |
make vet
Expand Down Expand Up @@ -192,7 +202,7 @@ jobs:
max-parallel: 1
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.20' ]
go-version: [1.21]
runs-on: ${{ matrix.os }}
name: Quality reports
steps:
Expand All @@ -204,7 +214,7 @@ jobs:
- name: Set up go
uses: actions/[email protected]
with:
go-version: ${{ matrix.go }}
go-version: ${{ matrix.go-version }}
- run: |
go version
shell: bash
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
max-parallel: 2
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.20' ]
go-version: [1.21]
runs-on: ${{ matrix.os }}
name: Build
steps:
Expand All @@ -26,7 +26,7 @@ jobs:
- name: Set up go
uses: actions/[email protected]
with:
go-version: ${{ matrix.go }}
go-version: ${{ matrix.go-version }}

- run: |
go version
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
max-parallel: 2
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.20' ]
go-version: [1.21]
runs-on: ${{ matrix.os }}
name: Regression tests
steps:
Expand All @@ -72,7 +72,7 @@ jobs:
- name: Set up go
uses: actions/[email protected]
with:
go-version: ${{ matrix.go }}
go-version: ${{ matrix.go-version }}

- run: |
go version
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
max-parallel: 1
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.20' ]
go-version: [1.21]
runs-on: ${{ matrix.os }}
name: Lint
steps:
Expand All @@ -121,7 +121,7 @@ jobs:
- name: Set up go
uses: actions/[email protected]
with:
go-version: ${{ matrix.go }}
go-version: ${{ matrix.go-version }}

- run: |
go version
Expand Down Expand Up @@ -162,7 +162,7 @@ jobs:
max-parallel: 1
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.20' ]
go-version: [1.21]
runs-on: ${{ matrix.os }}
name: Release
steps:
Expand All @@ -174,7 +174,7 @@ jobs:
- name: Set up go
uses: actions/[email protected]
with:
go-version: ${{ matrix.go }}
go-version: ${{ matrix.go-version }}

- run: |
go version
Expand Down
24 changes: 12 additions & 12 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ release:
**Full Changelog**: https://github.com/obalunenko/advent-of-code/compare/{{ .PreviousTag }}...{{ .Tag }}
gomod:
proxy: true
proxy: false
# If proxy is true, use these environment variables when running `go mod` commands (namely, `go mod tidy`).
# Defaults to `os.Environ()`.
env:
Expand All @@ -16,24 +16,24 @@ gomod:
- CGO_ENABLED=0
# Which Go binary to use.
# Defaults to `go`.
mod: vendor
gobinary: go

before:
hooks:
- go mod verify

builds:
- id: cli
binary: aoc-cli
goos:
- linux
- darwin
- windows
- 'linux'
- 'darwin'
- 'windows'
goarch:
- 386
- amd64
- arm
- arm64
- 'amd64'
- 'arm'
- 'arm64'
ignore:
- goos: darwin
goarch: 'arm'

mod_timestamp: '{{ .CommitTimestamp }}'
env:
- CGO_ENABLED=0
Expand Down
22 changes: 14 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
SHELL := env VERSION=$(VERSION) $(SHELL)
VERSION ?= $(shell git describe --tags $(git rev-list --tags --max-count=1))

GOVERSION:=1.21

APP_NAME?=aoc-cli
SHELL := env APP_NAME=$(APP_NAME) $(SHELL)

Expand All @@ -10,7 +12,7 @@ SHELL := env GOTOOLS_IMAGE_TAG=$(GOTOOLS_IMAGE_TAG) $(SHELL)
COMPOSE_TOOLS_FILE=deployments/docker-compose/go-tools-docker-compose.yml
COMPOSE_TOOLS_CMD_BASE=docker compose -f $(COMPOSE_TOOLS_FILE)
COMPOSE_TOOLS_CMD_UP=$(COMPOSE_TOOLS_CMD_BASE) up --exit-code-from
COMPOSE_TOOLS_CMD_PULL=$(COMPOSE_TOOLS_CMD_BASE) pull
COMPOSE_TOOLS_CMD_PULL=$(COMPOSE_TOOLS_CMD_BASE) build

TARGET_MAX_CHAR_NUM=20

Expand All @@ -32,15 +34,20 @@ help:
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)

bump-go-version:
./scripts/bump-go.sh $(GOVERSION)
.PHONY: bump-go-version

## Build project.
build: compile-app
build: sync-vendor generate compile-app
.PHONY: build

## Compile app.
compile-app:
./scripts/build/app.sh
$(COMPOSE_TOOLS_CMD_UP) build build
.PHONY: compile-app


## Test coverage report.
test-cover:
$(COMPOSE_TOOLS_CMD_UP) run-tests-coverage run-tests-coverage
Expand Down Expand Up @@ -94,13 +101,12 @@ format-project: fmt imports

## Installs vendored tools.
install-tools:
echo "Installing ${GOTOOLS_IMAGE_TAG}"
$(COMPOSE_TOOLS_CMD_PULL)
.PHONY: install-tools

## vet project
vet:
./scripts/linting/run-vet.sh
$(COMPOSE_TOOLS_CMD_UP) vet vet
.PHONY: vet

## Run full linting
Expand Down Expand Up @@ -129,17 +135,17 @@ generate: codegen format-project vet

## Release
release:
./scripts/release/release.sh
$(COMPOSE_TOOLS_CMD_UP) release release
.PHONY: release

## Release local snapshot
release-local-snapshot:
./scripts/release/local-snapshot-release.sh
$(COMPOSE_TOOLS_CMD_UP) release-local-snapshot release-local-snapshot
.PHONY: release-local-snapshot

## Check goreleaser config.
check-releaser:
./scripts/release/check.sh
$(COMPOSE_TOOLS_CMD_UP) release-check-config release-check-config
.PHONY: check-releaser

## Issue new release.
Expand Down
3 changes: 3 additions & 0 deletions build/docker/go-tools/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM ghcr.io/obalunenko/go-tools:v1.3.2 AS builder

CMD ["/bin/sh", "-c", ""]
Loading

0 comments on commit 9b4ebed

Please sign in to comment.