diff --git a/.envrc b/.envrc index 84fc8e53614..eff60eb12cf 100644 --- a/.envrc +++ b/.envrc @@ -1,7 +1,9 @@ +#!/bin/bash + # 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/ +# check out https://www.jetify.com/docs/devbox/ide_configuration/direnv/ # for more details diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000000..1c229604765 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,9 @@ +*.go diff=golang +*.sh diff=bash +*.md diff=markdown +*.py diff=python +*.sql diff=sql + +devbox.json linguist-language=json5 + +go.sum -diff linguist-generated diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index c772a8dd068..7f24327e4ec 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,3 +1,14 @@ ## Summary ## How was it tested? + +## Community Contribution License + +All community contributions in this pull request are licensed to the project +maintainers under the terms of the +[Apache 2 License](https://www.apache.org/licenses/LICENSE-2.0). + +By creating this pull request, I represent that I have the right to license the +contributions to the project maintainers under the Apache 2 License as stated in +the +[Community Contribution License](https://github.com/jetify-com/opensource/blob/main/CONTRIBUTING.md#community-contribution-license). diff --git a/.github/workflows/cache-upload.yml b/.github/workflows/cache-upload.yml new file mode 100644 index 00000000000..be488dfb369 --- /dev/null +++ b/.github/workflows/cache-upload.yml @@ -0,0 +1,64 @@ +name: cache-upload +# Uploads devbox nix dependencies to cache + +on: + push: + branches: + - main + workflow_dispatch: + schedule: + - cron: '30 8 * * *' # Run nightly at 8:30 UTC + +permissions: + contents: read + pull-requests: read + +defaults: + run: + shell: bash + +env: + DEVBOX_API_TOKEN: ${{ secrets.DEVBOX_API_TOKEN }} + DEVBOX_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DEVBOX_DEBUG: 1 + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # I think this should be added to individual nix commands within devbox, but this is quick fix for now + NIX_CONFIG: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + +jobs: + upload-cache: + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + + # Build devbox from scratch because released devbox has a bug that prevents + # DEVBOX_API_TOKEN use + # we can remove this after 0.10.6 is out. + - uses: actions/setup-go@v5 + with: + go-version-file: ./go.mod + - name: Build devbox + run: | + go build -o dist/devbox ./cmd/devbox + sudo mv ./dist/devbox /usr/local/bin/ + + # - name: Install devbox + # uses: jetify-com/devbox-install-action@v0.13.0 + # with: + # enable-cache: true + + # We upload twice, once before updating and once after. This shows a simple + # method to cache the latest current and latest dependencies. + # If we want read access to cache on multi-user nix installs (e.g. macos), + # we need to call devbox cache configure. This is currently not working + # as expected on CICD. + - name: Upload cache + run: | + devbox cache upload + devbox update + devbox cache upload diff --git a/.github/workflows/cli-release.yml b/.github/workflows/cli-release.yml index c9d699a014c..b4fb51419e8 100644 --- a/.github/workflows/cli-release.yml +++ b/.github/workflows/cli-release.yml @@ -26,10 +26,6 @@ permissions: jobs: tests: uses: ./.github/workflows/cli-tests.yaml - with: - # This will run the basic testscript unit tests on MacOS. - # NOTE: cli-tests will NEVER run project-tests on MacOS. - run-mac-tests: true report-test-failures: runs-on: ubuntu-latest @@ -54,7 +50,7 @@ jobs: if: ${{ inputs.create_edge_release || github.event.schedule }} steps: - name: Checkout source code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 # Needed by goreleaser to browse history. - name: Determine edge tag @@ -68,15 +64,15 @@ jobs: custom_tag: ${{ env.EDGE_TAG }} tag_prefix: "" - name: Set up go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version-file: ./go.mod - name: Build snapshot with goreleaser - uses: goreleaser/goreleaser-action@v3 + uses: goreleaser/goreleaser-action@v6 with: distribution: goreleaser version: latest - args: release --rm-dist --skip-publish --skip-announce --snapshot + args: release --clean --skip=announce,publish --snapshot env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} TELEMETRY_KEY: ${{ secrets.TELEMETRY_KEY }} @@ -120,11 +116,11 @@ jobs: if: startsWith(github.ref, 'refs/tags/') steps: - name: Checkout source code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 # Needed by goreleaser to browse history. - name: Set up go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version-file: ./go.mod - name: Create Sentry release @@ -142,7 +138,7 @@ jobs: with: distribution: goreleaser version: latest - args: release --rm-dist + args: release --clean env: DISCORD_WEBHOOK_ID: ${{ secrets.DISCORD_WEBHOOK_ID }} DISCORD_WEBHOOK_TOKEN: ${{ secrets.DISCORD_WEBHOOK_TOKEN }} diff --git a/.github/workflows/cli-tests.yaml b/.github/workflows/cli-tests.yaml index c7b9b8d24d3..dfab5ba06a1 100644 --- a/.github/workflows/cli-tests.yaml +++ b/.github/workflows/cli-tests.yaml @@ -25,6 +25,8 @@ on: example-debug: type: boolean description: Run example tests with DEVBOX_DEBUG=1 to increase verbosity + schedule: + - cron: '30 8 * * *' # Run nightly at 8:30 UTC permissions: contents: read @@ -37,30 +39,31 @@ defaults: shell: bash env: - HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DEVBOX_DEBUG: 1 DEVBOX_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} HOMEBREW_NO_ANALYTICS: 1 HOMEBREW_NO_AUTO_UPDATE: 1 HOMEBREW_NO_EMOJI: 1 HOMEBREW_NO_ENV_HINTS: 1 HOMEBREW_NO_INSTALL_CLEANUP: 1 - DEVBOX_DEBUG: 1 jobs: build-devbox: strategy: matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, macos-13] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 with: go-version-file: ./go.mod - name: Build devbox run: go build -o dist/devbox ./cmd/devbox - name: Upload devbox artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: devbox-${{ runner.os }}-${{ runner.arch }} path: ./dist/devbox @@ -71,34 +74,43 @@ jobs: if: github.ref != 'refs/heads/main' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: crate-ci/typos@v1.16.26 + flake-test: + name: Test Flake Build + if: github.ref != 'refs/heads/main' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install devbox + uses: jetify-com/devbox-install-action@v0.13.0 + with: + enable-cache: true + - name: Build flake + run: | + if ! devbox run build-flake; then + echo "::warning::If this fails, you probably have to run 'devbox run update-hash'" + exit 1 + fi + - run: ./result/bin/devbox version + golangci-lint: - needs: build-devbox strategy: matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, macos-13] runs-on: ${{ matrix.os }} timeout-minutes: 10 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - # We can remove this once we fix nix golangci-lint issue and move to devbox - - uses: actions/setup-go@v4 + - name: Install devbox + uses: jetify-com/devbox-install-action@v0.13.0 with: - go-version-file: ./go.mod - cache: false - - # This can be reanabled once released version supports runx - # and we can remove needs: build-devbox - # - name: Install devbox - # uses: jetpack-io/devbox-install-action@v0.7.0 - # with: - # enable-cache: true + enable-cache: true - name: Mount golang cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ~/.cache/golangci-lint @@ -106,15 +118,6 @@ jobs: ~/go/pkg key: go-${{ runner.os }}-${{ hashFiles('go.sum') }} - - name: Download devbox - uses: actions/download-artifact@v3 - with: - name: devbox-${{ runner.os }}-${{ runner.arch }} - - name: Add devbox to path - run: | - chmod +x ./devbox - sudo mv ./devbox /usr/local/bin/ - - run: devbox run lint test: @@ -123,43 +126,32 @@ jobs: matrix: is-main: - ${{ github.ref == 'refs/heads/main' && 'is-main' || 'not-main' }} - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, macos-13] # This is an optimization that runs tests twice, with and without # the devbox.json tests. We can require the other tests to complete before # merging, while keeping the others as an additional non-required signal - run-project-tests: ["project-tests", "project-tests-off"] + run-project-tests: ["project-tests-only", "project-tests-off"] # Run tests on: # 1. the oldest supported nix version (which is 2.9.0? But determinate-systems installer has 2.12.0) # 2. nix 2.19.2: version before nix profile changes # 2. latest nix version (note, 2.20.1 introduced a new profile change) - nix-version: ["2.12.0", "2.19.2", "2.20.1"] + nix-version: ["2.12.0", "2.19.2", "2.30.2"] exclude: - - is-main: "not-main" - os: "${{ inputs.run-mac-tests && 'dummy' || 'macos-latest' }}" - - is-main: "is-main" - run-project-tests: "project-tests-off" - - run-project-tests: "project-tests" - os: "${{ inputs.run-mac-tests && 'dummy' || 'macos-latest' }}" + # Only runs tests on macos if explicitly requested, or on a schedule + - os: "${{ (inputs.run-mac-tests || github.event.schedule != '') && 'dummy' || 'macos-13' }}" + runs-on: ${{ matrix.os }} timeout-minutes: 60 + env: + # For devbox.json tests, we default to non-debug mode since the debug output is less useful than for unit testscripts. + # But we allow overriding via inputs.example-debug + DEVBOX_DEBUG: ${{ (matrix.run-project-tests == 'project-tests-off' || inputs.example-debug) && '1' || '0' }} + DEVBOX_GOLANG_TEST_TIMEOUT: "${{ (github.ref == 'refs/heads/main' || inputs.run-mac-tests) && '1h' || '30m' }}" steps: - - name: Maximize build disk space - uses: easimon/maximize-build-space@v8 - if: matrix.os == 'ubuntu-latest' - with: - root-reserve-mb: 32768 - temp-reserve-mb: 10000 - remove-dotnet: true - remove-android: true - remove-haskell: true - remove-codeql: true - - uses: actions/checkout@v3 - - uses: actions/setup-go@v4 - with: - go-version-file: ./go.mod + - uses: actions/checkout@v4 - name: Mount golang cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ~/.cache/go-build @@ -174,20 +166,12 @@ jobs: brew update brew install dash zsh fi - - name: Install Nix - uses: DeterminateSystems/nix-installer-action@v4 + - name: Install devbox + uses: jetify-com/devbox-install-action@v0.13.0 with: - logger: pretty - extra-conf: experimental-features = ca-derivations fetch-closure - nix-package-url: https://releases.nixos.org/nix/nix-${{ matrix.nix-version }}/nix-${{ matrix.nix-version }}-${{ runner.arch == 'X64' && 'x86_64' || 'aarch64' }}-${{ runner.os == 'macOS' && 'darwin' || 'linux' }}.tar.xz - - name: Run tests - env: - # For devbox.json tests, we default to non-debug mode since the debug output is less useful than for unit testscripts. - # But we allow overriding via inputs.example-debug - DEVBOX_DEBUG: ${{ (matrix.run-project-tests == 'project-tests-off' || inputs.example-debug) && '1' || '0' }} - DEVBOX_RUN_PROJECT_TESTS: ${{ matrix.run-project-tests == 'project-tests' && '1' || '0' }} - # Used in `go test -timeout` flag. Needs a value that time.ParseDuration can parse. - DEVBOX_GOLANG_TEST_TIMEOUT: "${{ (github.ref == 'refs/heads/main' || inputs.run-mac-tests) && '1h' || '30m' }}" + enable-cache: true + - name: Run fast tests + if: matrix.run-project-tests == 'project-tests-off' run: | echo "::group::Nix version" nix --version @@ -198,18 +182,22 @@ jobs: echo "::group::Resolved Nix config" nix show-config --extra-experimental-features nix-command echo "::endgroup::" - go test -v -timeout $DEVBOX_GOLANG_TEST_TIMEOUT ./... + devbox run go test -v -timeout $DEVBOX_GOLANG_TEST_TIMEOUT ./... + - name: Run project (slow) tests + if: matrix.run-project-tests == 'project-tests-only' + run: devbox run test-projects-only auto-nix-install: # ensure Devbox installs nix and works properly after installation. needs: build-devbox strategy: matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, macos-13] + use-detsys: [true, false] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Download devbox - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: devbox-${{ runner.os }}-${{ runner.arch }} - name: Add devbox to path @@ -219,6 +207,7 @@ jobs: - name: Install nix and devbox packages run: | export NIX_INSTALLER_NO_CHANNEL_ADD=1 + export DEVBOX_FEATURE_DETSYS_INSTALLER=${{ matrix.use-detsys }} # Setup github authentication to ensure Github's rate limits are not hit. # If this works, we can consider refactoring this into a reusable github action helper. @@ -230,18 +219,18 @@ jobs: run: devbox rm go # Run a sanity test to make sure Devbox can install and remove packages with - # the last 3 Nix releases. + # the last few Nix releases. test-nix-versions: needs: build-devbox strategy: matrix: - os: [ubuntu-latest, macos-latest] - nix-version: [2.15.1, 2.16.1, 2.17.0, 2.18.0, 2.19.2] + os: [ubuntu-latest, macos-13] + nix-version: [2.15.1, 2.16.1, 2.17.0, 2.18.0, 2.19.2, 2.24.7] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Download devbox - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: devbox-${{ runner.os }}-${{ runner.arch }} - name: Add devbox to path diff --git a/.github/workflows/debug.yaml b/.github/workflows/debug.yaml index 1df38780b21..4b777067d1e 100644 --- a/.github/workflows/debug.yaml +++ b/.github/workflows/debug.yaml @@ -9,7 +9,7 @@ on: default: "ubuntu-latest" type: choice options: - - macos-12 + - macos-latest - ubuntu-latest permissions: @@ -36,8 +36,8 @@ jobs: --show-error \ --silent \ | jq . - - uses: actions/checkout@v3 - - uses: actions/setup-go@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 with: go-version-file: ./go.mod - run: | diff --git a/.github/workflows/docker-image-release.yml b/.github/workflows/docker-image-release.yml index 115ec31ed2d..f96d0ee127c 100644 --- a/.github/workflows/docker-image-release.yml +++ b/.github/workflows/docker-image-release.yml @@ -1,15 +1,45 @@ name: docker-image-release -on: workflow_dispatch +on: + release: + types: + - published + workflow_dispatch: + inputs: + tag: + description: 'tag name' + required: true + default: '' + type: string jobs: docker-image-build-push: runs-on: ubuntu-latest steps: - name: Check out the repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up QEMU uses: docker/setup-qemu-action@v2 + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + jetpackio/devbox + tags: | + type=raw,value=${{ inputs.tag || github.ref_name }} + flavor: | + latest=false + - name: Docker meta root + id: metaroot + uses: docker/metadata-action@v5 + with: + images: | + jetpackio/devbox-root-user + tags: | + type=raw,value=${{ inputs.tag || github.ref_name }} + flavor: | + latest=false - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Login to Docker Hub @@ -18,18 +48,58 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - name: Build and push default - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 with: context: ./internal/devbox/generate/tmpl/ file: ./internal/devbox/generate/tmpl/DevboxImageDockerfile + build-args: | + DEVBOX_USE_VERSION=${{ inputs.tag || github.ref_name }} push: true platforms: linux/amd64,linux/arm64 - tags: jetpackio/devbox:latest + tags: ${{ steps.meta.outputs.tags }} - name: Build and push root user - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 + with: + context: ./internal/devbox/generate/tmpl/ + file: ./internal/devbox/generate/tmpl/DevboxImageDockerfileRootUser + build-args: | + DEVBOX_USE_VERSION=${{ inputs.tag || github.ref_name }} + push: true + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.metaroot.outputs.tags }} + - name: Docker meta latest + id: metalatest + uses: docker/metadata-action@v5 + with: + images: | + jetpackio/devbox + tags: | + type=raw,value=latest + flavor: | + latest=true + - name: Build and push latest + uses: docker/build-push-action@v5 + with: + context: ./internal/devbox/generate/tmpl/ + file: ./internal/devbox/generate/tmpl/DevboxImageDockerfile + push: true + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.metalatest.outputs.tags }} + - name: Docker meta root latest + id: metarootlatest + uses: docker/metadata-action@v5 + with: + images: | + jetpackio/devbox-root-user + tags: | + type=raw,value=latest + flavor: | + latest=true + - name: Build and push root user latest + uses: docker/build-push-action@v5 with: context: ./internal/devbox/generate/tmpl/ file: ./internal/devbox/generate/tmpl/DevboxImageDockerfileRootUser push: true platforms: linux/amd64,linux/arm64 - tags: jetpackio/devbox-root-user:latest + tags: ${{ steps.metarootlatest.outputs.tags }} diff --git a/.github/workflows/random-reviewer-assignment.yml b/.github/workflows/random-reviewer-assignment.yml new file mode 100644 index 00000000000..d4e505194bf --- /dev/null +++ b/.github/workflows/random-reviewer-assignment.yml @@ -0,0 +1,89 @@ +name: Random Reviewer Assignment +on: + pull_request: + types: [opened] + +permissions: + contents: read + pull-requests: write + +env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN_FOR_PR_ASSIGNMENT }} + +jobs: + assign-reviewer: + runs-on: ubuntu-latest + steps: + - name: Randomly assign reviewer from team + uses: actions/github-script@v6 + with: + script: | + const TRIAGE_USERNAME = 'Lagoja'; + const EXCLUDE_USERNAMES = ['jetpack-io-bot']; + + try { + const authenticatedUser = await github.rest.users.getAuthenticated(); + + const teamMembers = await github.rest.teams.listMembersInOrg({ + org: 'jetify-com', + team_slug: 'eng' + }); + + const prAuthor = context.payload.pull_request.user.login.toLowerCase(); + const prAuthorId = context.payload.pull_request.user.id; + const authenticatedUserLower = authenticatedUser.data.login.toLowerCase(); + + // If the PR author is already a member of the team, we can skip random assignment + const isPrAuthorInTeam = teamMembers.data.some(member => + member.login.toLowerCase() === prAuthor && member.id === prAuthorId + ); + + if (isPrAuthorInTeam) { + console.log(`PR author ${prAuthor} is already a team member, skipping random assignment.`); + return; + } + + // Get eligible reviewers (excluding PR author, authenticated user, and lagoja) + const eligibleReviewers = teamMembers.data + .filter(member => { + const loginLower = member.login.toLowerCase(); + + // Exclude authenticated user + const isNotAuthenticatedUser = member.id !== authenticatedUser.data.id; + const isNotTriage = loginLower !== TRIAGE_USERNAME.toLowerCase(); + const isNotExcludedUsername = !EXCLUDE_USERNAMES.includes(loginLower); + + return isNotAuthenticatedUser && isNotTriage && isNotExcludedUsername; + }) + .map(member => member.login); + + console.log(`Eligible reviewers: ${eligibleReviewers.join(', ')}`); + + if (eligibleReviewers.length === 0) { + console.log('No eligible reviewers found'); + return; + } + + const randomReviewer = eligibleReviewers[Math.floor(Math.random() * eligibleReviewers.length)]; + const reviewers = [randomReviewer]; + + // Only add TRIAGE_USERNAME if they're not the PR author and not the authenticated user + if (prAuthor !== TRIAGE_USERNAME.toLowerCase() && + authenticatedUserLower !== TRIAGE_USERNAME.toLowerCase()) { + reviewers.push(TRIAGE_USERNAME); + } + + console.log(`Final reviewers: ${reviewers.join(', ')}`); + + console.log(`Assigning reviewers: ${reviewers.join(', ')}`); + + await github.rest.pulls.requestReviewers({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number, + reviewers + }); + + } catch (error) { + console.error('Error assigning reviewer:', error); + } diff --git a/.github/workflows/vscode-ext-release.yaml b/.github/workflows/vscode-ext-release.yaml index 6c380cd0f91..9756656aa56 100644 --- a/.github/workflows/vscode-ext-release.yaml +++ b/.github/workflows/vscode-ext-release.yaml @@ -11,11 +11,11 @@ jobs: environment: release steps: - name: Checkout - uses: actions/checkout@v3 - - name: Setup NodeJS 16 - uses: actions/setup-node@v3 + uses: actions/checkout@v4 + - name: Setup NodeJS 18 + uses: actions/setup-node@v4 with: - node-version: 16 + node-version: 18 - name: Install dependencies run: | npm install -g yarn @@ -29,6 +29,6 @@ jobs: working-directory: vscode-extension - name: publish-ovsx run: | - sed -i 's/"ms-vscode-remote.remote-ssh"//g' package.json + sed -i 's/"publisher": "jetpack-io"/"publisher": "Jetify"/g' package.json ovsx publish --pat ${{ secrets.OVSX_MARKETPLACE_TOKEN }} --yarn --skip-duplicate working-directory: vscode-extension diff --git a/.gitignore b/.gitignore index 7d4359f419c..1e9c1c0fc45 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,8 @@ __pycache__/ # deployment .vercel +.yarn + +# Nix +vendor/ +result diff --git a/.golangci.yml b/.golangci.yml index 9faefad13cd..56ea6dbb354 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,11 +1,9 @@ -run: - go: "1.20" linters: disable-all: true enable: - dupl - - errorlint - errcheck + - errorlint - gofmt - goimports - gosimple @@ -18,12 +16,12 @@ linters: - revive - staticcheck - stylecheck - - tenv - typecheck - unconvert - unparam - unused - usestdlibvars + - usetesting - varnamelen # - wrapcheck If we're going to use github.com/pkg/errors we should probably turn this on? # We'd like to have the following linter enabled, but it's broken for Go @@ -40,6 +38,8 @@ linters-settings: - name: bare-return - name: bool-literal-in-expr - name: cognitive-complexity + exclude: + - "**_test.go" arguments: - 32 # TODO: gradually reduce it - name: datarace @@ -70,6 +70,7 @@ linters-settings: - m map[string]int - n int - ns string + - ok bool - r *http.Request - r io.Reader - r *os.File @@ -85,4 +86,7 @@ linters-settings: - w *os.File wrapcheck: ignorePackageGlobs: - - go.jetpack.io/devbox/* + - go.jetify.com/devbox/* + misspell: + ignore-words: + - substituters diff --git a/.goreleaser.yaml b/.goreleaser.yaml index b4adb347b3b..3301a48bdc9 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -10,11 +10,11 @@ builds: mod_timestamp: "{{ .CommitTimestamp }}" # For reproducible builds ldflags: - -s -w - - -X go.jetpack.io/devbox/internal/build.Version={{.Version}} - - -X go.jetpack.io/devbox/internal/build.Commit={{.Commit}} - - -X go.jetpack.io/devbox/internal/build.CommitDate={{.CommitDate}} - - -X go.jetpack.io/devbox/internal/build.SentryDSN={{ .Env.SENTRY_DSN }} - - -X go.jetpack.io/devbox/internal/build.TelemetryKey={{ .Env.TELEMETRY_KEY }} + - -X go.jetify.com/devbox/internal/build.Version={{.Version}} + - -X go.jetify.com/devbox/internal/build.Commit={{.Commit}} + - -X go.jetify.com/devbox/internal/build.CommitDate={{.CommitDate}} + - -X go.jetify.com/devbox/internal/build.SentryDSN={{ .Env.SENTRY_DSN }} + - -X go.jetify.com/devbox/internal/build.TelemetryKey={{ .Env.TELEMETRY_KEY }} env: - CGO_ENABLED=0 - GO111MODULE=on @@ -41,7 +41,7 @@ release: prerelease: auto draft: true github: - owner: jetpack-io + owner: jetify-com name: devbox announce: discord: diff --git a/.schema/devbox-plugin.schema.json b/.schema/devbox-plugin.schema.json index edcb8e26720..3a0a9cb5cfe 100644 --- a/.schema/devbox-plugin.schema.json +++ b/.schema/devbox-plugin.schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft-04/schema#", - "$id": "https://github.com/jetpack-io/devbox/plugins", + "$id": "https://github.com/jetify-com/devbox/plugins", "title": "Devbox Plugin Schema", "description": "Defines fields and values for public devbox plugins", "type": "object", @@ -17,10 +17,78 @@ "description": "The version of the plugin.", "type": "string" }, - "readme": { + "description": { "description": "A short description of the plugin and how it works. This will automatically display when the user first installs the plugin, or runs `devbox info`", "type": "string" }, + "packages": { + "description": "Collection of packages to install", + "oneOf": [ + { + "type": "array", + "items": { + "description": "Name and version of each package in name@version format.", + "type": "string" + } + }, + { + "type": "object", + "description": "Name of each package in {\"name\": {\"version\": \"1.2.3\"}} format.", + "patternProperties": { + ".*": { + "oneOf": [ + { + "type": "object", + "description": "Version number of the specified package in {\"version\": \"1.2.3\"} format.", + "properties": { + "version": { + "type": "string", + "description": "Version of the package" + }, + "platforms": { + "type": "array", + "description": "Names of platforms to install the package on. This package will be skipped for any platforms not on this list", + "items": { + "enum": [ + "i686-linux", + "aarch64-linux", + "aarch64-darwin", + "x86_64-darwin", + "x86_64-linux", + "armv7l-linux" + ] + } + }, + "excluded_platforms": { + "type": "array", + "description": "Names of platforms to exclude the package on", + "items": { + "enum": [ + "i686-linux", + "aarch64-linux", + "aarch64-darwin", + "x86_64-darwin", + "x86_64-linux", + "armv7l-linux" + ] + } + }, + "glibc_patch": { + "type": "boolean", + "description": "Whether to patch glibc to the latest available version for this package" + } + } + }, + { + "type": "string", + "description": "Version of the package to install." + } + ] + } + } + } + ] + }, "env": { "type": "object", "description": "List of additional environment variables to be set in the Devbox environment. These can be overridden by environment variables set in the user's devbox.json", @@ -48,9 +116,31 @@ "init_hook": { "type": ["array", "string"], "description": "Shell command to run right before initializing the user's shell, running a script, or starting a service" + }, + "scripts": { + "description": "List of command/script definitions to run with `devbox run `.", + "type": "object", + "patternProperties": { + ".*": { + "description": "Alias name for the script.", + "type": ["array", "string"], + "items": { + "type": "string", + "description": "The script's shell commands." + } + } + } } } + }, + "include": { + "description": "List of additional plugins to activate within your devbox shell", + "type": "array", + "items": { + "description": "Name of the plugin to activate.", + "type": "string" + } } }, - "required": ["name", "version", "readme"] + "required": ["name", "version", "description"] } diff --git a/.schema/devbox.schema.json b/.schema/devbox.schema.json index 35a4bc87234..f540406976e 100644 --- a/.schema/devbox.schema.json +++ b/.schema/devbox.schema.json @@ -1,6 +1,6 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "$id": "https://github.com/jetpack-io/devbox", + "$id": "https://github.com/jetify-com/devbox", "title": "Devbox json definition", "description": "Defines fields and acceptable values of devbox.json", "type": "object", @@ -9,6 +9,14 @@ "description": "The schema version of this devbox.json file.", "type": "string" }, + "name": { + "description": "The name of the Devbox development environment.", + "type": "string" + }, + "description": { + "description": "A description of the Devbox development environment.", + "type": "string" + }, "packages": { "description": "Collection of packages to install", "oneOf": [ @@ -25,39 +33,53 @@ "patternProperties": { ".*": { "oneOf": [ - { - "type": "object", - "description": "Version number of the specified package in {\"version\": \"1.2.3\"} format.", - "properties": { - "version": { - "type": "string", - "description": "Version of the package" - }, - "platforms": { - "type": "array", - "description": "Names of platforms to install the package on. This package will be skipped for any platforms not on this list", - "items": { - "enum": ["i686-linux", "aarch64-linux", "aarch64-darwin", "x86_64-darwin", "x86_64-linux", "armv7l-linux"] - } - }, - "excluded_platforms": { - "type": "array", - "description": "Names of platforms to exclude the package on", - "items": { - "enum": ["i686-linux", "aarch64-linux", "aarch64-darwin", "x86_64-darwin", "x86_64-linux", "armv7l-linux"] + { + "type": "object", + "description": "Version number of the specified package in {\"version\": \"1.2.3\"} format.", + "properties": { + "version": { + "type": "string", + "description": "Version of the package" + }, + "platforms": { + "type": "array", + "description": "Names of platforms to install the package on. This package will be skipped for any platforms not on this list", + "items": { + "enum": [ + "i686-linux", + "aarch64-linux", + "aarch64-darwin", + "x86_64-darwin", + "x86_64-linux", + "armv7l-linux" + ] + } + }, + "excluded_platforms": { + "type": "array", + "description": "Names of platforms to exclude the package on", + "items": { + "enum": [ + "i686-linux", + "aarch64-linux", + "aarch64-darwin", + "x86_64-darwin", + "x86_64-linux", + "armv7l-linux" + ] + } + }, + "glibc_patch": { + "type": "boolean", + "description": "Whether to patch glibc to the latest available version for this package" + } } }, - "glibc_patch": { - "type":"boolean", - "description": "Whether to patch glibc to the latest available version for this package" + { + "type": "string", + "description": "Version of the package to install." } - } - }, - { - "type": "string", - "description": "Version of the package to install." - } - ] + ] } } } @@ -117,7 +139,16 @@ }, "env_from": { "type": "string" + }, + "nixpkgs": { + "type": "object", + "properties": { + "commit": { + "type": "string", + "description": "The commit hash of the nixpkgs repository to use" + } + } } }, "additionalProperties": false -} \ No newline at end of file +} diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 408cceff79a..0ac263c0b1b 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -59,8 +59,8 @@ representative at an online or offline event. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported to the community leaders responsible for enforcement. Use the -"Report to repository admins" functionality on GitHub to report. +reported to the community leaders responsible for enforcement. Use the "Report +to repository admins" functionality on GitHub to report. All complaints will be reviewed and investigated promptly and fairly. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4ebf7b8b7ff..2bee544a437 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,12 +1,15 @@ # Contributing -When contributing to this repository, please describe the change you wish to make via a related issue, or a pull request. +When contributing to this repository, please describe the change you wish to +make via a related issue, or a pull request. -Please note we have a [code of conduct](CODE_OF_CONDUCT.md), please follow it in all your interactions with the project. +Please note we have a [code of conduct](CODE_OF_CONDUCT.md), please follow it in +all your interactions with the project. ## Setting Up Development Environment -Before making any changes to the source code (documentation excluded) make sure you have installed all the required tools. +Before making any changes to the source code (documentation excluded) make sure +you have installed all the required tools. ### With Devbox @@ -14,14 +17,15 @@ The easiest way to develop Devbox is with Devbox! 1. Install Devbox: - curl -fsSL https://get.jetpack.io/devbox | bash + curl -fsSL https://get.jetify.com/devbox | bash 2. Clone this repository: - git clone https://github.com/jetpack-io/devbox.git go.jetpack.io/devbox - cd go.jetpack.io/devbox + git clone https://github.com/jetify-com/devbox.git go.jetify.com/devbox + cd go.jetify.com/devbox -3. Build the Devbox CLI. If you don't have Nix installed, Devbox will automatically install it for you before building: +3. Build the Devbox CLI. If you don't have Nix installed, Devbox will + automatically install it for you before building: devbox run build @@ -29,53 +33,84 @@ The easiest way to develop Devbox is with Devbox! dist/devbox shell -Tip: you can also start VSCode from inside your Devbox shell with `devbox run code`. -- If you are encountering an error similar to: `line 3: command 'code' not found`, this means you do not have the Visual Studio Code "Shell Command" installed. To do this, follow the official guide: https://code.visualstudio.com/docs/setup/mac. Please refer to the section under: "Launching from the command line". +Tip: you can also start VSCode from inside your Devbox shell with +`devbox run code`. + +- If you encounter an error similar to: `line 3: command 'code' not found`, it + means you do not have the Visual Studio Code "Shell Command" installed. Follow + the official guide at https://code.visualstudio.com/docs/setup/mac. Please + refer to the section under: "Launching from the command line". ### Setting up the Environment Without Devbox -If you are unable to install or use Devbox, you can manually replicate the environment by following the steps below. +If you are unable to install or use Devbox, you can manually replicate the +environment by following the steps below. -1. Install Nix Package Manager. We recommend using the [Determinate Systems installer](https://github.com/DeterminateSystems/nix-installer): +1. Install Nix Package Manager. We recommend using the + [Determinate Systems installer](https://github.com/DeterminateSystems/nix-installer): curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install - Alternatively, you can also use [the official installer](https://nixos.org/download.html). + Alternatively, you can also use + [the official installer](https://nixos.org/download.html). 2. Install [Go](https://go.dev/doc/install) (current version: 1.20) 3. Clone this repository and build Devbox: - git clone https://github.com/jetpack-io/devbox.git go.jetpack.io/devbox - cd go.jetpack.io/devbox + git clone https://github.com/jetify-com/devbox.git go.jetify.com/devbox + cd go.jetify.com/devbox go build ./cmd/devbox ./devbox run -- echo hello, world ## Pull Request Process -1. For new features or non-trivial changes, consider first filing an issue to discuss what changes you plan on making. This will let us help you with implementation details and to make sure we don't duplicate any work. -2. Ensure any new feature or functionality includes tests to verify its correctness. +1. For new features or non-trivial changes, consider first filing an issue to + discuss what changes you intend to make. This will let us help you with + implementation details and to make sure we don't duplicate any work. +2. Ensure any new feature or functionality includes tests to verify its + correctness. 3. Run `devbox run lint` and `devbox run test`. 4. Run `go mod tidy` if you added any new dependencies. 5. Submit your pull request and someone will take a look! ### Style Guide -We don't expect you to read through a long style guide or be an expert in Go before contributing. When necessary, a reviewer will be happy to help out with any suggestions around code style when you submit your PR. Otherwise, the Devbox codebase generally follows common Go idioms and patterns: +We don't expect you to read through a long style guide or be an expert in Go +before contributing. When necessary, a reviewer will be happy to help out with +any suggestions around code style when you submit your PR. Otherwise, the Devbox +codebase generally follows common Go idioms and patterns: + +- If you're unfamiliar with idiomatic Go, + [Effective Go](https://go.dev/doc/effective_go) and the + [Google Go Style Guide](https://google.github.io/styleguide/go) are good + resources. +- There's no strict commit message format, but a good practice is to start the + subject with the name of the Go packages you add/modified. For example, + `boxcli: update help for add command`. + +## Community Contribution License + +Contributions made to this project must be made under the terms of the +[Apache 2 License](https://www.apache.org/licenses/LICENSE-2.0). + +``` +By making a contribution to this project, you certify that: -- If you're unfamiliar with idiomatic Go, [Effective Go](https://go.dev/doc/effective_go) and the [Google Go Style Guide](https://google.github.io/styleguide/go) are good resources. -- There's no strict commit message format, but a good practice is to start the subject with the name of the Go packages you add/modified. For example, `boxcli: update help for add command`. + a. The contribution was created in whole or in part by you and you have the right + to submit it under the Apache 2 License; or -## Developer Certificate of Origin + b. The contribution is based upon previous work that, to the best of your + knowledge, is covered under an appropriate open source license and you have the + right under that license to submit that work with modifications, whether + created in whole or in part by you, under the Apache 2 License; or -By contributing to this project you agree to the [Developer Certificate of Origin](https://developercertificate.org/) (DCO) which was created by the Linux Foundation and is a simple statement that you, as a contributor, have the legal right to make the contribution. See the DCO description for details below: + c. The contribution was provided directly to you by some other person who + certified (a), (b) or (c) and you have not modified it. -> By making a contribution to this project, I certify that: -> -> a. The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or -> -> b. The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or -> -> c. The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. -> -> d. I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. + d. You understand and agree that this project and the contribution are public + and that a record of the contribution (including all personal information you + submit with it, including your sign-off) is maintained indefinitely and may be + redistributed consistent with this project or the open source license(s) + involved. +``` diff --git a/README.md b/README.md index 5d61b5a105e..d9fd8a5a8ac 100644 --- a/README.md +++ b/README.md @@ -8,23 +8,33 @@ ### Instant, easy, and predictable development environments -[![Join Discord](https://img.shields.io/discord/903306922852245526?color=7389D8&label=discord&logo=discord&logoColor=ffffff)](https://discord.gg/agbskCJXk2) ![License: Apache 2.0](https://img.shields.io/github/license/jetpack-io/devbox) [![version](https://img.shields.io/github/v/release/jetpack-io/devbox?color=green&label=version&sort=semver)](https://github.com/jetpack-io/devbox/releases) [![tests](https://github.com/jetpack-io/devbox/actions/workflows/cli-post-release.yml/badge.svg)](https://github.com/jetpack-io/devbox/actions/workflows/cli-release.yml?branch=main) [![Built with Devbox](https://jetpack.io/img/devbox/shield_galaxy.svg)](https://jetpack.io/devbox/docs/contributor-quickstart/) +[![Join Discord](https://img.shields.io/discord/903306922852245526?color=7389D8&label=discord&logo=discord&logoColor=ffffff&cacheSeconds=1800)](https://discord.gg/jetify) +![License: Apache 2.0](https://img.shields.io/github/license/jetify-com/devbox) +[![version](https://img.shields.io/github/v/release/jetify-com/devbox?color=green&label=version&sort=semver)](https://github.com/jetify-com/devbox/releases) +[![tests](https://github.com/jetify-com/devbox/actions/workflows/cli-post-release.yml/badge.svg)](https://github.com/jetify-com/devbox/actions/workflows/cli-release.yml?branch=main) +[![Built with Devbox](https://www.jetify.com/img/devbox/shield_galaxy.svg)](https://www.jetify.com/devbox/docs/contributor-quickstart/) ## What is it? -[Devbox](https://www.jetpack.io/devbox/) is a command-line tool that lets you easily create isolated shells for development. You start by defining the list of packages required by your development environment, and devbox uses that definition to create an isolated environment just for your application. +[Devbox](https://www.jetify.com/devbox/) is a command-line tool that lets you +easily create isolated shells for development. You start by defining the list of +packages required by your development environment, and devbox uses that +definition to create an isolated environment just for your application. -In practice, Devbox works similar to a package manager like `yarn` – except the packages it manages are at the operating-system level (the sort of thing you would normally install with `brew` or `apt-get`). With Devbox, you can install over [400,000 package versions](https://www.nixhub.io) from the Nix Package Registry +In practice, Devbox works similar to a package manager like `yarn` – except the +packages it manages are at the operating-system level (the sort of thing you +would normally install with `brew` or `apt-get`). With Devbox, you can install +over [400,000 package versions](https://www.nixhub.io) from the Nix Package +Registry -Devbox was originally developed by [jetpack.io](https://www.jetpack.io) and is internally powered by `nix`. +Devbox was originally developed by [Jetify](https://www.jetify.com) and is +internally powered by `nix`. ## Demo -You can try out Devbox in your browser using the button below: - -[![Open In Devbox.sh](https://jetpack.io/img/devbox/open-in-devbox.svg)](https://devbox.sh/new) - -The example below creates a development environment with `python 2.7` and `go 1.18`, even though those packages are not installed in the underlying machine: +The example below creates a development environment with `python 2.7` and +`go 1.18`, even though those packages are not installed in the underlying +machine: ![screen cast](https://user-images.githubusercontent.com/279789/186491771-6b910175-18ec-4c65-92b0-ed1a91bb15ed.svg) @@ -33,43 +43,59 @@ The example below creates a development environment with `python 2.7` and `go 1. Use the following install script to get the latest version of Devbox: ```sh -curl -fsSL https://get.jetpack.io/devbox | bash +curl -fsSL https://get.jetify.com/devbox | bash ``` -Read more on the [Devbox docs](https://www.jetpack.io/devbox/docs/installing_devbox/). +Read more on the +[Devbox docs](https://www.jetify.com/devbox/docs/installing_devbox/). ## Benefits ### A consistent shell for everyone on the team -Declare the list of tools needed by your project via a `devbox.json` file and run `devbox shell`. Everyone working on the project gets a shell environment with the exact same version of those tools. +Declare the list of tools needed by your project via a `devbox.json` file and +run `devbox shell`. Everyone working on the project gets a shell environment +with the exact same version of those tools. ### Try new tools without polluting your laptop -Development environments created by Devbox are isolated from everything else in your laptop. Is there a tool you want to try without making a mess? Add it to a Devbox shell, and remove it when you don't want it anymore – all while keeping your laptop pristine. +Development environments created by Devbox are isolated from everything else in +your laptop. Is there a tool you want to try without making a mess? Add it to a +Devbox shell, and remove it when you don't want it anymore – all while keeping +your laptop pristine. ### Don't sacrifice speed -Devbox can create isolated environments right on your laptop, without an extra-layer of virtualization slowing your file system or every command. When you're ready to ship, it'll turn it into an equivalent container – but not before. +Devbox can create isolated environments right on your laptop, without an +extra-layer of virtualization slowing your file system or every command. When +you're ready to ship, it'll turn it into an equivalent container – but not +before. -### Good-bye conflicting versions +### Goodbye conflicting versions -Are you working on multiple projects, all of which need different versions of the same binary? Instead of attempting to install conflicting versions of the same binary on your laptop, create an isolated environment for each project, and use whatever version you want for each. +Are you working on multiple projects, all of which need different versions of +the same binary? Instead of attempting to install conflicting versions of the +same binary on your laptop, create an isolated environment for each project, and +use whatever version you want for each. ### Take your environment with you Devbox's dev environments are _portable_. We make it possible to declare your -environment exactly once, and use that single definition in several different ways, including: +environment exactly once, and use that single definition in several different +ways, including: -+ A local shell created through `devbox shell` -+ A devcontainer you can use with VSCode -+ A Dockerfile so you can build a production image with the exact same tools you +- A local shell created through `devbox shell` +- A devcontainer you can use with VSCode +- A Dockerfile so you can build a production image with the exact same tools you used for development. -+ A remote development environment in the cloud that mirrors your local environment. +- A remote development environment in the cloud that mirrors your local + environment. ## Quickstart: Fast, Deterministic Shell -In this quickstart we’ll create a development shell with specific tools installed. These tools will only be available when using this Devbox shell, ensuring we don’t pollute your machine. +In this quickstart we'll create a development shell with specific tools +installed. These tools will only be available when using this Devbox shell, +ensuring we don't pollute your machine. 1. Open a terminal in a new empty folder. @@ -79,7 +105,8 @@ In this quickstart we’ll create a development shell with specific tools instal devbox init ``` - This creates a `devbox.json` file in the current directory. You should commit it to source control. + This creates a `devbox.json` file in the current directory. You should commit + it to source control. 3. Add command-line tools from Nix. For example, to add Python 3.10: @@ -89,13 +116,14 @@ In this quickstart we’ll create a development shell with specific tools instal Search for more packages on [Nixhub.io](https://www.nixhub.io) -4. Your `devbox.json` file keeps track of the packages you've added, it should now look like this: +4. Your `devbox.json` file keeps track of the packages you've added, it should + now look like this: ```json { - "packages": [ - "python@3.10" - ] + "packages": [ + "python@3.10" + ] } ``` @@ -105,17 +133,19 @@ In this quickstart we’ll create a development shell with specific tools instal devbox shell ``` - You can tell you’re in a Devbox shell (and not your regular terminal) because the shell prompt changed. + You can tell you're in a Devbox shell (and not your regular terminal) because + the shell prompt changed. 6. Use your favorite tools. - In this example we installed Python 3.10, so let’s use it. + In this example we installed Python 3.10, so let's use it. ```bash python --version ``` -7. Your regular tools are also available including environment variables and config settings. +7. Your regular tools are also available including environment variables and + config settings. ```bash git config --get user.name @@ -127,23 +157,30 @@ In this quickstart we’ll create a development shell with specific tools instal exit ``` -Read more on the [Devbox docs Quickstart](https://www.jetpack.io/devbox/docs/quickstart/). +Read more on the +[Devbox docs Quickstart](https://www.jetify.com/devbox/docs/quickstart/). ## Additional commands `devbox help` - see all commands -See the [CLI Reference](https://www.jetpack.io/devbox/docs/cli_reference/devbox/) for the full list of commands. +See the +[CLI Reference](https://www.jetify.com/devbox/docs/cli_reference/devbox/) for +the full list of commands. ## Join our Developer Community -+ Chat with us by joining the [Jetpack.io Discord Server](https://discord.gg/jetpack-io) – we have a #devbox channel dedicated to this project. -+ File bug reports and feature requests using [Github Issues](https://github.com/jetpack-io/devbox/issues) -+ Follow us on [Jetpack's Twitter](https://twitter.com/jetpack_io) for product updates +- Chat with us by joining the [Jetify Discord Server](https://discord.gg/jetify) + – we have a #devbox channel dedicated to this project. +- File bug reports and feature requests using + [Github Issues](https://github.com/jetify-com/devbox/issues) +- Follow us on [Jetify's Twitter](https://twitter.com/jetify_com) for product + updates ## Contributing -Devbox is an opensource project so contributions are always welcome. Please read [our contributing guide](CONTRIBUTING.md) before submitting pull requests. +Devbox is an opensource project, so contributions are always welcome. Please read +[our contributing guide](CONTRIBUTING.md) before submitting pull requests. [Devbox development readme](devbox.md) @@ -153,8 +190,10 @@ Thanks to [Nix](https://nixos.org/) for providing isolated shells. ## Translation -+ [Chinese](./docs/translation/README-zh-CN.md) +- [Chinese](./docs/translation/README-zh-CN.md) +- [Korean](./docs/translation/README-ko-KR.md) ## License -This project is proudly open-source under the [Apache 2.0 License](https://github.com/jetpack-io/devbox/blob/main/LICENSE) +This project is proudly open-source under the +[Apache 2.0 License](https://github.com/jetify-com/devbox/blob/main/LICENSE) diff --git a/cmd/devbox/main.go b/cmd/devbox/main.go index 383a85fd322..2f0a275f302 100644 --- a/cmd/devbox/main.go +++ b/cmd/devbox/main.go @@ -1,10 +1,10 @@ -// Copyright 2023 Jetpack Technologies Inc and contributors. All rights reserved. +// Copyright 2024 Jetify Inc. and contributors. All rights reserved. // Use of this source code is governed by the license in the LICENSE file. package main import ( - "go.jetpack.io/devbox/internal/boxcli" + "go.jetify.com/devbox/internal/boxcli" ) func main() { diff --git a/devbox.go b/devbox.go new file mode 100644 index 00000000000..53425e2d546 --- /dev/null +++ b/devbox.go @@ -0,0 +1,32 @@ +// Package devbox creates and configures Devbox development environments. +package devbox + +import ( + "context" + "io" + + "go.jetify.com/devbox/internal/devbox" + "go.jetify.com/devbox/internal/devbox/devopt" +) + +// Devbox is a Devbox development environment. +type Devbox struct { + dx *devbox.Devbox +} + +// Open loads a Devbox environment from a config file or directory. +func Open(path string) (*Devbox, error) { + dx, err := devbox.Open(&devopt.Opts{ + Dir: path, + Stderr: io.Discard, + }) + if err != nil { + return nil, err + } + return &Devbox{dx: dx}, nil +} + +// Install downloads and installs missing packages. +func (d *Devbox) Install(ctx context.Context) error { + return d.dx.Install(ctx) +} diff --git a/devbox.json b/devbox.json index 158b02448b1..b4b4b8fc19c 100644 --- a/devbox.json +++ b/devbox.json @@ -2,13 +2,13 @@ "name": "devbox", "description": "Instant, easy, and predictable development environments", "packages": { - "go": "latest", - "runx:golangci/golangci-lint": "latest", - "runx:mvdan/gofumpt": "latest", + "fd": "latest", + "git": "latest", + "go": "latest" }, "env": { "GOENV": "off", - "PATH": "$PATH:$PWD/dist", + "PATH": "$PWD/dist/tools:$PATH:$PWD/dist" }, "shell": { "init_hook": [ @@ -17,6 +17,7 @@ "test -z $FISH_VERSION && \\", "unset CGO_ENABLED GO111MODULE GOARCH GOFLAGS GOMOD GOOS GOROOT GOTOOLCHAIN GOWORK || \\", "set --erase CGO_ENABLED GO111MODULE GOARCH GOFLAGS GOMOD GOOS GOROOT GOTOOLCHAIN GOWORK", + "GOBIN=$PWD/dist/tools go install tool" ], "scripts": { // Build devbox for the current platform @@ -29,15 +30,48 @@ "devbox run build-darwin-amd64", "devbox run build-darwin-arm64", "devbox run build-linux-amd64", - "devbox run build-linux-arm64", + "devbox run build-linux-arm64" ], // Open VSCode - "code": "code .", - "lint": "golangci-lint run --timeout 5m && scripts/gofumpt.sh", - "fmt": "scripts/gofumpt.sh", - "test": "go test -race -cover ./...", - "update-examples": "devbox run build && go run testscripts/testrunner/updater/main.go", - "tidy": "go mod tidy", - }, - }, + "code": "code .", + "lint": "go tool golangci-lint run --timeout 5m && scripts/gofumpt.sh", + "fmt": "scripts/gofumpt.sh", + "test": "go test -race -cover ./...", + "test-projects-only": "DEVBOX_RUN_PROJECT_TESTS=1 go test -v -timeout ${DEVBOX_GOLANG_TEST_TIMEOUT:-30m} ./... -run \"TestExamples|TestScriptsWithProjects\"", + "update-examples": "devbox run build && go run testscripts/testrunner/updater/main.go", + // Updates the Flake's vendorHash: First run `go mod vendor` to vendor + // the dependencies, then hash the vendor directory with Nix. + // The hash is saved to the `vendor-hash` file, which is then + // read into the Nix Flake. + "update-hash": [ + // realpath to work-around nix hash not liking symlinks + "vendor=$(realpath $(mktemp -d))", + "trap \"rm -rf $vendor\" EXIT", + "go mod vendor -o $vendor", + "nix hash path $vendor >vendor-hash" + ], + "build-flake": "nix build .", + "tidy": ["go mod tidy", "devbox run update-hash"], + // docker-testscripts runs the testscripts with Docker to exercise + // Linux-specific tests. It invokes the test binary directly, so any extra + // test runner flags must have their "-test." prefix. + // + // For example, to only run Python tests: + // + // devbox run docker-testscripts -test.run ^TestScripts$/python + "docker-testscripts": [ + "cd testscripts", + + // The Dockerfile looks for a testscripts-$TARGETOS-$TARGETARCH binary + // to run the tests. Pre-compiling a static test binary lets us avoid + // polluting the container with a Go toolchain or shared libraries that + // might interfere with linker tests. + "trap 'rm -f testscripts-linux-amd64 testscripts-linux-arm64' EXIT", + "GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go test -c -o testscripts-linux-amd64", + "GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go test -c -o testscripts-linux-arm64", + "image=$(docker build --quiet --tag devbox-testscripts-ubuntu:noble --platform linux/amd64 .)", + "docker run --rm --mount type=volume,src=devbox-testscripts-amd64,dst=/nix --platform linux/amd64 -e DEVBOX_RUN_FAILING_TESTS -e DEVBOX_RUN_PROJECT_TESTS -e DEVBOX_DEBUG $image \"$@\"" + ] + } + } } diff --git a/devbox.lock b/devbox.lock index d3aa1ae6fbc..825c82cd315 100644 --- a/devbox.lock +++ b/devbox.lock @@ -1,33 +1,177 @@ { "lockfile_version": "1", "packages": { - "go@latest": { - "last_modified": "2024-02-08T11:55:47Z", - "resolved": "github:NixOS/nixpkgs/c0b7a892fb042ede583bdaecbbdc804acb85eabe#go_1_22", + "fd@latest": { + "last_modified": "2025-07-28T17:09:23Z", + "resolved": "github:NixOS/nixpkgs/648f70160c03151bc2121d179291337ad6bc564b#fd", + "source": "devbox-search", + "version": "10.2.0", + "systems": { + "aarch64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/40nk6ri500aip6a34x8nnhr9k0ikgl8f-fd-10.2.0", + "default": true + } + ], + "store_path": "/nix/store/40nk6ri500aip6a34x8nnhr9k0ikgl8f-fd-10.2.0" + }, + "aarch64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/f0cm3mr35dxk6ziwcarwmk5psnzklg6k-fd-10.2.0", + "default": true + } + ], + "store_path": "/nix/store/f0cm3mr35dxk6ziwcarwmk5psnzklg6k-fd-10.2.0" + }, + "x86_64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/5vqrgkgb3ishhjrjfvd08401bzj80yhl-fd-10.2.0", + "default": true + } + ], + "store_path": "/nix/store/5vqrgkgb3ishhjrjfvd08401bzj80yhl-fd-10.2.0" + }, + "x86_64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/d8gs5vih8f1nkck5q8jrndzxzdkpsl01-fd-10.2.0", + "default": true + } + ], + "store_path": "/nix/store/d8gs5vih8f1nkck5q8jrndzxzdkpsl01-fd-10.2.0" + } + } + }, + "git@latest": { + "last_modified": "2025-07-28T17:09:23Z", + "resolved": "github:NixOS/nixpkgs/648f70160c03151bc2121d179291337ad6bc564b#git", "source": "devbox-search", - "version": "1.22.0", + "version": "2.50.1", "systems": { "aarch64-darwin": { - "store_path": "/nix/store/2022s0jnrn2iyxjaikfy51w5fvifp38b-go-1.22.0" + "outputs": [ + { + "name": "out", + "path": "/nix/store/jn9byxgdjndngf0d2by0djg8gcdll7xc-git-2.50.1", + "default": true + }, + { + "name": "doc", + "path": "/nix/store/j8djmq64ckbah7bl6jv1y6arrjr0shmv-git-2.50.1-doc" + } + ], + "store_path": "/nix/store/jn9byxgdjndngf0d2by0djg8gcdll7xc-git-2.50.1" }, "aarch64-linux": { - "store_path": "/nix/store/7wxzkvjv8qc2awhagpz0r8q9ay38q3wj-go-1.22.0" + "outputs": [ + { + "name": "out", + "path": "/nix/store/h4pvvix6pvnvys9a6y1xj2442r1ajdhl-git-2.50.1", + "default": true + }, + { + "name": "debug", + "path": "/nix/store/rpxnrnsn4nbx8wm9d2vrgj0fr5xzz5lg-git-2.50.1-debug" + }, + { + "name": "doc", + "path": "/nix/store/q8sicpx16gyzxnp3345a46lj4cz9wd09-git-2.50.1-doc" + } + ], + "store_path": "/nix/store/h4pvvix6pvnvys9a6y1xj2442r1ajdhl-git-2.50.1" }, "x86_64-darwin": { - "store_path": "/nix/store/fgkl3qk8p5hnd07b0dhzfky3ys5gxjmq-go-1.22.0" + "outputs": [ + { + "name": "out", + "path": "/nix/store/8d1n8cvi5x1j0v61459lvhqs26vmcqbl-git-2.50.1", + "default": true + }, + { + "name": "doc", + "path": "/nix/store/yn9cvbs7jz4dfdb17qralgr0ybi5rmjf-git-2.50.1-doc" + } + ], + "store_path": "/nix/store/8d1n8cvi5x1j0v61459lvhqs26vmcqbl-git-2.50.1" }, "x86_64-linux": { - "store_path": "/nix/store/88y9r33p3j8f7bc8sqiy9jdlk7yqfrlg-go-1.22.0" + "outputs": [ + { + "name": "out", + "path": "/nix/store/5i8zvall945kypmwgqd0y47f02pldwp4-git-2.50.1", + "default": true + }, + { + "name": "doc", + "path": "/nix/store/d2lhlzkdziwmijik8nszfwp8srbkskb9-git-2.50.1-doc" + }, + { + "name": "debug", + "path": "/nix/store/l46kpjpcwwp8l7kzzr1s2dlk646r73z2-git-2.50.1-debug" + } + ], + "store_path": "/nix/store/5i8zvall945kypmwgqd0y47f02pldwp4-git-2.50.1" } } }, - "runx:golangci/golangci-lint@latest": { - "resolved": "golangci/golangci-lint@v1.56.1", - "version": "v1.56.1" + "github:NixOS/nixpkgs/nixpkgs-unstable": { + "last_modified": "2025-08-12T09:17:37Z", + "resolved": "github:NixOS/nixpkgs/372d9eeeafa5b15913201e2b92e8e539ac7c64d1?lastModified=1754990257&narHash=sha256-eEq2wlYNF2t89PsNyEv5Sz4lSxdukZCj4SdhZBVAGpI%3D" }, - "runx:mvdan/gofumpt@latest": { - "resolved": "mvdan/gofumpt@v0.6.0", - "version": "v0.6.0" + "go@latest": { + "last_modified": "2025-07-28T17:09:23Z", + "resolved": "github:NixOS/nixpkgs/648f70160c03151bc2121d179291337ad6bc564b#go", + "source": "devbox-search", + "version": "1.24.5", + "systems": { + "aarch64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/kw1vd98s15vj700m3gx2x2xca2z477i3-go-1.24.5", + "default": true + } + ], + "store_path": "/nix/store/kw1vd98s15vj700m3gx2x2xca2z477i3-go-1.24.5" + }, + "aarch64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/5bzlaj0c4mqw9p0zrcx5g9vz16vd45dl-go-1.24.5", + "default": true + } + ], + "store_path": "/nix/store/5bzlaj0c4mqw9p0zrcx5g9vz16vd45dl-go-1.24.5" + }, + "x86_64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/b72n20ixzl5ja9vciwahkr30bhmsn5jc-go-1.24.5", + "default": true + } + ], + "store_path": "/nix/store/b72n20ixzl5ja9vciwahkr30bhmsn5jc-go-1.24.5" + }, + "x86_64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/y4awwzp30ka130wmjrpaqjmjdf9p010w-go-1.24.5", + "default": true + } + ], + "store_path": "/nix/store/y4awwzp30ka130wmjrpaqjmjdf9p010w-go-1.24.5" + } + } } } } diff --git a/devbox.md b/devbox.md index c3edd091480..3ba3485e6d2 100644 --- a/devbox.md +++ b/devbox.md @@ -1,40 +1,56 @@ - + + # devbox Instant, easy, and predictable development environments ## Getting Started -This project uses [devbox](https://github.com/jetpack-io/devbox) to manage its development environment. + +This project uses [devbox](https://github.com/jetify-com/devbox) to manage its +development environment. Install devbox: + ```sh -curl -fsSL https://get.jetpack.io/devbox | bash +curl -fsSL https://get.jetify.com/devbox | bash ``` Start the devbox shell: -```sh + +```sh devbox shell ``` Run a script in the devbox environment: + ```sh devbox run