Skip to content

Commit

Permalink
ci: update workflows (#34)
Browse files Browse the repository at this point in the history
* ci: update workflows

* ci: codeowner, tidy

* ci: update kind version

* ci: disable cgo
  • Loading branch information
raffis committed Apr 24, 2023
1 parent a3ed659 commit 47a6da0
Show file tree
Hide file tree
Showing 20 changed files with 196 additions and 177 deletions.
12 changes: 12 additions & 0 deletions .-
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Release process

### Controller release
1. Merge all pr's to master which need to be part of the new release
2. Create pr to master and bump the kustomization base
3. Push a tag following semantic versioning prefixed by 'v'. Do not create a github release, this is done automatically.
4. Create a new pr and add the following changes:
1. Bump chart version
2. Bump charts app version

### Helm chart change only
1. Bump the helm chart version in the pr
10 changes: 0 additions & 10 deletions .github/dependabot.yml

This file was deleted.

30 changes: 30 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: main

on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3
- name: Setup Go
uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
with:
go-version: 1.20.x
- name: Restore Go cache
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Tests
run: make test
- name: Send go coverage report
uses: shogo82148/actions-goveralls@31ee804b8576ae49f6dc3caa22591bc5080e7920 #v1.6.0
with:
path-to-profile: coverage.out
10 changes: 4 additions & 6 deletions .github/workflows/pr-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 #v3.5.0
with:
go-version: 1.19.x
go-version: 1.20.x
- name: Restore Go cache
uses: actions/cache@4723a57e26efda3a62cbde1812113b730952852d #v3.2.2
with:
Expand Down Expand Up @@ -47,9 +47,7 @@ jobs:
fi
- name: Build container image
run: |
make docker-build IMG=test/k8s-pause:latest BUILD_PLATFORMS=linux/amd64 \
BUILD_ARGS="--cache-from=type=local,src=/tmp/.buildx-cache \
--cache-to=type=local,dest=/tmp/.buildx-cache-new,mode=max"
make docker-build
- name: Setup Kubernetes
uses: engineerd/setup-kind@aa272fe2a7309878ffc2a81c56cfe3ef108ae7d0 #v0.5.0
with:
Expand All @@ -59,9 +57,9 @@ jobs:
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.7.1/cert-manager.yaml
kubectl wait -n cert-manager --for=condition=Ready pods --all
- name: Load test image
run: kind load docker-image test/k8s-pause:latest
run: kind load docker-image k8s-pause:latest
- name: Deploy controller
run: make deploy IMG=test/k8s-pause:latest
run: make deploy
- name: Setup podinfo
env:
PODINFO_VER: ${{ '6.0.3' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-chart.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Lint and Test Charts
name: pr-chart

on: pull_request

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-chart.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release Chart
name: release-chart

on:
push:
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/scan.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: scan

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
schedule:
- cron: '18 10 * * 3'

permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for codeQL to write security events

jobs:
fossa:
name: FOSSA
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
- name: Run FOSSA scan and upload build data
uses: fossa-contrib/fossa-action@6728dc6fe9a068c648d080c33829ffbe56565023 # v2.0.0
with:
# FOSSA Push-Only API Token
fossa-api-key: 956b9b92c5b16eeca1467cebe104f2c3
github-token: ${{ github.token }}

codeql:
name: CodeQL
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
- name: Initialize CodeQL
uses: github/codeql-action/init@dc046388f30eacf938aadd32064285f437bd9c04 #codeql-bundle-20221020
with:
languages: go
- name: Autobuild
uses: github/codeql-action/autobuild@dc046388f30eacf938aadd32064285f437bd9c04 #codeql-bundle-20221020
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@dc046388f30eacf938aadd32064285f437bd9c04 #codeql-bundle-20221020
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*.dylib
bin
testbin/*
manager

# Test binary, build with `go test -c`
*.test
Expand Down
18 changes: 9 additions & 9 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ sboms:

dockers:
- image_templates:
- ghcr.io/doodlescheduling/{{ .ProjectName }}:{{ .Version }}-amd64
dockerfile: Dockerfile.release
- ghcr.io/doodlescheduling/{{ .ProjectName }}:v{{ .Version }}-amd64
dockerfile: Dockerfile
use: buildx
ids:
- manager
Expand All @@ -48,9 +48,9 @@ dockers:
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=Apache-2.0
- image_templates:
- "ghcr.io/doodlescheduling/{{ .ProjectName }}:{{ .Version }}-arm64v8"
- ghcr.io/doodlescheduling/{{ .ProjectName }}:v{{ .Version }}-arm64v8
goarch: arm64
dockerfile: Dockerfile.release
dockerfile: Dockerfile
use: buildx
ids:
- manager
Expand All @@ -66,14 +66,14 @@ dockers:
- --label=org.opencontainers.image.licenses=Apache-2.0

docker_manifests:
- name_template: ghcr.io/doodlescheduling/{{ .ProjectName }}:{{ .Version }}
- name_template: ghcr.io/doodlescheduling/{{ .ProjectName }}:v{{ .Version }}
image_templates:
- ghcr.io/doodlescheduling/{{ .ProjectName }}:{{ .Version }}-amd64
- ghcr.io/doodlescheduling/{{ .ProjectName }}:{{ .Version }}-arm64v8
- ghcr.io/doodlescheduling/{{ .ProjectName }}:v{{ .Version }}-amd64
- ghcr.io/doodlescheduling/{{ .ProjectName }}:v{{ .Version }}-arm64v8
- name_template: ghcr.io/doodlescheduling/{{ .ProjectName }}:latest
image_templates:
- ghcr.io/doodlescheduling/{{ .ProjectName }}:{{ .Version }}-amd64
- ghcr.io/doodlescheduling/{{ .ProjectName }}:{{ .Version }}-arm64v8
- ghcr.io/doodlescheduling/{{ .ProjectName }}:v{{ .Version }}-amd64
- ghcr.io/doodlescheduling/{{ .ProjectName }}:v{{ .Version }}-arm64v8

signs:
- cmd: cosign
Expand Down
15 changes: 0 additions & 15 deletions CHANGELOG.md

This file was deleted.

1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @DoodleScheduling/DevOps
14 changes: 4 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,11 @@

### Controller release
1. Merge all pr's to master which need to be part of the new release
2. Create pr to master with these changes:
1. Bump kustomization
2. Create CHANGELOG.md entry with release and date
3. Merge pr
4. Push a tag following semantic versioning prefixed by 'v'. Do not create a github release, this is done automatically.
5. Create new branch and add the following changes:
2. Create pr to master and bump the kustomization base
3. Push a tag following semantic versioning prefixed by 'v'. Do not create a github release, this is done automatically.
4. Create a new pr and add the following changes:
1. Bump chart version
2. Bump charts app version
6. Create pr to master and merge

### Helm chart change only
1. Create branch with changes
2. Bump chart version
3. Create pr to master and merge
1. Bump the helm chart version in the pr
22 changes: 1 addition & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,6 @@
# Build the manager binary
FROM golang:1.19 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

# Copy the go source
COPY main.go main.go
COPY controllers/ controllers/

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/manager .
COPY manager manager
USER 65532:65532

ENTRYPOINT ["/manager"]
8 changes: 0 additions & 8 deletions Dockerfile.release

This file was deleted.

8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

# Image URL to use all building/pushing image targets
IMG ?= controller:latest
IMG ?= k8s-pause:latest
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.23

Expand Down Expand Up @@ -71,7 +71,7 @@ test: manifests generate fmt vet tidy envtest ## Run tests.

.PHONY: build
build: generate fmt vet tidy ## Build manager binary.
go build -o bin/manager main.go
CGO_ENABLED=0 go build -o manager main.go

.PHONY: run
run: manifests generate fmt vet tidy ## Run a controller from your host.
Expand All @@ -88,7 +88,7 @@ api-docs: gen-crd-api-reference-docs
$(GEN_CRD_API_REFERENCE_DOCS) -api-dir=./api/v1beta1 -config=./hack/api-docs/config.json -template-dir=./hack/api-docs/template -out-file=./docs/api/v1beta1.md

.PHONY: docker-build
docker-build:
docker-build: build
docker build -t ${IMG} .

.PHONY: docker-push
Expand Down Expand Up @@ -126,7 +126,7 @@ controller-gen: ## Download controller-gen locally if necessary.
GOLANGCI_LINT = $(GOBIN)/golangci-lint
.PHONY: golangci-lint
golangci-lint: ## Download golint locally if necessary
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint@v1.49.0)
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2)

KUSTOMIZE = $(GOBIN)/kustomize
.PHONY: kustomize
Expand Down
4 changes: 2 additions & 2 deletions chart/k8s-pause/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
appVersion: 0.2.1
appVersion: v0.2.2
description: Suspend and resume kubernetes namespaces
home: https://github.com/DoodleScheduling/k8s-pause
maintainers:
Expand All @@ -14,4 +14,4 @@ keywords:
name: k8s-pause
sources:
- https://github.com/DoodleScheduling/k8s-pause
version: 0.2.1
version: 0.2.2
2 changes: 1 addition & 1 deletion config/base/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ configMapGenerator:
name: manager-config
images:
- name: ghcr.io/doodlescheduling/k8s-pause
newTag: v0.1.1
newTag: v0.2.2
Loading

0 comments on commit 47a6da0

Please sign in to comment.