Skip to content

Commit 90055da

Browse files
authored
Merge pull request #5 from DoodleScheduling/DK-3727
feat: update github actions and helm and refactor kustom
2 parents 7ea273a + 6162164 commit 90055da

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+754
-916
lines changed

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
- package-ecosystem: "gomod"
8+
directory: "/"
9+
schedule:
10+
interval: "weekly"
Lines changed: 34 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,63 @@
1-
name: e2e
1+
name: pr-build
22

33
on:
44
pull_request:
5-
push:
6-
branches:
7-
- master
5+
types:
6+
- opened
7+
- synchronize
8+
- reopened
89

910
jobs:
10-
kind:
11+
e2e:
1112
runs-on: ubuntu-latest
1213
steps:
1314
- name: Checkout
14-
uses: actions/checkout@v2
15-
- name: Setup QEMU
16-
uses: docker/setup-qemu-action@v1
15+
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b #v3
16+
- name: Setup Go
17+
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 #v3.5.0
1718
with:
18-
platforms: all
19-
- name: Setup Docker Buildx
20-
id: buildx
21-
uses: docker/setup-buildx-action@v1
19+
go-version: 1.19.x
2220
- name: Restore Go cache
23-
uses: actions/cache@v1
21+
uses: actions/cache@4723a57e26efda3a62cbde1812113b730952852d #v3.2.2
2422
with:
2523
path: ~/go/pkg/mod
2624
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
2725
restore-keys: |
2826
${{ runner.os }}-go-
29-
- name: Cache Docker layers
30-
uses: actions/cache@v2
31-
id: cache
32-
with:
33-
path: /tmp/.buildx-cache
34-
key: ${{ runner.os }}-buildx-ghcache-${{ github.sha }}
35-
restore-keys: |
36-
${{ runner.os }}-buildx-ghcache-
37-
- name: Setup Go
38-
uses: actions/setup-go@v2
39-
with:
40-
go-version: 1.17.x
41-
- name: Setup Kubernetes
42-
uses: engineerd/setup-kind@v0.5.0
43-
with:
44-
version: v0.11.1
45-
image: kindest/node:v1.21.1@sha256:69860bda5563ac81e3c0057d654b5253219618a22ec3a346306239bba8cfa1a6
46-
- name: Setup Kustomize
47-
uses: fluxcd/pkg/actions/kustomize@main
48-
- name: Setup envtest
49-
uses: fluxcd/pkg/actions/envtest@main
50-
with:
51-
version: "1.19.0"
52-
- name: Setup Helm
53-
uses: fluxcd/pkg/actions/helm@main
54-
- name: Run controller tests
27+
- name: fmt
28+
run: make fmt
29+
- name: vet
30+
run: make vet
31+
- name: lint
32+
run: make lint
33+
- name: test
5534
run: make test
35+
- name: build
36+
run: make build
37+
- name: Send go coverage report
38+
uses: shogo82148/actions-goveralls@31ee804b8576ae49f6dc3caa22591bc5080e7920 #v1.6.0
39+
with:
40+
path-to-profile: coverage.out
5641
- name: Check if working tree is dirty
5742
run: |
5843
if [[ $(git diff --stat) != '' ]]; then
5944
git --no-pager diff
60-
echo 'run make test and commit changes'
45+
echo 'run <make test> and commit changes'
6146
exit 1
6247
fi
63-
- name: Deploy certmanager
64-
run: |
65-
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.7.1/cert-manager.yaml
66-
kubectl wait -n cert-manager --for=condition=Ready pods --all
6748
- name: Build container image
6849
run: |
6950
make docker-build IMG=test/k8s-pause:latest BUILD_PLATFORMS=linux/amd64 \
7051
BUILD_ARGS="--cache-from=type=local,src=/tmp/.buildx-cache \
7152
--cache-to=type=local,dest=/tmp/.buildx-cache-new,mode=max"
53+
- name: Setup Kubernetes
54+
uses: engineerd/setup-kind@aa272fe2a7309878ffc2a81c56cfe3ef108ae7d0 #v0.5.0
55+
with:
56+
version: v0.17.0
57+
- name: Deploy certmanager
58+
run: |
59+
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.7.1/cert-manager.yaml
60+
kubectl wait -n cert-manager --for=condition=Ready pods --all
7261
- name: Load test image
7362
run: kind load docker-image test/k8s-pause:latest
7463
- name: Deploy controller
@@ -84,10 +73,7 @@ jobs:
8473
--namespace podinfo \
8574
--set replicaCount=2
8675
- name: Run k8s-pause tests
87-
run: bash ./scripts/e2e-test.sh
88-
- name: Logs
89-
run: |
90-
kubectl -n k8s-pause-system logs deploy/k8s-pause-controller-manager manager
76+
run: bash -e ./scripts/e2e-test.sh
9177
- name: Debug failure
9278
if: failure()
9379
run: |
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,41 @@
11
name: Lint and Test Charts
22

