Skip to content

Commit

Permalink
ci: add windows to test matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
YOU54F committed Jul 4, 2024
1 parent 2233ce1 commit bde80cf
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 12 deletions.
27 changes: 22 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ name: Test
env:
PACT_BROKER_BASE_URL: https://testdemo.pactflow.io
PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}
REACT_APP_API_BASE_URL: http://localhost:8080
PACT_DO_NOT_TRACK: true
APP_SHA: ${{ github.sha }}
APP_REF: ${{ github.ref }}
LD_LIBRARY_PATH: /tmp
PACT_GO_LIB_DOWNLOAD_PATH: /tmp
LOG_LEVEL: debug
LOG_LEVEL: DEBUG
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
Expand All @@ -25,7 +24,7 @@ jobs:
1.21.x,
1.22.x,
]
os: [ubuntu-latest]
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
Expand All @@ -39,14 +38,32 @@ jobs:
distribution: 'zulu'
java-version: '17'
- name: Test
if: matrix.os == 'ubuntu-latest'
run: APP_BRANCH=${APP_REF:11} DOCKER_GATEWAY_HOST=172.17.0.1 DOCKER_HOST_HTTP="http://172.17.0.1" make
- name: Set CGO_LDFLAGS / pact_ffi lib on PATH, and skip Avro plugin download
if: matrix.os == 'windows-latest'
run: |
"CGO_LDFLAGS=-L$env:TMP" >> $env:GITHUB_ENV
"$env:TMP" >> $env:GITHUB_PATH
"SKIP_PLUGIN_AVRO=1" >> $env:GITHUB_ENV
"SKIP_PLUGIN_PROTOBUF=1" >> $env:GITHUB_ENV
"SKIP_PLUGIN_GO=1" >> $env:GITHUB_ENV
"SKIP_PLUGIN_CSV=1" >> $env:GITHUB_ENV
- name: Test (unit)
if: matrix.os != 'ubuntu-latest'
run: make test
- name: Test (pact)
if: matrix.os != 'ubuntu-latest'
run: make pact_local
- name: Install goveralls
if: matrix.os != 'windows-latest'
run: go install github.com/mattn/goveralls@latest
- name: Send coverage
if: matrix.os != 'windows-latest'
run: goveralls -coverprofile=coverage.txt -service=github -parallel
- uses: actions/upload-artifact@v4
with:
name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.go-version }}.zip
name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.go-version }}-${{ matrix.os }}.zip
path: ~/.pact/plugins/**/plugin.log
if: ${{ always() }}

Expand Down
21 changes: 14 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ PLUGIN_PACT_MATT_VERSION=0.1.1
PLUGIN_PACT_AVRO_VERSION=0.0.5

ci:: docker deps clean bin test pact
PACT_DOWNLOAD_DIR=/tmp
ifeq ($(OS),Windows_NT)
PACT_DOWNLOAD_DIR=$$TMP
endif

# Run the ci target from a developer machine with the environment variables
# set as if it was on Travis CI.
Expand Down Expand Up @@ -39,10 +43,6 @@ clean:
rm -rf build output dist examples/pacts

deps: download_plugins
@echo "--- 🐿 Fetching build dependencies "
cd /tmp; \
go install github.com/mitchellh/gox@latest; \
cd -

download_plugins:
@echo "--- 🐿 Installing plugins"; \
Expand Down Expand Up @@ -84,29 +84,36 @@ cli:

install: bin
echo "--- 🐿 Installing Pact FFI dependencies"
./build/pact-go -l DEBUG install --libDir /tmp
./build/pact-go -l DEBUG install --libDir $(PACT_DOWNLOAD_DIR)

pact: clean install docker
@echo "--- 🔨 Running Pact examples"
go test -v -tags=consumer -count=1 github.com/pact-foundation/pact-go/v2/examples/...
make publish
go test -v -timeout=30s -tags=provider -count=1 github.com/pact-foundation/pact-go/v2/examples/...
pact_local: clean download_plugins install
@echo "--- 🔨 Running Pact examples"
go test -v -tags=consumer -count=1 github.com/pact-foundation/pact-go/v2/examples/...
SKIP_PUBLISH=true go test -v -timeout=30s -tags=provider -count=1 github.com/pact-foundation/pact-go/v2/examples/...

publish:
@echo "-- 📃 Publishing pacts"
@"${PACT_CLI}" publish ${PWD}/examples/pacts --consumer-app-version ${APP_SHA} --tag ${APP_BRANCH} --tag prod

release:
echo "--- 🚀 Releasing it"
"$(CURDIR)/scripts/release.sh"

ifeq ($(OS),Windows_NT)
SKIP_TESTS+= --test.skip TestHandleBasedMessageTestsWithBinary
endif

test: deps install
@echo "--- ✅ Running tests"
@if [ -f coverage.txt ]; then rm coverage.txt; fi;
@echo "mode: count" > coverage.txt
@for d in $$(go list ./... | grep -v vendor | grep -v examples); \
do \
go test -v -race -coverprofile=profile.out -covermode=atomic $$d; \
go test -v -race -coverprofile=profile.out -covermode=atomic $$d $(SKIP_TESTS); \
if [ $$? != 0 ]; then \
exit 1; \
fi; \
Expand Down

0 comments on commit bde80cf

Please sign in to comment.