Skip to content

Commit

Permalink
add CI + dependabot + cleanup (#11)
Browse files Browse the repository at this point in the history
* add CI + dependabot + cleanup
  • Loading branch information
TheDen authored May 13, 2024
1 parent 050e475 commit 46775b7
Show file tree
Hide file tree
Showing 6 changed files with 244 additions and 1 deletion.
45 changes: 45 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
version: 2
updates:
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "daily"
time: "09:00"
timezone: "Australia/Melbourne"
ignore:
- dependency-name: "*"
update-types: ["version-update:semver-major"]
groups:
docker:
patterns:
- "*"
labels:
- "docker"
- "dependencies"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
time: "09:00"
timezone: "Australia/Melbourne"
groups:
github:
patterns:
- "*"
labels:
- "ci"
- "dependencies"

- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
time: "09:00"
timezone: "Australia/Melbourne"
groups:
go:
patterns:
- "*"
labels:
- "dependencies"
25 changes: 25 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "CD"

on:
push:
branches:
- main

jobs:
tag:
name: Create a new tag
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
new_tag: ${{ steps.push-tag.outputs.new_tag }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Push tag
id: push-tag
uses: anothrNick/github-tag-action@1.69.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
DEFAULT_BUMP: patch
132 changes: 132 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: "CI"

on:
pull_request:
push:
branches:
- main
workflow_dispatch:

jobs:
shellcheck:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@2.0.0
with:
ignore_paths: "./vendor/**"

prettier:
name: Prettier
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Prettify code
uses: creyD/prettier_action@v4.3
with:
dry: true
prettier_options: --log-level debug --check .

hadolint:
name: hadolint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: "Dockerfile.template"

typocheck:
name: Spell Check with Typos
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v4
- name: Check for typos
uses: crate-ci/typos@master
with:
config: ./.typos.toml

go-staticcheck:
name: go-staticcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22"

- name: Setup staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@latest

- name: Run staticcheck
run: staticcheck ./...

golines:
name: golines
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22"

- name: Setup golines
run: go install github.com/segmentio/golines@latest

- name: Run golines
run: |
golines --write-output --ignored-dirs=vendor .
gosec:
name: gosec
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22"

- name: Setup Gosec Security Scanner
run: go install github.com/securego/gosec/v2/cmd/gosec@latest

- name: Run Gosec Security Scanner
run: make gosec

test-go-build-run:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
name: Go build
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22"

- name: Setup docker (missing on MacOS)
if: runner.os == 'macos'
run: |
brew install --HEAD colima
brew install docker
colima start --arch x86_64
- name: Test Go build
run: go build -o bin/anchor cmd/main.go

- name: Test Go run
run: go run cmd/main.go -y

- name: Run Tests
run: make test
38 changes: 38 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "Release"

on: workflow_dispatch

jobs:
release:
name: "Release"
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22"

- name: Go build all production binaries
run: |
git fetch --tags
make build-all-prod
- name: Create a GitHub Release
run: |
git fetch --tags
previous_release_tag=$(gh release list --json tagName -L 1 --jq '.[0].tagName')
latest_tag="$(git describe --tags --abbrev=0)"
gh release create \
"${latest_tag}" \
--title "Release ${latest_tag}" \
--latest \
--generate-notes \
--notes-start-tag "${previous_release_tag}" \
bin/anchor_linux_amd64 \
bin/anchor_linux_arm64 \
bin/anchor_darwin_amd64 \
bin/anchor_darwin_arm64 \
bin/anchor_windows_amd64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ go-staticcheck: ## Runs staticcheck on the codebase
run: ## Runs the binary
go run cmd/*.go $(ARGS)

test: ## Runs the tests
go test -v .

build: format-lint ## Builds the binary for your current platform
go build -o bin/${BINARY_NAME} cmd/*.go

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Anchor

A tool for anchoring depencencies in dockerfiles
A tool for anchoring dependencies in dockerfiles

0 comments on commit 46775b7

Please sign in to comment.