Skip to content

Commit

Permalink
build: Use devbox instead of asdf
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmidyson committed Jul 20, 2023
1 parent 9ed8cef commit f95c297
Show file tree
Hide file tree
Showing 18 changed files with 253 additions and 166 deletions.
12 changes: 7 additions & 5 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
strict_env
source_env_if_exists .envrc.local-asdf
use_asdf
PATH_add .local/bin
source_env_if_exists .envrc.local
# Automatically sets up your devbox environment whenever you cd into this
# directory via our direnv integration:

eval "$(devbox generate direnv --print-envrc)"

# check out https://www.jetpack.io/devbox/docs/ide_configuration/direnv/
# for more details
97 changes: 60 additions & 37 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,17 @@ jobs:
- name: Check out code
uses: actions/checkout@v3

- name: Install asdf
uses: asdf-vm/actions/setup@v2
# Setup github authentication to ensure Github's rate limits are not hit.
- name: Configure nix GitHub access-tokens
run: |
mkdir -p ~/.config/nix
echo "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" >>~/.config/nix/nix.conf
- name: Install devbox
uses: jetpack-io/devbox-install-action@v0.4.0

- name: Run unit tests
run: make test
run: devbox run -- make test

- name: Annotate tests
if: always()
Expand All @@ -49,43 +55,66 @@ jobs:
with:
files: "test/e2e/**/*.go"

- name: Install asdf
if: steps.check_e2e_files.outputs.files_exists == 'true'
uses: asdf-vm/actions/setup@v2
# Setup github authentication to ensure Github's rate limits are not hit.
- if: steps.check_e2e_files.outputs.files_exists == 'true'
name: Configure nix GitHub access-tokens
run: |
mkdir -p ~/.config/nix
echo "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" >>~/.config/nix/nix.conf
- if: steps.check_e2e_files.outputs.files_exists == 'true'
name: Install devbox
uses: jetpack-io/devbox-install-action@v0.4.0

- name: Run e2e tests
if: steps.check_e2e_files.outputs.files_exists == 'true'
run: make e2e-test
- if: steps.check_e2e_files.outputs.files_exists == 'true'
name: Run e2e tests
run: devbox run -- make e2e-test

lint:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Gather tool versions
uses: jimmidyson/asdf-parse-tool-versions@v2
id: versions
# Setup github authentication to ensure Github's rate limits are not hit.
- name: Configure nix GitHub access-tokens
run: |
mkdir -p ~/.config/nix
echo "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" >>~/.config/nix/nix.conf
- name: Install devbox
uses: jetpack-io/devbox-install-action@v0.4.0

- name: Collect tool versions
run: |
echo GO_VERSION="$(devbox run -- go version | cut -d' ' -f 3 | grep -o '[0-9.]\+')" >>"${GITHUB_ENV}"
echo GOLANGCI_LINT_VERSION="$(devbox run -- golangci-lint version --format short)" >>"${GITHUB_ENV}"
- name: golangci-lint
uses: reviewdog/action-golangci-lint@v2
with:
fail_on_error: true
reporter: github-pr-review
go_version: ${{ fromJson(steps.versions.outputs.tools).golang }}
golangci_lint_version: v${{ fromJson(steps.versions.outputs.tools).golangci-lint }}
go_version: ${{ env.GO_VERSION }}
golangci_lint_version: v${{ env.GOLANGCI_LINT_VERSION }}

generated:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Install asdf
uses: asdf-vm/actions/setup@v2
# Setup github authentication to ensure Github's rate limits are not hit.
- name: Configure nix GitHub access-tokens
run: |
mkdir -p ~/.config/nix
echo "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" >>~/.config/nix/nix.conf
- name: Install devbox
uses: jetpack-io/devbox-install-action@v0.4.0

- name: Check generated files
run: make go-generate
run: devbox run -- make go-generate

- name: Verify no changed files
uses: tj-actions/verify-changed-files@v16
Expand All @@ -103,28 +132,22 @@ jobs:
- name: Check out code
uses: actions/checkout@v3

- name: Gather tool versions
uses: jimmidyson/asdf-parse-tool-versions@v2
id: versions
# Setup github authentication to ensure Github's rate limits are not hit.
- name: Configure nix GitHub access-tokens
run: |
mkdir -p ~/.config/nix
echo "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" >>~/.config/nix/nix.conf
- uses: actions/setup-go@v4
with:
go-version: ${{ fromJson(steps.versions.outputs.tools).golang }}
check-latest: false
cache: true
- name: Install devbox
uses: jetpack-io/devbox-install-action@v0.4.0

