Skip to content

Commit

Permalink
build: Try devbox instead of devenv
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmidyson committed Jul 19, 2023
1 parent 1ebe724 commit eb4ee9d
Show file tree
Hide file tree
Showing 12 changed files with 251 additions and 281 deletions.
8 changes: 5 additions & 3 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
strict_env
# Automatically sets up your devbox environment whenever you cd into this
# directory via our direnv integration:

source_url "https://raw.githubusercontent.com/cachix/devenv/v0.6.2/direnvrc" "sha256-YBzqskFZxmNb3kYVoKD9ZixoPXJh1C9ZvTLGFRkauZ0="
eval "$(devbox generate direnv --print-envrc)"

use devenv
# check out https://www.jetpack.io/devbox/docs/ide_configuration/direnv/
# for more details
16 changes: 12 additions & 4 deletions .github/workflows/checks-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,21 @@ jobs:
- name: Check out code
uses: actions/checkout@v3

- name: Set up devenv.sh environment
uses: d2iq-labs/devenv.sh-action@v1
# 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]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
enable-cache: true
env:
NIX_USER_COUNT: 4

- name: Build
run: make SKIP_UPX=false build-snapshot
run: devbox run -- make SKIP_UPX=false build-snapshot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down
73 changes: 55 additions & 18 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,21 @@ jobs:
- name: Check out code
uses: actions/checkout@v3

- name: Set up devenv.sh environment
uses: d2iq-labs/devenv.sh-action@v1
# 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]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
enable-cache: true
env:
NIX_USER_COUNT: 4

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

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
Expand All @@ -52,18 +60,26 @@ jobs:
with:
fetch-depth: 0

- name: Set up devenv.sh environment
uses: d2iq-labs/devenv.sh-action@v1
# 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]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
enable-cache: true
env:
NIX_USER_COUNT: 4

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: arm64

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

Expand All @@ -81,15 +97,23 @@ jobs:
- name: Check out code
uses: actions/checkout@v3

- name: Set up devenv.sh environment
uses: d2iq-labs/devenv.sh-action@v1
# 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]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
enable-cache: true
env:
NIX_USER_COUNT: 4

- name: Export golang and golangci-lint versions
run: |
echo "GOLANGCI_LINT_VERSION=v$(golangci-lint version --format short)" >>$GITHUB_ENV
echo "GO_VERSION=$(go version | grep -o "[[:digit:]]\+.[[:digit:]]\+\(.[[:digit:]]\+\)\?")" >>$GITHUB_ENV
echo "GOLANGCI_LINT_VERSION=v$(devbox run -- golangci-lint version --format short)" >>$GITHUB_ENV
echo "GO_VERSION=$(devbox run -- go version | grep -o "[[:digit:]]\+.[[:digit:]]\+\(.[[:digit:]]\+\)\?")" >>$GITHUB_ENV
- name: golangci-lint
uses: reviewdog/action-golangci-lint@v2
Expand All @@ -105,13 +129,26 @@ jobs:
- name: Check out code
uses: actions/checkout@v3

- name: Set up devenv.sh environment
uses: d2iq-labs/devenv.sh-action@v1
# 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]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
enable-cache: true
env:
NIX_USER_COUNT: 4

- 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
16 changes: 12 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,21 @@ jobs:
with:
languages: ${{ matrix.language }}

- name: Set up devenv.sh environment
uses: d2iq-labs/devenv.sh-action@v1
# 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]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
enable-cache: true
env:
NIX_USER_COUNT: 4

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

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
16 changes: 12 additions & 4 deletions .github/workflows/release-tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,18 @@ jobs:
ref: ${{ github.ref }}
fetch-depth: 0

- name: Set up devenv.sh environment
uses: d2iq-labs/devenv.sh-action@v1
# 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]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
enable-cache: true
env:
NIX_USER_COUNT: 4

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
Expand All @@ -35,6 +43,6 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Release
run: make release
run: devbox run -- make release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,3 @@ dist/

*.tar.gz
*.tar

# Devenv
.devenv*
devenv.local.nix
.direnv
35 changes: 3 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,38 +165,9 @@ or in a Kubernetes cluster.

## Contributing

This project uses <https://devenv.sh> to create a reproducible build environment. If you do not have `nix` ior `devenv`
configured, then the following instructions should work for you. For further details, see
<https://devenv.sh/getting-started/#installation> and <https://devenv.sh/automatic-shell-activation/>.

### Install `nix`

`devenv.sh` uses `nix` for creating reproducible build environments.

On Linux run:

```bash
sh <(curl -fsSL https://nixos.org/nix/install) --daemon --no-channel-add --daemon-user-count 6 --yes
```

On macOS run:

```bash
sh <(curl -fsSL https://nixos.org/nix/install) --no-channel-add --daemon-user-count 6 --yes
```

Restart your shell.

### Install `cachix`

`devenv.sh` recommends using `cachix` to speeds up the installation by providing binaries for packages.

```bash
nix-env -iA cachix -f https://cachix.org/api/v1/install
echo "trusted-users = root ${USER}" | sudo tee -a /etc/nix/nix.conf && sudo pkill nix-daemon
cachix use devenv
nix-env -if https://github.com/cachix/devenv/tarball/latest
```
This project uses <https://www.jetpack.io/devbox/> to create a reproducible build environment. If you do not have
`devbox` configured, then the following instructions should work for you. For further details, see
<https://www.jetpack.io/devbox/docs/installing_devbox/>.

### Integrate with `direnv` for automatic shell integration

Expand Down
33 changes: 33 additions & 0 deletions devbox.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"packages": [
"go@latest",
"bash@latest",
"coreutils@latest",
"crane@latest",
"findutils@latest",
"ginkgo@latest",
"git@latest",
"gnused@latest",
"gnugrep@latest",
"gnumake@latest",
"gojq@latest",
"golangci-lint@latest",
"golines@latest",
"goreleaser@latest",
"gotestsum@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 eb4ee9d

Please sign in to comment.