Skip to content

Commit

Permalink
fixup! chore: add xBSD pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
rexagod committed Dec 21, 2024
1 parent 01fec99 commit 885e898
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 60 deletions.
61 changes: 52 additions & 9 deletions .github/workflows/bsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ permissions:
contents: read

env:
GNU_TAR_VERSION: "1.35"
GO_VERSION_DRAGONFLY: "1.23.3"
GO_VERSION_FREEBSD: "123"
GO_VERSION_OPENBSD: "1.23.1"
GO_VERSION_NETBSD: "123"
GO_VERSION_DRAGONFLY: "1.23.3"
GNU_TAR_VERSION: "1.35"
GO_VERSION_OPENBSD: "1.23.1"
GO_VERSION_SOLARIS: "1.23.3"

# To spin up one of the VMs below, see the "Debug Shell" section here: https://github.com/vmactions
jobs:
Expand All @@ -34,7 +35,7 @@ jobs:
usesh: true
prepare: |
pkg update -f
pkg install -y bash curl gtar git gmake gsed gnugrep go${GO_VERSION_FREEBSD} python
pkg install -y wget gtar git gmake gsed gnugrep go${GO_VERSION_FREEBSD} python
run: |
echo "::group::Setup prerequisites"
set -eu
Expand Down Expand Up @@ -72,7 +73,7 @@ jobs:
usesh: true
prepare: |
pkg_add -u
pkg_add bash curl gtar-${GNU_TAR_VERSION}p0-static git gmake gsed ggrep go-${GO_VERSION_OPENBSD} python
pkg_add wget gtar-${GNU_TAR_VERSION}p0-static git gmake gsed ggrep go-${GO_VERSION_OPENBSD} python
run: |
echo "::group::Setup prerequisites"
set -eu
Expand Down Expand Up @@ -109,7 +110,7 @@ jobs:
usesh: true
prepare: |
/usr/sbin/pkg_add -u
/usr/sbin/pkg_add curl gtar-base-${GNU_TAR_VERSION} git gmake gsed grep go${GO_VERSION_NETBSD} python312
/usr/sbin/pkg_add wget gtar-base-${GNU_TAR_VERSION} git gmake gsed grep go${GO_VERSION_NETBSD} python312
run: |
echo "::group::Setup prerequisites"
set -eu
Expand Down Expand Up @@ -147,14 +148,15 @@ jobs:
usesh: true
prepare: |
pkg update && pkg upgrade -y
pkg install -y bash wget gtar git gmake gsed gnugrep python3
pkg install -y wget gtar git gmake gsed gnugrep python3
run: |
echo "::group::Setup prerequisites"
set -eu
mkdir bin
export PATH=$(pwd)/bin:$PATH
wget https://go.dev/dl/go${GO_VERSION_DRAGONFLY}.dragonfly-amd64.tar.gz
gtar xzf go${GO_VERSION_DRAGONFLY}.dragonfly-amd64.tar.gz
GOGZ="go${GO_VERSION_DRAGONFLY}.dragonfly-amd64.tar.gz"
wget https://go.dev/dl/${GOGZ}
gtar xzf ${GOGZ}
ln -s $(pwd)/go/bin/go $(pwd)/bin/go
ln -s $(which ggrep) $(pwd)/bin/grep
ln -s $(which gmake) $(pwd)/bin/make
Expand All @@ -173,3 +175,44 @@ jobs:
git config --global --add safe.directory $(pwd)
gmake test-e2e
echo "::endgroup::"
test_solaris:
name: Run end-to-end tests on Solaris
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: test-e2e
uses: vmactions/solaris-vm@v1
with:
copyback: false
envs: 'GO_VERSION_SOLARIS'
usesh: true
prepare: |
pkg update
pkg install curl gnu-tar git gnu-make gnu-sed gnu-grep go # python (build 11.4.42.0.0.111.0 ships with 3.7.10)
run: |
echo "::group::Setup prerequisites"
set -eu
mkdir bin
export PATH=$(pwd)/bin:$PATH
GOGZ="go${GO_VERSION_DRAGONFLY}.solaris-amd64.tar.gz"
wget https://go.dev/dl/${GOGZ}
gtar xzf ${GOGZ}
ln -s $(which ggrep) $(pwd)/bin/grep
ln -s $(which gmake) $(pwd)/bin/make
ln -s $(which gsed) $(pwd)/bin/sed
ln -s $(which gtar) $(pwd)/bin/tar
export PATH=$(pwd)/bin:$PATH
echo "::endgroup::"
echo "::group::Print environment information"
uname -a
echo "GOOS: $(go env GOOS)"
echo "GOARCH: $(go env GOARCH)"
echo "::endgroup::"
echo "::group::Run End-to-End Tests"
git config --global --add safe.directory $(pwd)
make test-e2e
echo "::endgroup::"
5 changes: 0 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ require (
github.com/prometheus/exporter-toolkit v0.13.2
github.com/prometheus/procfs v0.15.1
github.com/safchain/ethtool v0.5.9
github.com/spf13/cobra v1.8.1
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0
golang.org/x/sys v0.28.0
howett.net/plist v1.0.1
Expand All @@ -40,7 +39,6 @@ require (
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/dennwc/ioctl v1.0.0 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
Expand All @@ -50,7 +48,6 @@ require (
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/siebenmann/go-kstat v0.0.0-20210513183136-173c9b0a9973 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/xhit/go-str2duration/v2 v2.1.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
Expand All @@ -62,5 +59,3 @@ require (
google.golang.org/protobuf v1.35.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)

//replace github.com/prometheus/procfs => github.com/rexagod/procfs v0.0.0-20241124020414-857c5b813f1b
8 changes: 0 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ github.com/cilium/ebpf v0.12.3 h1:8ht6F9MquybnY97at+VDZb3eQQr8ev79RueWeVaEcG4=
github.com/cilium/ebpf v0.12.3/go.mod h1:TctK1ivibvI3znr66ljgi4hqOT8EYQjz1KWBfb1UVgM=
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand All @@ -33,8 +32,6 @@ github.com/hodgesds/perf-utils v0.7.0 h1:7KlHGMuig4FRH5fNw68PV6xLmgTe7jKs9hgAcEA
github.com/hodgesds/perf-utils v0.7.0/go.mod h1:LAklqfDadNKpkxoAJNHpD5tkY0rkZEVdnCEWN5k4QJY=
github.com/illumos/go-kstat v0.0.0-20210513183136-173c9b0a9973 h1:hk4LPqXIY/c9XzRbe7dA6qQxaT6Axcbny0L/G5a4owQ=
github.com/illumos/go-kstat v0.0.0-20210513183136-173c9b0a9973/go.mod h1:PoK3ejP3LJkGTzKqRlpvCIFas3ncU02v8zzWDW+g0FY=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA=
github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
Expand Down Expand Up @@ -90,15 +87,10 @@ github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0leargg
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/safchain/ethtool v0.5.9 h1://6RvaOKFf3nQ0rl5+8zBbE4/72455VC9Jq61pfq67E=
github.com/safchain/ethtool v0.5.9/go.mod h1:w8oSsZeowyRaM7xJJBAbubzzrOkwO8TBgPSEqPP/5mg=
github.com/siebenmann/go-kstat v0.0.0-20210513183136-173c9b0a9973 h1:GfSdC6wKfTGcgCS7BtzF5694Amne1pGCSTY252WhlEY=
github.com/siebenmann/go-kstat v0.0.0-20210513183136-173c9b0a9973/go.mod h1:G81aIFAMS9ECrwBYR9YxhlPjWgrItd+Kje78O6+uqm8=
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
Expand Down
66 changes: 28 additions & 38 deletions tools/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,49 +19,39 @@ import (
"os"
"path/filepath"
"runtime"

"github.com/spf13/cobra"
)

func main() {
var rootCmd = &cobra.Command{}

var matchCmd = &cobra.Command{
Use: "match [file]",
Short: "Check whether the file matches the context.",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
// For debugging purposes, allow overriding these.
goos, found := os.LookupEnv("GOHOSTOS")
if !found {
goos = runtime.GOOS
}
goarch, found := os.LookupEnv("GOARCH")
if !found {
goarch = runtime.GOARCH
}
ctx := build.Context{
GOOS: goos,
GOARCH: goarch,
}
abs, err := filepath.Abs(args[0])
if err != nil {
panic(err)
}
match, err := ctx.MatchFile(filepath.Dir(abs), filepath.Base(abs))
if err != nil {
fmt.Println("Error:", err)
os.Exit(1)
}
if match {
os.Exit(0)
}
os.Exit(1)
},
if len(os.Args) != 2 {
fmt.Println(`
Usage: match [file]`)
os.Exit(1)
}

rootCmd.AddCommand(matchCmd)
if err := rootCmd.Execute(); err != nil {
// For debugging purposes, allow overriding these.
goos, found := os.LookupEnv("GOHOSTOS")
if !found {
goos = runtime.GOOS
}
goarch, found := os.LookupEnv("GOARCH")
if !found {
goarch = runtime.GOARCH
}
ctx := build.Context{
GOOS: goos,
GOARCH: goarch,
}
abs, err := filepath.Abs(os.Args[1])
if err != nil {
panic(err)
}
match, err := ctx.MatchFile(filepath.Dir(abs), filepath.Base(abs))
if err != nil {
fmt.Println("Error:", err)
os.Exit(1)
}
if match {
os.Exit(0)
}
os.Exit(1)
}

0 comments on commit 885e898

Please sign in to comment.