- uses: mfinelli/setup-shfmt@v2
- name: Set up pre-commit cache
uses: actions/cache@v3
with:
shfmt-version: ${{ fromJson(steps.versions.outputs.tools).shfmt }}
path: ~/.cache/pre-commit
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}

- name: Install asdf
uses: asdf-vm/actions/setup@v2

- name: Install helm-docs
run: make install-tool.helm-docs

- uses: pre-commit/action@v3.0.0
with:
extra_args: --all-files --show-diff-on-failure
- name: Run pre-commit
run: devbox run -- make pre-commit
env:
SKIP: no-commit-to-branch,golangci-lint,go-generate
SKIP: no-commit-to-branch,golangci-lint
14 changes: 10 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,22 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

# Setup github authentication to ensure Github's rate limits are not hit.
- name: Configure nix GitHub access-tokens
run: |
mkdir -p ~/.config/nix
echo "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" >>~/.config/nix/nix.conf
- name: Install devbox
uses: jetpack-io/devbox-install-action@v0.4.0

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}

- name: Install tools via asdf
uses: asdf-vm/actions/install@v2

- name: Build
run: make build-snapshot
run: devbox run -- make build-snapshot

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
17 changes: 0 additions & 17 deletions .github/workflows/recover-secret.yaml

This file was deleted.

25 changes: 16 additions & 9 deletions .github/workflows/release-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,36 @@ jobs:
with:
fetch-depth: 0

# Setup github authentication to ensure Github's rate limits are not hit.
- if: ${{ steps.release-please.outputs.release_created }}
name: Install tools via asdf
uses: asdf-vm/actions/install@v2
name: Configure nix GitHub access-tokens
run: |
mkdir -p ~/.config/nix
echo "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" >>~/.config/nix/nix.conf
- if: ${{ steps.release-please.outputs.release_created }}
name: Install devbox
uses: jetpack-io/devbox-install-action@v0.4.0

- if: ${{ steps.release-please.outputs.release_created }}
name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- if: ${{ steps.release-please.outputs.release_created }}
name: Release
run: make release
run: devbox run -- make release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- if: ${{ steps.release-please.outputs.release_created }}
- if: ${{ steps.release-please.outputs.release_created }}
name: Publish Helm chart
uses: stefanprodan/helm-gh-pages@v1.7.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
app_version: ${{ steps.release-please.outputs.tag_name }}
chart_version: ${{ steps.release-please.outputs.tag_name }}
token: ${{ secrets.GITHUB_TOKEN }}
app_version: ${{ steps.release-please.outputs.tag_name }}
chart_version: ${{ steps.release-please.outputs.tag_name }}
target_dir: repo
3 changes: 0 additions & 3 deletions .go-tools
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
github.com/oligot/go-mod-upgrade@v0.9.1
gotest.tools/gotestsum@v1.10.0
github.com/segmentio/golines@v0.11.0
github.com/google/go-containerregistry/cmd/crane@v0.15.2
16 changes: 0 additions & 16 deletions .tool-versions

This file was deleted.

4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,3 @@
REPO_ROOT := $(CURDIR)

include make/all.mk

ASDF_VERSION=v0.10.2

CI_DOCKER_BUILD_ARGS=ASDF_VERSION=$(ASDF_VERSION)
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package v1alpha1

//go:generate controller-gen object paths=.
//go:generate bash -ec "cd ../../.. && defaulter-gen -h hack/boilerplate.go.txt -i ./apis/config/v1alpha1 -o ."
//go:generate bash -ec "cd ../../.. && defaulter-gen -h hack/boilerplate.go.txt -i ./apis/config/v1alpha1 -o ../../../"

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
32 changes: 32 additions & 0 deletions devbox.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"packages": [
"clusterctl@latest",
"crane@latest",
"ginkgo@latest",
"go@latest",
"gojq@latest",
"golangci-lint@latest",
"golines@latest",
"google-cloud-sdk@latest",
"goreleaser@latest",
"gotestsum@latest",
"helm-docs@latest",
"kubebuilder@latest",
"kubernetes-code-generator@latest",
"kubernetes-controller-tools@latest",
"kubernetes-helm@latest",
"pre-commit@latest",
"shfmt@latest",
"upx@latest"
],
"shell": {
"init_hook": [
"echo 'Welcome to devbox!' > /dev/null"
],
"scripts": {
"test": [
"echo \"Error: no test specified\" && exit 1"
]
}
}
}
Loading

0 comments on commit f95c297

Please sign in to comment.