diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 0000000..be82e58 --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,21 @@ +--- +name: setup +description: Common tasks for preparing the environment + +runs: + using: "composite" + steps: + - uses: actions/setup-go@v5 + if: runner.os != 'Windows' + with: + go-version-file: go.mod + cache: true + # See https://github.com/actions/setup-go/pull/515 + - uses: antontroshin/setup-go@bda02de8887c9946189f81e7e59512914aeb9ea4 + if: runner.os == 'Windows' + with: + go-version-file: go.mod + cache: true + - name: install mage + run: go install github.com/magefile/mage + shell: 'bash' diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..ee85a87 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,18 @@ +--- +version: 2 +updates: + - package-ecosystem: "github-actions" + directories: + - '/' + - '/.github/actions/*' + schedule: + interval: "weekly" + day: "sunday" + time: "22:00" + reviewers: + - "elastic/observablt-ci" + - "elastic/observablt-ci-contractors" + groups: + github-actions: + patterns: + - "*" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..9934cae --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,48 @@ +name: ci + +on: + push: + pull_request: + merge_group: + +# limit the access of the generated GITHUB_TOKEN +permissions: + contents: read + +jobs: + + lint: + strategy: + matrix: + os: ['ubuntu-latest', 'windows-latest'] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup + - run: | + mage -debug check + go vet ./... + + update: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup + - name: install protoc + run: | + curl -sSfL -o protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v3.19.4/protoc-3.19.4-linux-x86_64.zip + mkdir -p $GITHUB_WORKSPACE/.protoc + unzip -o protoc.zip -d $GITHUB_WORKSPACE/.protoc + echo "$GITHUB_WORKSPACE/.protoc/bin" >> $GITHUB_PATH + + - run: mage -debug update + + test: + strategy: + matrix: + os: ['ubuntu-latest', 'windows-latest'] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup + - run: go test -v -race ./... diff --git a/pkg/client/chunk/expected_test.go b/pkg/client/chunk/expected_test.go index 0159627..a362e1f 100644 --- a/pkg/client/chunk/expected_test.go +++ b/pkg/client/chunk/expected_test.go @@ -6,6 +6,7 @@ package chunk import ( "fmt" + "runtime" "slices" "strings" "testing" @@ -254,6 +255,9 @@ func TestExpected(t *testing.T) { } func TestRecvExpected_Timestamp_Restart(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("Skipping test on Windows for now. See https://github.com/elastic/elastic-agent-client/issues/120#issuecomment-2757564351") + } firstTimestamp := time.Now() first := &proto.CheckinExpected{ FeaturesIdx: 2, diff --git a/pkg/client/chunk/observed_test.go b/pkg/client/chunk/observed_test.go index e78a6a0..9fdfeee 100644 --- a/pkg/client/chunk/observed_test.go +++ b/pkg/client/chunk/observed_test.go @@ -6,6 +6,7 @@ package chunk import ( "fmt" + "runtime" "slices" "strings" "testing" @@ -260,6 +261,9 @@ func TestObserved(t *testing.T) { } func TestRecvObserved_Timestamp_Restart(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("Skipping test on Windows for now. See https://github.com/elastic/elastic-agent-client/issues/120#issuecomment-2757564351") + } firstTimestamp := time.Now() first := &proto.CheckinObserved{ Token: "token",