Skip to content

build: Use devbox instead of asdf #96

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

Merged
merged 12 commits into from
Aug 2, 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
14 changes: 5 additions & 9 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
strict_env
# Automatically sets up your devbox environment whenever you cd into this
# directory via our direnv integration:

source_env_if_exists .envrc.local-asdf
eval "$(devbox generate direnv --print-envrc)"

use asdf

PATH_add .local/bin

source_env_if_exists envrc.local

command -v yamale &>/dev/null || pip install yamale
# check out https://www.jetpack.io/devbox/docs/ide_configuration/direnv/
# for more details
142 changes: 73 additions & 69 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ jobs:
- name: Check out code
uses: actions/checkout@v3

- name: Install asdf
uses: asdf-vm/actions/setup@v2
- name: Install devbox
uses: jetpack-io/[email protected]
with:
asdf_branch: v0.11.3
enable-cache: true

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

- name: Annotate tests
if: always()
Expand All @@ -48,76 +48,97 @@ jobs:
with:
fetch-depth: 0

- name: Install asdf
uses: asdf-vm/actions/setup@v2
- name: Install devbox
uses: jetpack-io/[email protected]
with:
asdf_branch: v0.11.3
enable-cache: true

- name: Build and install on KinD
run: make dev.run-on-kind
run: devbox run -- make dev.run-on-kind
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run e2e tests
run: make e2e-test
run: devbox run -- make e2e-test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Cleanup KinD cluster
if: always()
run: make kind.delete
run: devbox run -- make kind.delete

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

- name: Gather tool versions
uses: endorama/asdf-parse-tool-versions@v1
- name: Install devbox
uses: jetpack-io/[email protected]
with:
enable-cache: true

- name: Export golang and golangci-lint versions
id: versions
run: |
echo "golangci-lint=$(devbox run -- golangci-lint version --format short)" >>"${GITHUB_OUTPUT}"
echo "golang=$(devbox run -- go version | grep -o "[[:digit:]]\+.[[:digit:]]\+\(.[[:digit:]]\+\)\?")" >>"${GITHUB_OUTPUT}"

- name: golangci-lint
uses: reviewdog/action-golangci-lint@v2
with:
fail_on_error: true
reporter: github-pr-review
golangci_lint_version: v${{ fromJson(steps.versions.outputs.tools).golangci-lint }}
go_version: v${{ fromJson(steps.versions.outputs.tools).golang }}
golangci_lint_version: v${{ steps.versions.outputs.golangci-lint }}
go_version: v${{ steps.versions.outputs.golang }}

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

- name: Gather tool versions
uses: endorama/asdf-parse-tool-versions@v1
id: versions

- uses: actions/setup-go@v4
- name: actionlint
uses: reviewdog/action-actionlint@v1
with:
go-version: ${{ fromJson(steps.versions.outputs.tools).golang }}
check-latest: false
cache: true
fail_on_error: true
reporter: github-pr-review

- uses: mfinelli/setup-shfmt@v2
lint-dockerfile:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v3

- name: actionlint
uses: reviewdog/action-hadolint@v1
with:
shfmt-version: ${{ fromJson(steps.versions.outputs.tools).shfmt }}
fail_on_error: true
reporter: github-pr-review

- name: Install asdf
uses: asdf-vm/actions/setup@v2
pre-commit:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v3
with:
asdf_branch: v0.11.3
ref: ${{ github.event.pull_request.head.sha }}

- name: Install helm-docs
run: make install-tool.helm-docs
- name: Install devbox
uses: jetpack-io/[email protected]
with:
enable-cache: true

- uses: pre-commit/[email protected]
- name: Set up pre-commit cache
uses: actions/cache@v3
with:
extra_args: --all-files --show-diff-on-failure
path: ~/.cache/pre-commit
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}

- name: Run pre-commit
run: devbox run -- make pre-commit
env:
SKIP: no-commit-to-branch,golangci-lint
SKIP: no-commit-to-branch,golangci-lint,actionlint-system

lint-test-helm:
runs-on: ubuntu-22.04
Expand All @@ -127,70 +148,53 @@ jobs:
with:
fetch-depth: 0

- name: Gather tool versions
uses: endorama/asdf-parse-tool-versions@v1
id: versions

- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: v${{ fromJson(steps.versions.outputs.tools).helm }}

- uses: actions/setup-python@v4
- name: Install devbox
uses: jetpack-io/[email protected]
with:
python-version: '3.10'
check-latest: true

- name: Set up chart-testing
uses: helm/chart-testing-action@v2
with:
version: v${{ fromJson(steps.versions.outputs.tools).helm-ct }}
yamllint_version: ${{ fromJson(steps.versions.outputs.tools).yamllint }}
enable-cache: true

- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }})
git fetch origin main:main
changed=$(devbox run -- ct list-changed --target-branch ${{ github.event.repository.default_branch }})
if [[ -n "$changed" ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
fi

- if: steps.list-changed.outputs.changed == 'true'
name: Run chart-testing (lint)
run: ct lint --config charts/ct-config.yaml
run: devbox run -- ct lint --config charts/ct-config.yaml

- if: steps.list-changed.outputs.changed == 'true'
name: Create kind cluster
uses: helm/kind-action@v1
with:
version: v${{ fromJson(steps.versions.outputs.tools).kind }}
kubectl_version: v${{ fromJson(steps.versions.outputs.tools).kubectl }}
node_image: ghcr.io/mesosphere/kind-node:v${{ fromJson(steps.versions.outputs.tools).kubectl }}
run: |
devbox run -- kind create cluster \
--image=ghcr.io/mesosphere/kind-node:"$(kubectl version --output=json --client | gojq --raw-output .clientVersion.gitVersion)" \
--name=chart-testing
env:
KUBECONFIG: ct-kind-kubeconfig

- if: steps.list-changed.outputs.changed == 'true'
name: Install asdf
uses: asdf-vm/actions/setup@v2
with:
asdf_branch: v0.11.3

- if: steps.list-changed.outputs.changed == 'true'
name: Build Docker images
run: make release-snapshot
run: devbox run -- make release-snapshot

- if: steps.list-changed.outputs.changed == 'true'
name: Sideload docker image
run: kind load docker-image --name chart-testing "$(jq -r '.[] | select(.type == "Docker Image" and .goos == "linux" and .goarch == "amd64").name' dist/artifacts.json)"
run: devbox run -- kind load docker-image --name chart-testing "$(jq -r '.[] | select(.type == "Docker Image" and .goos == "linux" and .goarch == "amd64").name' dist/artifacts.json)"

- if: steps.list-changed.outputs.changed == 'true'
name: Setup Cluster API and cert-manager
run: make clusterctl.init
run: devbox run -- make clusterctl.init
env:
KIND_KUBECONFIG: ct-kind-kubeconfig

- if: steps.list-changed.outputs.changed == 'true'
name: Run chart-testing (install)
run: ct install --config charts/ct-config.yaml --helm-extra-set-args "--set=image.tag=$(jq -r .version dist/metadata.json)"
run: devbox run -- ct install --config charts/ct-config.yaml --helm-extra-set-args "--set=image.tag=$(jq -r .version dist/metadata.json)"
env:
KUBECONFIG: ct-kind-kubeconfig

- if: steps.list-changed.outputs.changed == 'true' && always()
name:
run: devbox run -- kind delete cluster --name chart-testing || true
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ jobs:
with:
languages: ${{ matrix.language }}

- name: Install tools via asdf
uses: asdf-vm/actions/install@master
- name: Install devbox
uses: jetpack-io/devbox-install[email protected]
with:
asdf_branch: v0.11.3
enable-cache: true

- 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.

59 changes: 9 additions & 50 deletions .github/workflows/release-please.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ on:
branches:
- main

permissions:
contents: write
pull-requests: write
actions: write

jobs:
release-please:
runs-on: ubuntu-22.04
Expand All @@ -21,54 +26,8 @@ jobs:
changelog-notes-type: github

- if: ${{ steps.release-please.outputs.release_created }}
uses: actions/checkout@v3
with:
fetch-depth: 0

- if: ${{ steps.release-please.outputs.release_created }}
name: Fetch all tags
run: git fetch --force --tags

- if: ${{ steps.release-please.outputs.release_created }}
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- if: ${{ steps.release-please.outputs.release_created }}
name: Gather tool versions
uses: endorama/asdf-parse-tool-versions@v1
id: versions

- 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 }}

- if: ${{ steps.release-please.outputs.release_created }}
name: Install go
uses: actions/setup-go@v4
with:
go-version: ${{ fromJson(steps.versions.outputs.tools).golang }}
check-latest: false
cache: true

- if: ${{ steps.release-please.outputs.release_created }}
name: Run goreleaser
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: ${{ fromJson(steps.versions.outputs.tools).goreleaser }}
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- if: ${{ steps.release-please.outputs.release_created }}
name: Publish Helm chart
uses: stefanprodan/[email protected]
name: Run release workflow
uses: benc-uk/workflow-dispatch@v121
with:
token: ${{ secrets.GITHUB_TOKEN }}
app_version: ${{ steps.release-please.outputs.tag_name }}
chart_version: ${{ steps.release-please.outputs.tag_name }}
target_dir: repo
workflow: release-tag.yaml
ref: ${{ steps.release-please.outputs.tag_name }}
Loading