Skip to content

Commit

Permalink
Improve workflow speed & build binaries (#144)
Browse files Browse the repository at this point in the history
* Avoid the module download. setup-go action is caching for us
* Use pre-built cloud-provider-kind image instead of rebuilding
* build and publish latest binary on tag to pre-release
* Update tests/integration/install-kind.sh

Co-authored-by: Mark Goddard <[email protected]>

* feat: improve release workflow. Add license

* chore: add tag to artifact name

* remove privileged mode from docker run

---------

Co-authored-by: Mark Goddard <[email protected]>
  • Loading branch information
kipz and markgoddard authored Feb 7, 2025
1 parent eb08d83 commit 249bcb8
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 70 deletions.
46 changes: 0 additions & 46 deletions .github/actions/cache-cloud-provider-kind-image/action.yml

This file was deleted.

59 changes: 59 additions & 0 deletions .github/release-drafter-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name-template: "v$RESOLVED_VERSION"
tag-template: "v$RESOLVED_VERSION"
categories:
- title: "🚀 Features"
labels:
- "feat"
- "feature"
- "enhancement"
- title: "🐛 Bug Fixes"
labels:
- "fix"
- "bugfix"
- "bug"
- title: "🧰 Maintenance"
labels:
- "chore"
- title: "💥 Breaking Changes"
labels:
- "breaking"

change-template: "- $TITLE @$AUTHOR (#$NUMBER)"
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
version-resolver:
major:
labels:
- "major"
- "breaking"
minor:
labels:
- "minor"
patch:
labels:
- "patch"
default: patch
template: |
## Changes
$CHANGES
autolabeler:
- label: "chore"
files:
- "*.md"
title:
- "/^docs!?:/i"
- "/^test!?:/i"
- "/^chore!?:/i"
- "/^refactor!?:/i"
- label: "bug"
title:
- "/^fix!?:/i"
- "/^revert!?:/i"
- label: "feature"
title:
- "/^feat!?:/i"
- "/^add!?:/i"
- label: "breaking"
title:
- "/^[a-zA-Z]+!:/i"
5 changes: 1 addition & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,5 @@ jobs:
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Install dependencies
run: |
go mod download
- name: Build and run tests with race detector enabled
run: just test-race
run: just test-race
3 changes: 0 additions & 3 deletions .github/workflows/govulncheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ jobs:
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Install dependencies
run: |
go mod download
- id: govulncheck
uses: golang/govulncheck-action@v1
with:
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ jobs:
- name: Build and run tests
run: just build

- name: Build and cache cloud-provider-kind image
uses: ./.github/actions/cache-cloud-provider-kind-image

- name: Install kind
run: just install-kind

Expand Down Expand Up @@ -64,9 +61,6 @@ jobs:

- name: Build and run tests
run: just build

- name: Build and cache cloud-provider-kind image
uses: ./.github/actions/cache-cloud-provider-kind-image

- name: Build and install test plugin
run: just install-test-plugin
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Release Drafter
on:
push:
branches:
- main
pull_request:
types: [opened, reopened, synchronize]
permissions:
contents: read
jobs:
update_release_draft:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v6
with:
config-name: release-drafter-config.yml
publish: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: pre-release-binaries
on:
push:
tags:
- "v*.*.*"

jobs:
publish:
name: Build and Publish
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
strategy:
matrix:
goos: [linux, darwin]
goarch: [amd64, arm64]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build
run: |
mkdir -p dist
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o dist/cofidectl-${{ matrix.goos }}-${{ matrix.goarch }}-${{ github.ref_name }} ./cmd/cofidectl/main.go
- name: Upload artifacts
run: |
gh release list --limit 1 | grep -q ${{ github.ref_name }} || gh release create ${{ github.ref_name }} -d
gh release upload ${{ github.ref_name }} dist/cofidectl-${{ matrix.goos }}-${{ matrix.goarch }} --clobber
gh release upload ${{ github.ref_name }} LICENSE --clobber
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/cofide/cofidectl

go 1.23.0

toolchain go1.23.4
toolchain go1.23.6

require (
buf.build/go/protoyaml v0.3.1
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/create-kind-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ DELETE_EXISTING_KIND_CLUSTER=${DELETE_EXISTING_KIND_CLUSTER:-true}

K8S_CLUSTER_NAME=${K8S_CLUSTER_NAME:-local1}

CLOUD_PROVIDER_KIND_CONTAINER_NAME=cloud-provider-kind-cloud-provider-1
CLOUD_PROVIDER_KIND_CONTAINER_NAME=cloud-provider-kind

function delete_kind_cluster() {
cluster=$(kind get clusters | egrep "\b${K8S_CLUSTER_NAME}\b" || true)
Expand Down
17 changes: 8 additions & 9 deletions tests/integration/install-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,13 @@ function ensure_kind_network() {
fi
}

function install_cloud_provider_kind() {
# https://github.com/kubernetes-sigs/cloud-provider-kind
if [[ ! -d cloud-provider-kind ]]; then
git clone --depth 1 https://github.com/kubernetes-sigs/cloud-provider-kind
fi
pushd cloud-provider-kind
sudo bash -c 'NET_MODE=kind docker compose up -d'
popd
function run_cloud_provider_kind() {
docker run -d \
--network kind \
--restart unless-stopped \
--name cloud-provider-kind \
-v /var/run/docker.sock:/var/run/docker.sock \
registry.k8s.io/cloud-provider-kind/cloud-controller-manager:v0.5.0
}

function check_non_root_docker_access() {
Expand All @@ -82,7 +81,7 @@ function main() {
install_kind
set_inotify_limits_for_kind
ensure_kind_network
install_cloud_provider_kind
run_cloud_provider_kind
echo "Success!"
check_non_root_docker_access
}
Expand Down

0 comments on commit 249bcb8

Please sign in to comment.