Skip to content
This repository was archived by the owner on Jul 13, 2025. It is now read-only.

Commit 5eafce7

Browse files
committed
gokrazy/natlab: update gokrazy, wire up natlab tests to GitHub CI
Updates tailscale#13038 Change-Id: I610f9076816f44d59c0ca405a1b4f5eb4c6c0594 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
1 parent 3e18434 commit 5eafce7

File tree

11 files changed

+318
-20
lines changed

11 files changed

+318
-20
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Run some natlab integration tests.
2+
# See https://github.com/tailscale/tailscale/issues/13038
3+
name: "natlab-integrationtest"
4+
5+
concurrency:
6+
group: ${{ github.workflow }}-$${{ github.head_ref || github.run_id }}
7+
cancel-in-progress: true
8+
9+
on:
10+
pull_request:
11+
paths:
12+
- "tailcfg/**"
13+
- "wgengine/**"
14+
- "ipn/ipnlocal/**"
15+
- ".github/workflows/natlab-integrationtest.yml"
16+
jobs:
17+
natlab-integrationtest:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Check out code
21+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
22+
- name: Install qemu
23+
run: |
24+
sudo rm /var/lib/man-db/auto-update
25+
sudo apt-get -y update
26+
sudo apt-get -y remove man-db
27+
sudo apt-get install -y qemu-system-x86 qemu-utils
28+
- name: Run natlab integration tests
29+
run: |
30+
./tool/go test -v -run=^TestEasyEasy$ -timeout=3m -count=1 ./tstest/integration/nat --run-vm-tests

gokrazy/build.go

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ package main
1111

