Skip to content

Commit

Permalink
Merge branch 'initial2' into 'review'
Browse files Browse the repository at this point in the history
Initial version

See merge request aws-dctf/kubernetes/node-undertaker!3
  • Loading branch information
kamil-stc committed Sep 18, 2023
2 parents 8cf37da + fba4a61 commit 10ad32c
Show file tree
Hide file tree
Showing 76 changed files with 6,788 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.idea
.code
local
bin
.git
.gitignore
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
67 changes: 67 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
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: Build and test
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
id: go

- name: Cache Go modules packages
uses: actions/[email protected]
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-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 "[email protected]"
- name: Install Helm
uses: azure/setup-helm@v1
with:
version: v3.8.1

- name: Run chart-releaser
uses: helm/[email protected]
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

0 comments on commit 10ad32c

Please sign in to comment.