3-
on:
4-
pull_request:
5-
push:
6-
branches:
7-
- master
3+
on: pull_request
84

95
jobs:
106
lint-test:
117
runs-on: ubuntu-latest
128
steps:
139
- name: Checkout
14-
uses: actions/checkout@v2
10+
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b #v3
1511
with:
1612
fetch-depth: 0
1713

1814
- name: Set up Helm
19-
uses: azure/setup-helm@v1
15+
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 #v3.5
2016
with:
2117
version: v3.4.0
2218

23-
- uses: actions/setup-python@v2
19+
- uses: actions/setup-python@5ccb29d8773c3f3f653e1705f474dfaa8a06a912 #v4.4.0
2420
with:
2521
python-version: 3.7
2622

2723
- name: Set up chart-testing
28-
uses: helm/chart-testing-action@v2.1.0
24+
uses: helm/chart-testing-action@afea100a513515fbd68b0e72a7bb0ae34cb62aec #v2.3.1
2925

3026
- name: Run chart-testing (list-changed)
3127
id: list-changed
3228
run: |
33-
changed=$(ct list-changed --chart-dirs chart)
29+
changed=$(ct list-changed --target-branch=master --chart-dirs chart)
3430
if [[ -n "$changed" ]]; then
3531
echo "::set-output name=changed::true"
3632
fi
3733
3834
- name: Run chart-testing (lint)
39-
run: ct lint --chart-dirs chart
35+
run: ct lint --target-branch=master --chart-dirs chart
4036

4137
- name: Create kind cluster
42-
uses: helm/kind-action@v1.2.0
38+
uses: helm/kind-action@d8ccf8fb623ce1bb360ae2f45f323d9d5c5e9f00 #v1.5.0
4339
if: steps.list-changed.outputs.changed == 'true'
4440

4541
- name: Deploy certmanager
@@ -48,4 +44,4 @@ jobs:
4844
kubectl wait -n cert-manager --for=condition=Ready pods --all
4945
5046
- name: Run chart-testing (install)
51-
run: ct install --chart-dirs chart
47+
run: ct install --target-branch=master --chart-dirs chart

.github/workflows/pr-label.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: pr-label
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
size-label:
8+
runs-on: ubuntu-latest
9+
if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }}
10+
steps:
11+
- name: size-label
12+
uses: "pascalgn/size-label-action@1619680c5ac1ef360b944bb56a57587ba4aa2af8"
13+
env:
14+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

.github/workflows/rebase.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Checkout the latest code
15-
uses: actions/checkout@v2
15+
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b #v3
1616
with:
1717
fetch-depth: 0
1818
- name: Automatic Rebase
19-
uses: cirrus-actions/rebase@1.3.1
19+
uses: cirrus-actions/rebase@b87d48154a87a85666003575337e27b8cd65f691 #1.8
2020
env:
2121
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}

.github/workflows/release-chart.yaml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,21 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout
13-
uses: actions/checkout@v2
13+
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b #v3
1414
with:
1515
fetch-depth: 0
1616

17-
- name: Configure Git
17+
- name: Install Helm
18+
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 #v3.5
19+
20+
- name: Login to Github Container Registry using helm
21+
run: echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ghcr.io --username ${{ github.actor }} --password-stdin
22+
23+
- name: Package helm charts
1824
run: |
19-
git config user.name "$GITHUB_ACTOR"
20-
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
21-
- name: Run chart-releaser
22-
uses: helm/chart-releaser-action@v1.3.0
23-
with:
24-
charts_dir: ./chart
25-
env:
26-
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
25+
helm package chart/k8s-pause -d chart
26+
27+
- name: Publish helm charts to Github Container Registry
28+
run: |
29+
repository=$(echo "${{ github.repository_owner }}" | tr [:upper:] [:lower:])
30+
helm push ${{ github.workspace }}/chart/k8s-pause-*.tgz oci://ghcr.io/$repository/charts

.github/workflows/release.yaml

