Skip to content

Commit a42b2a0

Browse files
committed
[tmpnet] Rename tmpnetctl package from cmd to tmpnetctl
This enables downstream repos to `go install` `tmptnetctl` rather than `cmd`.
1 parent 618a6f8 commit a42b2a0

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

scripts/build_tmpnetctl.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ echo "Building tmpnetctl..."
1212
go build -ldflags\
1313
"-X github.com/ava-labs/avalanchego/version.GitCommit=$git_commit $static_ld_flags"\
1414
-o "$AVALANCHE_PATH/build/tmpnetctl"\
15-
"$AVALANCHE_PATH/tests/fixture/tmpnet/cmd/"*.go
15+
"$AVALANCHE_PATH/tests/fixture/tmpnet/tmpnetctl/"*.go

tests/fixture/tmpnet/README.md

+19-8
Original file line numberDiff line numberDiff line change
@@ -444,16 +444,27 @@ flake that inherits from the avalanchego flake:
444444
}
445445
```
446446

447-
The action also requires being able to invoke tmpnetctl via `go
448-
run`. Use of a `tools.go` file that imports tmpnetctl is suggested to
449-
enable this:
447+
The action expects to be able to run bin/tmpnetctl from the root of
448+
the repository. A suggested version of this script:
450449

451-
```golang
452-
package tools
450+
```bash
451+
#!/usr/bin/env bash
453452

454-
import (
455-
_ "github.com/ava-labs/avalanchego/tests/fixture/tmpnet/cmd" // tmpnetctl
456-
)
453+
set -euo pipefail
454+
455+
# Ensure the go command is run from the root of the repository
456+
REPO_ROOT=$(cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd )
457+
cd "${REPO_ROOT}"
458+
459+
# Set AVALANCHE_VERSION
460+
source ./scripts/versions.sh
461+
462+
# Install if not already available
463+
if command -v tmpnetctl &2> /dev/null; then
464+
# An explicit version is required since a main package can't be included as a dependency of the go module.
465+
go install github.com/ava-labs/avalanchego/tests/fixture/tmpnet/tmpnetctl@${AVALANCHE_VERSION}
466+
fi
467+
tmpnetctl "${@}"
457468
```
458469

459470
### Viewing
File renamed without changes.

0 commit comments

Comments
 (0)