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: MacOS arm64/x86_64 + Dockerfile #416

Closed
wants to merge 19 commits into from
Closed
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
88 changes: 77 additions & 11 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
APP_SHA: ${{ github.sha }}
APP_REF: ${{ github.ref }}
LD_LIBRARY_PATH: /tmp
PACT_GO_LIB_DOWNLOAD_PATH: /tmp
LOG_LEVEL: debug
LOG_LEVEL: info
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
Expand All @@ -19,34 +18,101 @@ jobs:
go-version: [ # https://endoflife.date/go
# 1.17.x, # Ended 02 Aug 2022
# 1.18.x, # Ended 01 Feb 2023
1.19.x,
1.20.x,
1.21.x
# 1.19.x, # Ended 8 Aug 2023
'1.20', # Ended 06 Feb 2024
'1.21',
'1.22'
]
os: [ubuntu-latest]
os: [
ubuntu-22.04, # We use this OS to run a build against our docker image
ubuntu-latest,
# windows-latest,
macos-12,
macos-14
]
experimental: [false]
exclude:
- go-version: '1.22'
os: ubuntu-latest
- go-version: '1.22'
os: ubuntu-22.04
- go-version: '1.22'
os: macos-12
include:
- go-version: '1.22'
os: ubuntu-latest
experimental: true
- go-version: '1.22'
os: ubuntu-22.04
experimental: true
- go-version: '1.22'
os: macos-12
experimental: true
fail-fast: false
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
name: ${{ matrix.os == 'ubuntu-22.04' && 'linux-docker' || matrix.os }}-${{ matrix.go-version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Go
if: matrix.os != 'ubuntu-22.04'
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- uses: actions/setup-java@v4 # Needed for the Avro example
if: matrix.os != 'ubuntu-22.04'
with:
distribution: 'zulu'
java-version: '17'
- name: Test
run: APP_BRANCH=${APP_REF:11} DOCKER_GATEWAY_HOST=172.17.0.1 DOCKER_HOST_HTTP="http://172.17.0.1" make
- run: brew install protobuf
if: matrix.os == 'macos-14'
- name: Unit Test
if: matrix.os != 'ubuntu-22.04'
run: make ci_unit
- name: Build amd64 dockerfile
if: matrix.os == 'ubuntu-22.04'
run: |
docker build \
--platform linux/amd64 \
--build-arg VERSION=${{ matrix.go-version }} \
-f Dockerfile \
-t pactfoundation/pact-go-test-${{ matrix.go-version }} .
- name: Unit Test (amd64 docker)
if: matrix.os == 'ubuntu-22.04'
run: |
docker run \
--platform linux/amd64 \
--rm pactfoundation/pact-go-test-${{ matrix.go-version }}
- name: Examples with Standalone (amd64 docker)
if: matrix.os == 'ubuntu-22.04'
run: |
docker run \
--platform linux/amd64 \
-e PACT_BROKER_BASE_URL \
-e PACT_BROKER_TOKEN \
-e LOG_LEVEL \
-e APP_SHA \
-e APP_BRANCH=${APP_REF:11} \
--rm \
pactfoundation/pact-go-test-${{ matrix.go-version }} \
/bin/sh -c "make download_plugins && make install-pact-ruby-cli && PACT_TOOL=ruby make pact"
- name: Examples with Standalone
if: matrix.os != 'ubuntu-22.04'
run: |
make install-pact-ruby-standalone
APP_BRANCH=${APP_REF:11} PACT_TOOL=standalone make ci_hosted_examples
- name: Install goveralls
run: go install github.com/mattn/goveralls@latest
if: runner.os == 'Linux' && matrix.os != 'ubuntu-22.04'
- name: Send coverage
run: goveralls -coverprofile=coverage.txt -service=github -parallel
if: runner.os == 'Linux' && matrix.os != 'ubuntu-22.04'
- 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() }}
if: ${{ always() }} && matrix.os != 'ubuntu-22.04'

finish:
needs: test
Expand All @@ -56,4 +122,4 @@ jobs:
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
parallel-finished: true
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@ coverage.txt
.vscode

# Dependencies
pact
pact

# pact files
examples/pacts/*
93 changes: 92 additions & 1 deletion DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,95 @@ The previous major version. Only bug fixes and security updates will be consider

### `master`

The `2.x.x` release line. Current major version.
The `2.x.x` release line. Current major version.


## Running locally

### Pre-reqs

- GoLang

### Unit tests

```sh
make ci_unit
```

### E2E Examples

#### E2E Pre-reqs

- Pact CLI tools (for examples). Available via
- Docker
- Ruby
- Standalone package
-
- Pact Broker
- Locally via Docker
- Hosted (OSS or PactFlow)
- Java
- For Avro example
- Protobuf Compiler
- For gRPC / Protobuf examples

#### Running

With Docker

```sh
APP_SHA=foo make ci_examples
```

Without Docker

```sh
APP_SHA=foo make ci_hosted_examples
```

You will need to use a Pact Broker to run the examples.

You can either use an OSS Pact Broker and set the following env vars

- `PACT_BROKER_BASE_URL`
- `PACT_BROKER_USERNAME`
- `PACT_BROKER_PASSWORD`

Or a PactFlow Broker

- `PACT_BROKER_BASE_URL`
- `PACT_BROKER_TOKEN`

To use the different cli tools, use

- `PACT_TOOL=standalone make ci_examples`
- Install it `make install-pact-ruby-standalone`
- https://github.com/pact-foundation/pact-ruby-standalone
- `PACT_TOOL=ruby make ci_examples`
- Install it `make install-pact-ruby-cli`
- Requires ruby
- https://github.com/pact-foundation/pact_broker-client
- `PACT_TOOL=docker make ci_examples`
- Requires docker
- https://github.com/pact-foundation/pact-ruby-cli
You will want to install them first

### Docker

Build an image from the repo

```sh
make docker_build
```

Run the repo's unit test

```
make docker_run_test
```

Run the repo's examples

```
make docker_run_examples
```
13 changes: 5 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
FROM golang:1.22.3

# Install pact ruby standalone binaries
RUN curl -LO https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v2.0.3/pact-2.0.3-linux-x86_64.tar.gz; \
tar -C /usr/local -xzf pact-2.0.3-linux-x86_64.tar.gz; \
rm pact-2.0.3-linux-x86_64.tar.gz

ENV PATH /usr/local/pact/bin:$PATH
ARG VERSION=latest
FROM golang:${VERSION}

RUN apt-get update && apt-get install -y openjdk-17-jre file protobuf-compiler ruby ruby-dev ruby-bundler
COPY . /go/src/github.com/pact-foundation/pact-go

WORKDIR /go/src/github.com/pact-foundation/pact-go

CMD ["make", "test"]
10 changes: 10 additions & 0 deletions Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ARG VERSION=latest
FROM golang:${VERSION}-alpine

RUN apk add --no-cache curl gcc musl-dev gzip openjdk17-jre bash protoc protobuf-dev make file

COPY . /go/src/github.com/pact-foundation/pact-go

WORKDIR /go/src/github.com/pact-foundation/pact-go

CMD ["make", "test"]
Loading
Loading