1212
import (
1313
"bytes"
14-
"cmp"
1514
"encoding/json"
1615
"errors"
1716
"flag"
@@ -30,7 +29,6 @@ import (
3029
var (
3130
app = flag.String("app", "tsapp", "appliance name; one of the subdirectories of gokrazy/")
3231
bucket = flag.String("bucket", "tskrazy-import", "S3 bucket to upload disk image to while making AMI")
33-
goArch = flag.String("arch", cmp.Or(os.Getenv("GOARCH"), "amd64"), "GOARCH architecture to build for: arm64 or amd64")
3432
build = flag.Bool("build", false, "if true, just build locally and stop, without uploading")
3533
)
3634

@@ -54,13 +52,46 @@ func findMkfsExt4() (string, error) {
5452
return "", errors.New("No mkfs.ext4 found on system")
5553
}
5654

55+
var conf gokrazyConfig
56+
57+
// gokrazyConfig is the subset of gokrazy/internal/config.Struct
58+
// that we care about.
59+
type gokrazyConfig struct {
60+
// Environment is os.Environment pairs to use when
61+
// building userspace.
62+
// See https://gokrazy.org/userguide/instance-config/#environment
63+
Environment []string
64+
}
65+
66+
func (c *gokrazyConfig) GOARCH() string {
67+
for _, e := range c.Environment {
68+
if v, ok := strings.CutPrefix(e, "GOARCH="); ok {
69+
return v
70+
}
71+
}
72+
return ""
73+
}
74+
5775
func main() {
5876
flag.Parse()
5977

6078
if *app == "" || strings.Contains(*app, "/") {
6179
log.Fatalf("--app must be non-empty name such as 'tsapp' or 'natlabapp'")
6280
}
6381

82+
confJSON, err := os.ReadFile(filepath.Join(*app, "config.json"))
83+
if err != nil {
84+
log.Fatalf("reading config.json: %v", err)
85+
}
86+
if err := json.Unmarshal(confJSON, &conf); err != nil {
87+
log.Fatalf("unmarshaling config.json: %v", err)
88+
}
89+
switch conf.GOARCH() {
90+
case "amd64", "arm64":
91+
default:
92+
log.Fatalf("config.json GOARCH %q must be amd64 or arm64", conf.GOARCH())
93+
}
94+
6495
if err := buildImage(); err != nil {
6596
log.Fatalf("build image: %v", err)
6697
}
@@ -106,7 +137,6 @@ func buildImage() error {
106137
// Build the tsapp.img
107138
var buf bytes.Buffer
108139
cmd := exec.Command("go", "run",
109-
"-exec=env GOOS=linux GOARCH="+*goArch+" ",
110140
"github.com/gokrazy/tools/cmd/gok",
111141
"--parent_dir="+dir,
112142
"--instance="+*app,
@@ -253,13 +283,13 @@ func waitForImportSnapshot(importTaskID string) (snapID string, err error) {
253283

254284
func makeAMI(name, ebsSnapID string) (ami string, err error) {
255285
var arch string
256-
switch *goArch {
286+
switch conf.GOARCH() {
257287
case "arm64":
258288
arch = "arm64"
259289
case "amd64":
260290
arch = "x86_64"
261291
default:
262-
return "", fmt.Errorf("unknown arch %q", *goArch)
292+
return "", fmt.Errorf("unknown arch %q", conf.GOARCH())
263293
}
264294
out, err := exec.Command("aws", "ec2", "register-image",
265295
"--name", name,

gokrazy/go.mod

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
module tailscale.com/gokrazy
22

3-
go 1.23.1
3+
go 1.23
44

5-
require github.com/gokrazy/tools v0.0.0-20240730192548-9f81add3a91e
5+
require github.com/gokrazy/tools v0.0.0-20250128200151-63160424957c
66

77
require (
88
github.com/breml/rootcerts v0.2.10 // indirect
99
github.com/donovanhide/eventsource v0.0.0-20210830082556-c59027999da0 // indirect
10-
github.com/gokrazy/internal v0.0.0-20240629150625-a0f1dee26ef5 // indirect
10+
github.com/gokrazy/internal v0.0.0-20250126213949-423a5b587b57 // indirect
1111
github.com/gokrazy/updater v0.0.0-20230215172637-813ccc7f21e2 // indirect
1212
github.com/google/renameio/v2 v2.0.0 // indirect
1313
github.com/inconshreveable/mousetrap v1.1.0 // indirect
1414
github.com/spf13/cobra v1.6.1 // indirect
1515
github.com/spf13/pflag v1.0.5 // indirect
1616
golang.org/x/mod v0.11.0 // indirect
1717
golang.org/x/sync v0.1.0 // indirect
18-
golang.org/x/sys v0.20.0 // indirect
18+
golang.org/x/sys v0.28.0 // indirect
1919
)
20-
21-
replace github.com/gokrazy/gokrazy => github.com/tailscale/gokrazy v0.0.0-20240812224643-6b21ddf64678
22-
23-
replace github.com/gokrazy/tools => github.com/tailscale/gokrazy-tools v0.0.0-20240730192548-9f81add3a91e

gokrazy/go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ github.com/breml/rootcerts v0.2.10/go.mod h1:24FDtzYMpqIeYC7QzaE8VPRQaFZU5TIUDly
33
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
44
github.com/donovanhide/eventsource v0.0.0-20210830082556-c59027999da0 h1:C7t6eeMaEQVy6e8CarIhscYQlNmw5e3G36y7l7Y21Ao=
55
github.com/donovanhide/eventsource v0.0.0-20210830082556-c59027999da0/go.mod h1:56wL82FO0bfMU5RvfXoIwSOP2ggqqxT+tAfNEIyxuHw=
6-
github.com/gokrazy/internal v0.0.0-20240629150625-a0f1dee26ef5 h1:XDklMxV0pE5jWiNaoo5TzvWfqdoiRRScmr4ZtDzE4Uw=
7-
github.com/gokrazy/internal v0.0.0-20240629150625-a0f1dee26ef5/go.mod h1:t3ZirVhcs9bH+fPAJuGh51rzT7sVCZ9yfXvszf0ZjF0=
6+
github.com/gokrazy/internal v0.0.0-20250126213949-423a5b587b57 h1:f5bEvO4we3fbfiBkECrrUgWQ8OH6J3SdB2Dwxid/Yx4=
7+
github.com/gokrazy/internal v0.0.0-20250126213949-423a5b587b57/go.mod h1:SJG1KwuJQXFEoBgryaNCkMbdISyovDgZd0xmXJRZmiw=
8+
github.com/gokrazy/tools v0.0.0-20250128200151-63160424957c h1:iEbS8GrNOn671ze8J/AfrYFEVzf8qMx8aR5K0VxPK2w=
9+
github.com/gokrazy/tools v0.0.0-20250128200151-63160424957c/go.mod h1:f2vZhnaPzy92+Bjpx1iuZHK7VuaJx6SNCWQWmu23HZA=
810
github.com/gokrazy/updater v0.0.0-20230215172637-813ccc7f21e2 h1:kBY5R1tSf+EYZ+QaSrofLaVJtBqYsVNVBWkdMq3Smcg=
911
github.com/gokrazy/updater v0.0.0-20230215172637-813ccc7f21e2/go.mod h1:PYOvzGOL4nlBmuxu7IyKQTFLaxr61+WPRNRzVtuYOHw=
1012
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
@@ -19,14 +21,12 @@ github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
1921
github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
2022
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
2123
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
22-
github.com/tailscale/gokrazy-tools v0.0.0-20240730192548-9f81add3a91e h1:3/xIc1QCvnKL7BCLng9od98HEvxCadjvqiI/bN+Twso=
23-
github.com/tailscale/gokrazy-tools v0.0.0-20240730192548-9f81add3a91e/go.mod h1:eTZ0QsugEPFU5UAQ/87bKMkPxQuTNa7+iFAIahOFwRg=
2424
golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU=
2525
golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
2626
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
2727
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
28-
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
29-
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
28+
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
29+
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
3030
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
3131
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
3232
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

0 commit comments

Comments
 (0)