Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Use devbox instead of asdf #159

Merged
merged 1 commit into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
106 changes: 61 additions & 45 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/[email protected]

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

- name: Annotate tests
if: always()
Expand All @@ -49,82 +55,92 @@ 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

- 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: Install devbox
uses: jetpack-io/[email protected]

- 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/[email protected]

- 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/[email protected]

- 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
id: verify-changed-files

- name: Fail if files have changed
if: steps.verify-changed-files.outputs.files_changed == 'true'
run: |
echo "Changed files: ${{ steps.verify-changed-files.outputs.changed_files }}"
exit 1
run: git diff --exit-code

pre-commit:
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

- 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/[email protected]

- uses: mfinelli/setup-shfmt@v2
- name: Set up pre-commit cache
uses: actions/cache@v3
with:
shfmt-version: ${{ fromJson(steps.versions.outputs.tools).shfmt }}

- name: Install asdf
uses: asdf-vm/actions/setup@v2
path: ~/.cache/pre-commit
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}

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

- uses: pre-commit/[email protected]
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/[email protected]

- 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/[email protected]

- 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/[email protected]
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/[email protected]
gotest.tools/[email protected]
github.com/segmentio/[email protected]
github.com/google/go-containerregistry/cmd/[email protected]
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