Lines changed: 18 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -3,81 +3,38 @@ on:
33
push:
44
tags:
55
- 'v*'
6-
workflow_dispatch:
7-
inputs:
8-
tag:
9-
description: 'image tag prefix'
10-
default: 'rc'
11-
required: true
126

13-
env:
14-
CONTROLLER: ${{ github.event.repository.name }}
7+
permissions:
8+
contents: write # needed to write releases
9+
id-token: write # needed for keyless signing
10+
packages: write # needed for ghcr access
1511

1612
jobs:
17-
build-push:
13+
build:
14+
name: Build
1815
runs-on: ubuntu-latest
1916
steps:
20-
- uses: actions/checkout@v2
21-
- name: Setup Kustomize
22-
uses: fluxcd/pkg/actions/kustomize@main
23-
- name: Prepare
24-
id: prep
25-
run: |
26-
VERSION="${{ github.event.inputs.tag }}-${GITHUB_SHA::8}"
27-
if [[ $GITHUB_REF == refs/tags/* ]]; then
28-
VERSION=${GITHUB_REF/refs\/tags\//}
29-
fi
30-
echo ::set-output name=BUILD_DATE::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
31-
echo ::set-output name=VERSION::${VERSION}
32-
- name: Setup QEMU
33-
uses: docker/setup-qemu-action@v1
17+
- name: Checkout code
18+
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b #v3
3419
with:
35-
platforms: all
36-
- name: Setup Docker Buildx
37-
id: buildx
38-
uses: docker/setup-buildx-action@v1
20+
fetch-depth: 0
21+
- uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 #v3.5.0
3922
with:
40-
buildkitd-flags: "--debug"
41-
- name: Login to GitHub Container Registry
42-
uses: docker/login-action@v1
23+
go-version: '1.19'
24+
- name: Docker Login
25+
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a #v2.1.0
4326
with:
4427
registry: ghcr.io
4528
username: ${{ github.actor }}
4629
password: ${{ secrets.GITHUB_TOKEN }}
47-
- name: Generate images meta
48-
id: meta
49-
uses: docker/metadata-action@v3
50-
with:
51-
images: |
52-
ghcr.io/doodlescheduling/${{ env.CONTROLLER }}
53-
tags: |
54-
type=raw,value=${{ steps.prep.outputs.VERSION }}
55-
- name: Publish multi-arch container image
56-
uses: docker/build-push-action@v2
57-
with:
58-
push: true
59-
builder: ${{ steps.buildx.outputs.name }}
60-
context: .
61-
file: ./Dockerfile
62-
platforms: linux/amd64,linux/arm/v7,linux/arm64
63-
tags: ${{ steps.meta.outputs.tags }}
64-
labels: ${{ steps.meta.outputs.labels }}
65-
- name: Check images
66-
run: |
67-
docker buildx imagetools inspect ghcr.io/doodlescheduling/${{ env.CONTROLLER }}:${{ steps.prep.outputs.VERSION }}
68-
docker pull ghcr.io/doodlescheduling/${{ env.CONTROLLER }}:${{ steps.prep.outputs.VERSION }}
69-
- name: Generate release manifests
70-
if: startsWith(github.ref, 'refs/tags/v')
71-
run: |
72-
mkdir -p config/release
73-
kustomize build ./config/manager > ./config/release/${{ env.CONTROLLER }}.deployment.yaml
74-
echo '[CHANGELOG](https://github.com/DoodleScheduling/${{ env.CONTROLLER }}/blob/master/CHANGELOG.md)' > ./config/release/notes.md
75-
- uses: anchore/sbom-action/download-syft@v0
30+
- name: Setup Cosign
31+
uses: sigstore/cosign-installer@9becc617647dfa20ae7b1151972e9b3a2c338a2b #v2.8.1
32+
- uses: anchore/sbom-action/download-syft@06e109483e6aa305a2b2395eabae554e51530e1d #v0.13.1
7633
- name: Create release and SBOM
7734
if: startsWith(github.ref, 'refs/tags/v')
78-
uses: goreleaser/goreleaser-action@v2
35+
uses: goreleaser/goreleaser-action@8f67e590f2d095516493f017008adc464e63adb1 #v4.1.0
7936
with:
8037
version: latest
81-
args: release --release-notes=config/release/notes.md --rm-dist --skip-validate
38+
args: release --rm-dist --skip-validate
8239
env:
8340
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/size-labeler.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ testbin/*
2323
*.swp
2424
*.swo
2525
*~
26+
.DS_Store

0 commit comments

Comments
 (0)