Skip to content

Commit

Permalink
Switch to GitHub Actions
Browse files Browse the repository at this point in the history
TravisCI not supported anymore.

Signed-off-by: Andrea Barberio <[email protected]>
  • Loading branch information
insomniacslk committed Mar 15, 2021
1 parent 28f7414 commit c510608
Show file tree
Hide file tree
Showing 7 changed files with 157 additions and 103 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Lint

on:
push:
tags:
- v*
branches:
- master
pull_request:

jobs:
golangci:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: latest

# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true then the action will use pre-installed Go
# skip-go-installation: true
# checklicenses:
# name: checklicenses
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - name: check license headers
# run: |
# set -exu
# go get -u github.com/u-root/u-root/tools/checklicenses
# $(go env GOPATH)/bin/checklicenses -c .ci/checklicenses_config.json
70 changes: 70 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Tests

on: [push, pull_request]

jobs:
unit-tests:
runs-on: ubuntu-latest
strategy:
matrix:
go: ['1.13', '1.14', '1.15', '1.16']
env:
GO111MODULE: on
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
stable: false
go-version: ${{ matrix.go }}
- name: run unit tests
run: |
go get -v -t ./...
echo "" > "${GITHUB_WORKSPACE}"/coverage.txt
for d in $(go list ./...); do
go test -v -race -coverprofile=profile.out -covermode=atomic "${d}"
if [ -f profile.out ]; then
cat profile.out >> "${GITHUB_WORKSPACE}"/coverage.txt
rm profile.out
fi
done
- name: report coverage to codecov
uses: codecov/codecov-action@v1
with:
files: coverage.txt
flags: unittests
fail_ci_if_error: true
verbose: true
integration-tests:
runs-on: ubuntu-latest
strategy:
matrix:
go: ['1.13', '1.14', '1.15', '1.16']
env:
GO111MODULE: on
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
stable: false
go-version: ${{ matrix.go }}
- name: run integ tests
run: |
go get -v -t -tags=integration ./...
echo "" > "${GITHUB_WORKSPACE}"/coverage.txt
for d in $(go list -tags=integration ./...); do
go test -c -tags=integration -v -race -coverprofile=profile.out -covermode=atomic "${d}"
testbin="./$(basename $d).test"
# only run it if it was built - i.e. if there are integ tests
test -x "${testbin}" && sudo "./${testbin}"
if [ -f profile.out ]; then
cat profile.out >> "${GITHUB_WORKSPACE}"/coverage.txt
rm profile.out
fi
done
- name: report coverage to codecov
uses: codecov/codecov-action@v1
with:
files: coverage.txt
flags: integtests
fail_ci_if_error: true
verbose: true
38 changes: 0 additions & 38 deletions .travis.yml

This file was deleted.

8 changes: 0 additions & 8 deletions .travis/linters.sh

This file was deleted.

37 changes: 0 additions & 37 deletions .travis/tests.sh

This file was deleted.

1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
Expand Down
67 changes: 47 additions & 20 deletions netboot/netconf_integ_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
package netboot

import (
"fmt"
"io/ioutil"
"log"
"net"
"testing"
"time"
Expand All @@ -11,10 +14,9 @@ import (
"github.com/stretchr/testify/require"
)

// Travis-CI uses ens4, and this test assumes that such interface
// exists and is configurable. If you are running this test locally,
// you may need to adjust this value.
var ifname = "ens4"
// The test assumes that the interface exists and is configurable.
// If you are running this test locally, you may need to adjust this value.
var ifname = "eth0"

func TestIfUp(t *testing.T) {
iface, err := IfUp(ifname, 2*time.Second)
Expand All @@ -28,24 +30,49 @@ func TestIfUpTimeout(t *testing.T) {
}

func TestConfigureInterface(t *testing.T) {
nc := NetConf{
Addresses: []AddrConf{
AddrConf{IPNet: net.IPNet{IP: net.ParseIP("10.20.30.40")}},
// Linux-only. `netboot.ConfigureInterface` writes to /etc/resolv.conf when
// `NetConf.DNSServers` is set. In this test we make a backup of resolv.conf
// and subsequently restore it. This is really ugly, and not safe if
// multiple tests do the same.
resolvconf, err := ioutil.ReadFile("/etc/resolv.conf")
if err != nil {
panic(fmt.Sprintf("Failed to read /etc/resolv.conf: %v", err))
}
type testCase struct {
Name string
NetConf *NetConf
}
testCases := []testCase{
{
Name: "just IP addr",
NetConf: &NetConf{
Addresses: []AddrConf{
AddrConf{IPNet: net.IPNet{IP: net.ParseIP("10.20.30.40")}},
},
},
},
{
Name: "IP addr, DNS, and routers",
NetConf: &NetConf{
Addresses: []AddrConf{
AddrConf{IPNet: net.IPNet{IP: net.ParseIP("10.20.30.40")}},
},
DNSServers: []net.IP{net.ParseIP("8.8.8.8")},
DNSSearchList: []string{"slackware.it"},
Routers: []net.IP{net.ParseIP("10.20.30.254")},
},
},
}
err := ConfigureInterface(ifname, &nc)
require.NoError(t, err)
}
for _, tc := range testCases {
t.Run(tc.Name, func(t *testing.T) {
require.NoError(t, ConfigureInterface(ifname, tc.NetConf))

func TestConfigureInterfaceWithRouteAndDNS(t *testing.T) {
nc := NetConf{
Addresses: []AddrConf{
AddrConf{IPNet: net.IPNet{IP: net.ParseIP("10.20.30.40")}},
},
DNSServers: []net.IP{net.ParseIP("8.8.8.8")},
DNSSearchList: []string{"slackware.it"},
Routers: []net.IP{net.ParseIP("10.20.30.254")},
// after the test, restore the content of /etc/resolv.conf . The permissions
// are used only if it didn't exist.
if err = ioutil.WriteFile("/etc/resolv.conf", resolvconf, 0644); err != nil {
panic(fmt.Sprintf("Failed to restore /etc/resolv.conf: %v", err))
}
log.Printf("Restored /etc/resolv.conf")
})
}
err := ConfigureInterface(ifname, &nc)
require.NoError(t, err)
}

0 comments on commit c510608

Please sign in to comment.