Skip to content

Commit

Permalink
debug ci
Browse files Browse the repository at this point in the history
  • Loading branch information
gcurtis committed Jul 26, 2023
1 parent 0ceb7c8 commit a92946e
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 21 deletions.
55 changes: 40 additions & 15 deletions .github/workflows/cli-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ permissions:
contents: read
pull-requests: read

defaults:
run:
# Explicitly setting the shell to bash runs commands with
# `bash --noprofile --norc -eo pipefail` instead of `bash -e`.
shell: bash

env:
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}"
HOMEBREW_NO_ANALYTICS: 1
Expand Down Expand Up @@ -102,10 +108,10 @@ jobs:
brew install dash zsh
fi
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v1
uses: DeterminateSystems/nix-installer-action@v4
with:
logger: pretty
nix-build-user-count: 4
extra-conf: experimental-features = ca-derivations fetch-closure
- 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.
Expand All @@ -115,6 +121,15 @@ jobs:
# 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) && '35m' || '20m' }}"
run: |
echo "::group::Nix version"
nix --version
echo "::endgroup::"
echo "::group::Contents of /etc/nix/nix.conf"
cat /etc/nix/nix.conf || true
echo "::endgroup::"
echo "::group::Resolved Nix config"
nix show-config
echo "::endgroup::"
go test -v -timeout $DEVBOX_GOLANG_TEST_TIMEOUT ./...
auto-nix-install: # ensure Devbox installs nix and works properly after installation.
Expand All @@ -141,12 +156,14 @@ jobs:
devbox run echo "Installing packages..."
- name: Test removing package
run: devbox rm go

test-with-old-nix-version:

# Run a sanity test to make sure Devbox can install and remove packages with
# the last 3 Nix releases.
test-nix-versions:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
version: [2.15.1]
version: [2.15.1, 2.16.1, 2.17.0]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand All @@ -155,15 +172,23 @@ jobs:
go-version-file: ./go.mod
- name: Build devbox
run: go install ./cmd/devbox
- name: Install nix
run: sh <(curl -L https://releases.nixos.org/nix/nix-${{ matrix.version }}/install) --daemon
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v4
with:
logger: pretty
extra-conf: experimental-features = ca-derivations fetch-closure
nix-package-url: https://releases.nixos.org/nix/nix-${{ matrix.version }}/nix-${{ matrix.version }}-${{ runner.arch == 'X64' && 'x86_64' || 'aarch64' }}-${{ runner.os == 'macOS' && 'darwin' || 'linux' }}.tar.xz
- name: Install devbox packages
run: |
# 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.
mkdir -p ~/.config/nix
echo "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" > ~/.config/nix/nix.conf
devbox run echo "Installing packages..."
- name: Test removing package
run: devbox rm go
echo "::group::Nix version"
nix --version
echo "::endgroup::"
echo "::group::Contents of /etc/nix/nix.conf"
cat /etc/nix/nix.conf || true
echo "::endgroup::"
echo "::group::Resolved Nix config"
nix show-config
echo "::endgroup::"
devbox install
devbox run -- echo "Hello from devbox!"
devbox rm go
16 changes: 10 additions & 6 deletions internal/nix/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@ package nix

import (
"fmt"
"strings"
"testing"

"golang.org/x/exp/slices"
)

func TestContentAddressedPath(t *testing.T) {

testCases := []struct {
storePath string
expected string
expected []string
}{
{
"/nix/store/r2jd6ygnmirm2g803mksqqjm4y39yi6i-git-2.33.1",
"/nix/store/ldbhlwhh39wha58rm61bkiiwm6j7211j-git-2.33.1",
[]string{
"/nix/store/ldbhlwhh39wha58rm61bkiiwm6j7211j-git-2.33.1",
"/nix/store/d49wyvsz5nkqa23qp4p0ikr04mw9n4h9-git-2.33.1",
},
},
}

Expand All @@ -23,10 +28,9 @@ func TestContentAddressedPath(t *testing.T) {
if err != nil {
t.Errorf("got error: %v", err)
}
if out != testCase.expected {
t.Errorf("got %s, want %s", out, testCase.expected)
if !slices.Contains(testCase.expected, out) {
t.Errorf("got %q, want any of:\n%s", out, strings.Join(testCase.expected, "\n"))
}
})

}
}

0 comments on commit a92946e

Please sign in to comment.