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

Ci/test x plat #351

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 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
31 changes: 31 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
test: &TEST
test_script: make test

linux_arm64_task:
env:
SKIP_PLUGIN_AVRO: "true"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming this (and related references) was put in the "do it later" basket?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah avro was failing, needs java plus other yaks.

matrix:
- VERSION: 1.19
- VERSION: 1.20
- VERSION: 1.21
# name: Tests (Go $VERSION)
arm_container:
image: golang:$VERSION
<<: *TEST

macos_arm64_task:
macos_instance:
image: ghcr.io/cirruslabs/macos-ventura-base:latest
golang_pre_req_script: brew install go@$VERSION
cirrus_cli_pre_req_script: chmod +x scripts/*.sh
plugin_protobuf_pre_req_script: brew install protobuf
# plugin_avro_pre_req_script: brew install openjdk@17 && java --version
env:
PATH: "/opt/homebrew/opt/go@$VERSION/bin:$PATH" # Needed golang
# PATH: "/opt/homebrew/opt/openjdk@17/bin:$PATH" # Needed for Avro Plugin
SKIP_PLUGIN_AVRO: "true"
matrix:
- VERSION: 1.19
- VERSION: 1.20
- VERSION: 1.21
<<: *TEST
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,25 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true

test-other-os:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why you didn't just merge this into the test job above?

This doesn't run the examples, but just the tests from what I can see (which is probably fine, if we ever build the compatibility suite for proper feature regression testing).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought

  1. try and get build and unit tests working first x plat
  2. then move onto examples
    • consider examples as 2nd class compared to main code that is currently untested in CI x-plat

not sure how yaks we would need to end up shaving to get this working, so thought I would just create a seperate job to check whats needed for these non linux os's, and then could roll everything back together intro one job

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, I thought so. It's better than where we were, but just wanted to clarify.

strategy:
matrix:
go-version: [ # https://endoflife.date/go
1.19.x,
1.20.x,
1.21.x
]
os: [macos-latest,windows-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- run: make test
env:
SKIP_PLUGIN_AVRO: true
20 changes: 14 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ TEST?=./...
DOCKER_HOST_HTTP?="http://host.docker.internal"
PACT_CLI="docker run --rm -v ${PWD}:${PWD} -e PACT_BROKER_BASE_URL=$(DOCKER_HOST_HTTP) -e PACT_BROKER_USERNAME -e PACT_BROKER_PASSWORD pactfoundation/pact-cli"

ifeq ($(OS),Windows_NT)
EXT=.exe
endif

ci:: docker deps clean bin test pact

# Run the ci target from a developer machine with the environment variables
Expand Down Expand Up @@ -41,12 +45,16 @@ deps: download_plugins
cd -

download_plugins:
@echo "--- 🐿 Installing plugins"; \
./scripts/install-cli.sh
~/.pact/bin/pact-plugin-cli -y install https://github.com/pactflow/pact-protobuf-plugin/releases/tag/v-0.3.4
~/.pact/bin/pact-plugin-cli -y install https://github.com/pact-foundation/pact-plugins/releases/tag/csv-plugin-0.0.1
~/.pact/bin/pact-plugin-cli -y install https://github.com/mefellows/pact-matt-plugin/releases/tag/v0.0.9
~/.pact/bin/pact-plugin-cli -y install https://github.com/austek/pact-avro-plugin/releases/tag/v0.0.3
if [ -z $$SKIP_PLUGINS ]; then\
echo "--- 🐿 Installing plugins";\
./scripts/install-cli.sh;\
$$HOME/.pact/bin/pact-plugin-cli$(EXT) -y install https://github.com/pactflow/pact-protobuf-plugin/releases/tag/v-0.3.4;\
$$HOME/.pact/bin/pact-plugin-cli$(EXT) -y install https://github.com/you54f/pact-plugins/releases/tag/csv-plugin-0.0.4;\
$$HOME/.pact/bin/pact-plugin-cli$(EXT) -y install https://github.com/mefellows/pact-matt-plugin/releases/tag/v0.0.9;\
if [ -z $$SKIP_PLUGIN_AVRO ]; then\
$$HOME/.pact/bin/pact-plugin-cli$(EXT) -y install https://github.com/austek/pact-avro-plugin/releases/tag/v0.0.3; \
fi \
fi

cli:
@if [ ! -d pact/bin ]; then\
Expand Down
4 changes: 2 additions & 2 deletions command/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package command

import (
"fmt"
"io/ioutil"
"io"
"log"
"os"

Expand Down Expand Up @@ -50,6 +50,6 @@ func setLogLevel(verbose bool, level string) {
log.SetOutput(filter)

if !verbose {
log.SetOutput(ioutil.Discard)
log.SetOutput(io.Discard)
}
}
4 changes: 2 additions & 2 deletions command/root_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package command

import (
"io/ioutil"
"io"
"log"
"os"
"strings"
Expand Down Expand Up @@ -55,7 +55,7 @@ func captureOutput(action func()) string {
action()

w.Close()
out, _ := ioutil.ReadAll(r)
out, _ := io.ReadAll(r)
os.Stderr = rescueStderr

return strings.TrimSpace(string(out))
Expand Down
2 changes: 1 addition & 1 deletion doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ An example route using the standard Go http package might look like this:
// Retrieve the Provider State
var state types.ProviderState

body, _ := ioutil.ReadAll(req.Body)
body, _ := io.ReadAll(req.Body)
req.Body.Close()
json.Unmarshal(body, &state)

Expand Down
4 changes: 2 additions & 2 deletions examples/avro/avro_consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package avro

import (
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -82,7 +82,7 @@ func callServiceHTTP(msc consumer.MockServerConfig) (*User, error) {
return nil, err
}

bytes, err := ioutil.ReadAll(res.Body)
bytes, err := io.ReadAll(res.Body)

if err != nil {
return nil, err
Expand Down
6 changes: 3 additions & 3 deletions examples/avro/codec.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package avro

import (
"io/ioutil"


"os"
"github.com/linkedin/goavro/v2"
)

func getCodec() *goavro.Codec {
schema, err := ioutil.ReadFile("user.avsc")
schema, err := os.ReadFile("user.avsc")
if err != nil {
panic(err)
}
Expand Down
4 changes: 2 additions & 2 deletions examples/consumer_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package main

import (
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"strings"
Expand Down Expand Up @@ -188,7 +188,7 @@ var rawTest = func(query string) func(config consumer.MockServerConfig) error {
Path: "/foobar",
RawQuery: query,
},
Body: ioutil.NopCloser(strings.NewReader(`{"id": 27, "name":"billy", "lastName":"sampson", "datetime":"2021-01-01T08:00:45"}`)),
Body: io.NopCloser(strings.NewReader(`{"id": 27, "name":"billy", "lastName":"sampson", "datetime":"2021-01-01T08:00:45"}`)),
Header: make(http.Header),
}

Expand Down
4 changes: 2 additions & 2 deletions examples/grpc/routeguide/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"os"
"log"
"math"
"net"
Expand Down Expand Up @@ -155,7 +155,7 @@ func (s *routeGuideServer) loadFeatures(filePath string) {
var data []byte
if filePath != "" {
var err error
data, err = ioutil.ReadFile(filePath)
data, err = os.ReadFile(filePath)
if err != nil {
log.Fatalf("Failed to load default features: %v", err)
}
Expand Down
81 changes: 81 additions & 0 deletions examples/pacts/AvroConsumer-AvroProvider.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"consumer": {
"name": "AvroConsumer"
},
"interactions": [
{
"description": "A request to do get some Avro stuff",
"pending": false,
"pluginConfiguration": {
"avro": {
"record": "User",
"schemaKey": "1184dbf3292cee8bc7390762dd15fc52"
}
},
"request": {
"method": "GET",
"path": "/avro"
},
"response": {
"body": {
"content": "AghtYXR0",
"contentType": "avro/binary;record=User",
"contentTypeHint": "BINARY",
"encoded": "base64"
},
"headers": {
"content-type": [
"avro/binary"
]
},
"matchingRules": {
"body": {
"$.id": {
"combine": "AND",
"matchers": [
{
"match": "number"
}
]
},
"$.username": {
"combine": "AND",
"matchers": [
{
"match": "notEmpty"
}
]
}
}
},
"status": 200
},
"transport": "http",
"type": "Synchronous/HTTP"
}
],
"metadata": {
"pactRust": {
"ffi": "0.4.5",
"mockserver": "1.1.1",
"models": "1.1.2"
},
"pactSpecification": {
"version": "4.0"
},
"plugins": [
{
"configuration": {
"1184dbf3292cee8bc7390762dd15fc52": {
"avroSchema": "{\"type\":\"record\",\"name\":\"User\",\"namespace\":\"io.pact\",\"fields\":[{\"name\":\"id\",\"type\":\"long\"},{\"name\":\"username\",\"type\":\"string\"}]}"
}
},
"name": "avro",
"version": "0.0.4"
}
]
},
"provider": {
"name": "AvroProvider"
}
}
9 changes: 4 additions & 5 deletions examples/pacts/MattConsumer-MattProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"interactions": [
{
"description": "A request to do a matt",
"key": "c544877c9301bb17",
"pending": false,
"request": {
"body": {
Expand Down Expand Up @@ -42,9 +41,9 @@
],
"metadata": {
"pactRust": {
"ffi": "0.3.18",
"mockserver": "0.9.8",
"models": "1.0.2"
"ffi": "0.4.5",
"mockserver": "1.1.1",
"models": "1.1.2"
},
"pactSpecification": {
"version": "4.0"
Expand All @@ -53,7 +52,7 @@
{
"configuration": {},
"name": "matt",
"version": "0.0.7"
"version": "0.0.9"
}
]
},
Expand Down
6 changes: 3 additions & 3 deletions examples/pacts/PactGoProductAPIConsumer-PactGoProductAPI.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
],
"metadata": {
"pactRust": {
"ffi": "0.3.18",
"mockserver": "0.9.8",
"models": "1.0.2"
"ffi": "0.4.5",
"mockserver": "1.1.1",
"models": "1.1.2"
},
"pactSpecification": {
"version": "2.0.0"
Expand Down
6 changes: 3 additions & 3 deletions examples/pacts/PactGoV2Consumer-V2Provider.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@
],
"metadata": {
"pactRust": {
"ffi": "0.3.18",
"mockserver": "0.9.8",
"models": "1.0.2"
"ffi": "0.4.5",
"mockserver": "1.1.1",
"models": "1.1.2"
},
"pactSpecification": {
"version": "2.0.0"
Expand Down
6 changes: 3 additions & 3 deletions examples/pacts/PactGoV2ConsumerAllInOne-V2Provider.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@
],
"metadata": {
"pactRust": {
"ffi": "0.3.18",
"mockserver": "0.9.8",
"models": "1.0.2"
"ffi": "0.4.5",
"mockserver": "1.1.1",
"models": "1.1.2"
},
"pactSpecification": {
"version": "2.0.0"
Expand Down
6 changes: 3 additions & 3 deletions examples/pacts/PactGoV2ConsumerMatch-V2ProviderMatch.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@
],
"metadata": {
"pactRust": {
"ffi": "0.3.18",
"mockserver": "0.9.8",
"models": "1.0.2"
"ffi": "0.4.5",
"mockserver": "1.1.1",
"models": "1.1.2"
},
"pactSpecification": {
"version": "2.0.0"
Expand Down
6 changes: 3 additions & 3 deletions examples/pacts/PactGoV3Consumer-V3Provider.json
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,9 @@
],
"metadata": {
"pactRust": {
"ffi": "0.3.18",
"mockserver": "0.9.8",
"models": "1.0.2"
"ffi": "0.4.5",
"mockserver": "1.1.1",
"models": "1.1.2"
},
"pactSpecification": {
"version": "3.0.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/pacts/PactGoV3MessageConsumer-V3MessageProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
],
"metadata": {
"pactRust": {
"ffi": "0.3.18",
"models": "1.0.2"
"ffi": "0.4.5",
"models": "1.1.2"
},
"pactSpecification": {
"version": "3.0.0"
Expand Down
Loading
Loading