Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub Workflow: tests #89

Merged
merged 7 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 2 additions & 35 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
version: 2

templates:
golang-template: &golang-template
docker:
- image: ghcr.io/hugelgupf/vmtest/ci-amd64:main
working_directory: /home/circleci/go/src/github.com/hugelgupf/p9
environment:
- CGO_ENABLED: 0

workflows:
version: 2
build:
jobs:
- tidy
- build:
requires:
- tidy
- test:
requires:
- tidy

jobs:
tidy:
<<: *golang-template
docker:
- image: cimg/go:1.21.5
steps:
- checkout
- run: go env
Expand All @@ -42,23 +29,3 @@ jobs:
- run:
name: gofmt
command: test -z "$(gofmt -s -l $(find -name '*.go'))"

test:
<<: *golang-template
steps:
- checkout
- run: go env
- run: go test -timeout 15m -v ./...
- run: CGO_ENABLED=1 go test -race -timeout 15m -v ./...

build:
<<: *golang-template
steps:
- checkout
- run: go env
- run: |
go install github.com/mitchellh/gox@latest

# Exclude darwin/arm(64?).
gox -osarch="darwin/amd64" ./...
gox -parallel=2 -os="windows linux freebsd netbsd openbsd solaris" -arch="386 amd64 arm arm64 ppc64 ppc64le s390x mips mipsle mips64 mips64le" ./...
180 changes: 143 additions & 37 deletions .github/workflows/p9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,157 @@ on:
pull_request:
branches: [ main ]

jobs:
# Cancel running workflows on new push to a PR.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build
strategy:
matrix:
goos: ['linux', 'windows', 'openbsd', 'freebsd', 'netbsd']
goarch: ['386', 'amd64', 'arm', 'arm64']
include:
- goos: 'darwin'
goarch: 'arm64'
- goos: 'solaris'
goarch: 'amd64'
- goos: 'linux'
goarch: 'mips'
- goos: 'linux'
goarch: 'mips64'
- goos: 'linux'
goarch: 'mipsle'
- goos: 'linux'
goarch: 'mips64le'
- goos: 'linux'
goarch: 'ppc64'
- goos: 'linux'
goarch: 'ppc64le'
- goos: 'linux'
goarch: 'riscv64'
exclude:
- goos: 'netbsd'
goarch: 'arm64'

runs-on: ubuntu-latest
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.21.x'
- name: Build
run: go build -v ./...

test:
name: Unit test
strategy:
matrix:
go-version: ['1.21.x']
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
runs-on: ${{ matrix.platform }}
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.18
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...
- uses: actions/checkout@v4
- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

- name: Build
run: go build -v ./...

- name: Test
run: go test -v -covermode atomic -coverpkg ./... -coverprofile cover.out ./...

- name: Archive coverage artifacts
uses: actions/upload-artifact@v3
with:
name: coverage
path: cover.out

- name: Race
run: go test -race -timeout 15m -v ./...

- uses: codecov/codecov-action@v4-beta
env:
CODECOV_TOKEN: '19f1ec66-d755-4010-bc76-0c8091d231c3'
with:
flags: ${{ matrix.platform }}-unit
fail_ci_if_error: true
verbose: true

fuzz:
name: Fuzz
runs-on: [ubuntu-latest]
needs: [build]
steps:
- name: Build Fuzzers
id: build
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: 'p9'
dry-run: false

- name: Run Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
oss-fuzz-project-name: 'p9'
fuzz-seconds: 600
dry-run: false

- name: Upload Crash
uses: actions/upload-artifact@v1
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
path: ./out/artifacts
- name: Build Fuzzers
id: build
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: 'p9'
dry-run: false

- name: Run Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
oss-fuzz-project-name: 'p9'
fuzz-seconds: 600
dry-run: false

- name: Upload Crash
uses: actions/upload-artifact@v1
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
path: ./out/artifacts

vmtest:
name: VM tests
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ '1.21.x' ]
vmarch: [ 'amd64', 'arm', 'arm64' ]
include:
# QEMU's -M virt only supports GOARM=5, so add goarm=5 only for
# arm configs
- vmarch: arm
goarm: '5'

env:
GO_VERSION: ${{ matrix.go-version }}
VMTEST_ARCH: ${{ matrix.vmarch }}
GOARM: ${{ matrix.goarm }}

steps:
- uses: actions/checkout@v4
- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

- name: Build runvm tool
run: go install github.com/hugelgupf/vmtest/tools/runvmtest@latest

- name: Test
run: |
mkdir gocov
GOCOVERDIR=$(pwd)/gocov \
VMTEST_GO_PROFILE=vmcoverage.txt runvmtest -- \
go test -v -coverpkg=./... -covermode=atomic \
-coverprofile=coverage.txt ./...

- uses: codecov/codecov-action@v4-beta
env:
CODECOV_TOKEN: '19f1ec66-d755-4010-bc76-0c8091d231c3'
with:
flags: ubuntu-vm-${{ matrix.vmarch }}
fail_ci_if_error: true
verbose: true
env_vars: GO_VERSION,VMTEST_ARCH
38 changes: 20 additions & 18 deletions fsimpl/composefs/composefs_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,27 @@ func TestLinuxClient(t *testing.T) {

// Run the read tests from fsimpl/test/rovmtests.
vmtest.RunGoTestsInVM(t, []string{"github.com/hugelgupf/p9/fsimpl/test/rovmtests"},
vmtest.WithMergedInitramfs(uroot.Opts{
Commands: uroot.BusyBoxCmds(
"github.com/u-root/u-root/cmds/core/dhclient",
),
ExtraFiles: []string{
fmt.Sprintf("%s:etc/want.json", filepath.Join(dir, "want.json")),
},
}),
vmtest.WithQEMUFn(
qemu.WithAppendKernel(fmt.Sprintf("P9_PORT=%d P9_TARGET=192.168.0.2", serverPort)),
// 192.168.0.0/24
vmdriver.HostNetwork(&net.IPNet{
IP: net.IP{192, 168, 0, 0},
Mask: net.CIDRMask(24, 32),
}),
qemu.WithVMTimeout(30*time.Second),
qemu.WithTask(func(ctx context.Context, n *qemu.Notifications) error {
return s.ServeContext(ctx, serverSocket)
vmtest.WithVMOpt(
vmtest.WithMergedInitramfs(uroot.Opts{
Commands: uroot.BusyBoxCmds(
"github.com/u-root/u-root/cmds/core/dhclient",
),
ExtraFiles: []string{
fmt.Sprintf("%s:etc/want.json", filepath.Join(dir, "want.json")),
},
}),
vmtest.WithQEMUFn(
qemu.WithAppendKernel(fmt.Sprintf("P9_PORT=%d P9_TARGET=192.168.0.2", serverPort)),
// 192.168.0.0/24
vmdriver.HostNetwork(&net.IPNet{
IP: net.IP{192, 168, 0, 0},
Mask: net.CIDRMask(24, 32),
}),
qemu.WithVMTimeout(30*time.Second),
qemu.WithTask(func(ctx context.Context, n *qemu.Notifications) error {
return s.ServeContext(ctx, serverSocket)
}),
),
),
)
}
Loading