Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial version review #1

Merged
merged 6 commits into from
Sep 19, 2023
Merged
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
19 changes: 19 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.idea
.code
local
bin
.git
.gitignore
.github
charts
docs
example
Dockerfile
.gitlab-ci.yml
env.local
docker-compose*
Makefile
README.md
sonar-project.properties
*.iml
.dockerignore
58 changes: 58 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
on:
push:
paths-ignore:
- 'charts/**'
- 'example/**'
- 'docs/**'
- '/*.md'
branches:
- '*'
pull_request:
paths-ignore:
- 'example/**'
- 'charts/**'
- 'docs/**'
- '/*.md'
workflow_call:

name: Build and test
jobs:
build:
strategy:
matrix:
architecture: [amd64, arm64]
os: [linux, darwin]

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

- name: Set up Go 1.21.x
uses: actions/setup-go@v4
with:
go-version: '1.21'
cache: true
id: go

- name: Download Go modules
run: go mod download
env:
GOPROXY: https://proxy.golang.org

- name: Build
run: GOOS=${{ matrix.os }} GOARCH=${{matrix.architecture}} go build ${{ env.LDFLAGS }} -o bin/node-undertaker-${{ matrix.os }}-${{ matrix.architecture }} ./cmd/node-undertaker

- name: Test
run: |
go get github.com/golang/mock/mockgen
go install github.com/golang/mock/mockgen
go generate ./...
go test ./...

- uses: actions/upload-artifact@v3
if: github.event_name != 'pull_request'
with:
name: node-undertaker-binaries
path: bin/node-undertaker-*
if-no-files-found: error
60 changes: 60 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
on:
schedule:
- cron: '5 11 * * 3'
push:
paths-ignore:
- 'charts/**'
- 'example/**'
- 'docs/**'
- '/*.md'
branches:
- 'main'
- 'release-*'
pull_request:
branches:
- 'main'
- 'release-*'
paths-ignore:
- 'charts/**'
- 'example/**'
- 'docs/**'
- '/*.md'
workflow_call:

name: CodeQL analysis
jobs:
codql-build:
permissions:
security-events: write
strategy:
matrix:
architecture: [amd64]
os: [linux]

runs-on: ubuntu-latest
steps:
- name: Set up Go 1.21.x
uses: actions/setup-go@v2
with:
go-version: 1.21.x
cache: true
id: go

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

- name: Download Go modules
run: go mod download
env:
GOPROXY: https://proxy.golang.org

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: go

- name: Build
run: GOOS=${{ matrix.os }} GOARCH=${{matrix.architecture}} go build -o bin/node-undertaker ./cmd/node-undertaker

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
81 changes: 81 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Build docker image

on:
workflow_call:
push:
paths-ignore:
- 'charts/**'
- 'docs/**'
- 'example/**'
- '/*.md'
branches:
- '*'
pull_request:
paths-ignore:
- 'charts/**'
- 'example/**'
- 'docs/**'
- '/*.md'
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
type=ref,event=tag
type=ref,event=branch
type=ref,event=pr

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64 #,darwin/arm64,darwin/amd64
build-args: ${{ github.event_name == 'push' && github.ref_type == 'tag' && format('RELEASE_VERSION={0}', github.ref_name) || '' }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
cache-to: ${{ github.event_name != 'pull_request' && format( 'type=registry,ref={0}/{1}:buildcache,mode=max', env.REGISTRY, env.IMAGE_NAME ) || '' }}

31 changes: 31 additions & 0 deletions .github/workflows/release-helm-chart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
on:
push:
paths:
- "charts/**"
branches:
- 'main'

name: Release
jobs:
create-helm-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"

- name: Install Helm
uses: azure/setup-helm@v1
with:
version: v3.8.1

- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.5.0
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
31 changes: 31 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
on:
push:
tags:
- "v*.*.*"

name: Release
jobs:
docker-build:
uses: ./.github/workflows/docker.yml
build-and-test:
uses: ./.github/workflows/build.yml
create-release:
needs:
- docker-build
- build-and-test
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: node-undertaker-binaries
path: bin
- name: debug list files
run: find .
- name: Release
uses: softprops/action-gh-release@v1
with:
files: bin/node-undertaker*
append_body: true
body: |
Build also available as docker image:
`ghcr.io/${{ github.repository }}:${{ github.ref_name }}`
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
./bin
bin/
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test
**/mocks/*_mocks.go

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work

.idea
.code

etcd-peers
local/certs
site/
43 changes: 43 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
variables:
TYPE: app

image: golang:1.21

include:
- project: shared-scripts/gitlab-ci
file: /autodevops-golang.yml
ref: v1

# mockgen setup
Test:
before_script:
- export PATH=$GOPATH/bin:$PATH
- go get github.com/golang/mock/mockgen
- go install github.com/golang/mock/mockgen
Vet:
before_script:
- export PATH=$GOPATH/bin:$PATH
- go get github.com/golang/mock/mockgen
- go install github.com/golang/mock/mockgen
Build:
before_script:
- export PATH=$GOPATH/bin:$PATH
- go get github.com/golang/mock/mockgen
- go install github.com/golang/mock/mockgen
Dependency-Track:
before_script:
- export PATH=$GOPATH/bin:$PATH
- go get github.com/golang/mock/mockgen
- go install github.com/golang/mock/mockgen

Docker Release:
variables:
PROJECT_VERSION: "${CI_COMMIT_REF_NAME}"

Deploy Dev Manual:
rules:
- when: never

Deploy Fat:
rules:
- when: never
Loading