Skip to content

Commit 46fb587

Browse files
authored
Merge pull request #109 from YOU54F/chore/create_dockerfiles
Chore/create dockerfiles
2 parents a0f9e9a + 42c7848 commit 46fb587

9 files changed

+516
-53
lines changed

.cirrus.yml

+205-41
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,223 @@
1+
env:
2+
PACT_VERSION: 2.0.1
3+
tag: v2.0.1
4+
5+
#####################################
6+
### BUILD & TEST STANDALONE ###
7+
#####################################
8+
# This task packages up the pact-ruby-standalone for all arches
9+
# it is used in tasks
10+
# - builder_linux_arm_task
11+
# - builder_macos_arm_task
112
BUILD_TEST_TASK_TEMPLATE: &BUILD_TEST_TASK_TEMPLATE
213
arch_check_script:
314
- uname -am
415
install_script: bundle install
516
build_script: bundle exec rake package
6-
test_script: chmod +x ./script/test.sh && ./script/test.sh
7-
8-
linux_arm64_task:
17+
test_script: chmod +x ./script/unpack-and-test.sh && ./script/unpack-and-test.sh
18+
# BINARY_ env vars are set, so we only test our platform specific pact-ruby-standalone
19+
builder_linux_arm_task:
920
env:
1021
BINARY_OS: linux
1122
BINARY_ARCH: arm64
1223
PATH: "$HOME/.rbenv/bin:/root/.rbenv/shims:$PATH"
13-
## *******************************
14-
## Fails on Ruby:3.2.2 based image - fine on ubuntu latest, but installing ruby 3.2.2 from source takes a good while (few minutes)
15-
## executing ./pact/bin/pactflow
16-
## /tmp/cirrus-ci/working-dir/pkg/pact/lib/ruby/lib/ruby/3.2.0/bundler/definition.rb:524:in `materialize': Could not find pact-1.63.0, pact-message-0.11.1, pact-mock_service-3.11.0, pact-provider-verifier-1.36.1, pact_broker-client-1.66.1, webrick-1.8.1, rack-2.2.7, pact-support-1.19.0, rack-test-2.1.0, rspec-3.12.0, term-ansicolor-1.7.1, thor-1.2)
17-
## from /tmp/cirrus-ci/working-dir/pkg/pact/lib/ruby/lib/ruby/3.2.0/bundler/definition.rb:197:in `specs'
18-
## from /tmp/cirrus-ci/working-dir/pkg/pact/lib/ruby/lib/ruby/3.2.0/bundler/definition.rb:254:in `specs_for'
19-
## from /tmp/cirrus-ci/working-dir/pkg/pact/lib/ruby/lib/ruby/3.2.0/bundler/runtime.rb:18:in `setup'
20-
## from /tmp/cirrus-ci/working-dir/pkg/pact/lib/ruby/lib/ruby/3.2.0/bundler.rb:171:in `setup'
21-
## from /tmp/cirrus-ci/working-dir/pkg/pact/lib/ruby/lib/ruby/3.2.0/bundler/setup.rb:23:in `block in <top (required)>'
22-
## from /tmp/cirrus-ci/working-dir/pkg/pact/lib/ruby/lib/ruby/3.2.0/bundler/ui/shell.rb:159:in `with_level'
23-
## from /tmp/cirrus-ci/working-dir/pkg/pact/lib/ruby/lib/ruby/3.2.0/bundler/ui/shell.rb:111:in `silence'
24-
## from /tmp/cirrus-ci/working-dir/pkg/pact/lib/ruby/lib/ruby/3.2.0/bundler/setup.rb:23:in `<top (required)>'
25-
## from <internal:/tmp/cirrus-ci/working-dir/pkg/pact/lib/ruby/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
26-
## from <internal:/tmp/cirrus-ci/working-dir/pkg/pact/lib/ruby/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
27-
## *******************************
28-
# container:
29-
# image: ruby:3.2.2
30-
# architecture: arm64
31-
# pre_req_script: |
32-
# apt update --yes && apt install --yes git curl libssl-dev libreadline-dev zlib1g-dev autoconf bison build-essential libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev zip
33-
# ruby --version
34-
# bundler --version
3524
arm_container:
36-
image: ubuntu:latest
37-
architecture: arm64
38-
install_ruby_from_source_script: |
39-
apt update --yes && apt install --yes git curl libssl-dev libreadline-dev zlib1g-dev autoconf bison build-essential libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev zip
40-
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash
41-
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
42-
source ~/.bashrc
43-
rbenv install 3.2.2
44-
rbenv global 3.2.2
45-
ruby --version
46-
bundler --version
25+
image: ruby:3.2.2-slim
26+
pre_req_script:
27+
apt update --yes && apt install --yes zip curl
4728
<< : *BUILD_TEST_TASK_TEMPLATE
48-
49-
macosx_arm64_task:
29+
binary_artifacts:
30+
path: "pkg/*"
31+
builder_macos_arm_task:
5032
macos_instance:
5133
image: ghcr.io/cirruslabs/macos-ventura-base:latest
5234
env:
5335
BINARY_OS: osx
5436
BINARY_ARCH: arm64
55-
pre_req_script:
56-
- brew install ruby
57-
- ruby --version
37+
## If you need to install Ruby from source
38+
## the image comes with 3.2.2 preinstalled
39+
# install_ruby_script:
40+
# - |
41+
# brew unlink openssl && brew link --force openssl
42+
# wget https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.2.2.tar.gz
43+
# tar xf ruby-3.2.2.tar.gz
44+
# cd ruby-3.2.2
45+
# ./configure --prefix=/Users/$USER/.rbenv/versions/3.2.2
46+
# make -j9
47+
# make install
48+
# - rbenv global 3.2.2
49+
ruby_version_script: ruby --version
5850
<< : *BUILD_TEST_TASK_TEMPLATE
51+
binary_artifacts:
52+
path: "pkg/*"
53+
54+
55+
#####################################
56+
### TESTING PUBLISHED STANDALONE ###
57+
#####################################
58+
59+
# Tests a specified version of the standalone against several types of Docker images
60+
# the tag version is set at the top of file tag: v2.0.1
61+
#
62+
# It tests a combination of Dockerfiles
63+
# The Dockerfiles are provided for users to build their own images
64+
#
65+
# - alpine arm64
66+
# - ubuntu arm64
67+
# - debian arm64
68+
# - alpine x64
69+
# - ubuntu x64
70+
# - debian x64
71+
72+
# It also tests a combination of common Docker images
73+
# - IMAGE: ruby:3.2.2-alpine
74+
# - IMAGE: node:20-alpine
75+
# - IMAGE: golang:1.20.2-alpine
76+
# - IMAGE: ruby:3.2.2-slim
77+
# - IMAGE: node:20-slim
78+
# - IMAGE: golang:1.20.2
79+
80+
## This is a yak shave relating to https://github.com/pact-foundation/pact-ruby-standalone/issues/102
81+
## pact-plugin-cli is not compatible with current guidance for alpine aarch64 with official arm64v8/alpine
82+
## This task is reused in TEST_FULL_CLI_TASK_TEMPLATE adding in the pact-plugin-cli so its tested for other combos
83+
TEST_RUBY_CLI_TASK_TEMPLATE: &TEST_RUBY_CLI_TASK_TEMPLATE
84+
arch_check_script:
85+
- uname -am
86+
test_script: | # would rather avoid the commands here, but also want to keep the images clean so they can be easily used by users
87+
pact-broker help
88+
pact-message help
89+
pact-mock-service help
90+
pact-provider-verifier help
91+
pact-stub-service help
92+
pactflow help
93+
94+
TEST_FULL_CLI_TASK_TEMPLATE: &TEST_FULL_CLI_TASK_TEMPLATE
95+
test_plugin_cli_script: pact-plugin-cli help
96+
<<: *TEST_RUBY_CLI_TASK_TEMPLATE
97+
98+
DOCKER_ARGS_ARM64_TEMPLATE: &DOCKER_ARGS_ARM64_TEMPLATE
99+
docker_arguments:
100+
PACT_VERSION: $PACT_VERSION
101+
TARGET_ARCH: arm64
102+
TARGET_PLATFORM: linux
103+
104+
DOCKER_ARGS_X64_TEMPLATE: &DOCKER_ARGS_X64_TEMPLATE
105+
docker_arguments:
106+
PACT_VERSION: $PACT_VERSION
107+
TARGET_ARCH: x86_64
108+
TARGET_PLATFORM: linux
109+
110+
## Test published standalone against arm64 Dockerfiles provided for users
111+
alpine_arm64_task:
112+
only_if: $CIRRUS_BRANCH == 'master' || $CIRRUS_PR != ''
113+
arm_container:
114+
dockerfile: Dockerfile.alpine.arm64
115+
<<: *DOCKER_ARGS_ARM64_TEMPLATE
116+
<<: *TEST_RUBY_CLI_TASK_TEMPLATE
117+
ubuntu_arm64_task:
118+
only_if: $CIRRUS_BRANCH == 'master'
119+
arm_container:
120+
dockerfile: Dockerfile.ubuntu
121+
<<: *DOCKER_ARGS_ARM64_TEMPLATE
122+
<<: *TEST_RUBY_CLI_TASK_TEMPLATE
123+
debian_arm64_task:
124+
only_if: $CIRRUS_BRANCH == 'master'
125+
arm_container:
126+
dockerfile: Dockerfile.debian.slim
127+
<<: *DOCKER_ARGS_ARM64_TEMPLATE
128+
<<: *TEST_RUBY_CLI_TASK_TEMPLATE
129+
## Test published standalone against x64 Dockerfiles provided for users
130+
alpine_x64_task:
131+
only_if: $CIRRUS_BRANCH == 'master' || $CIRRUS_PR != ''
132+
container:
133+
dockerfile: Dockerfile.alpine.x64
134+
<<: *DOCKER_ARGS_X64_TEMPLATE
135+
<<: *TEST_RUBY_CLI_TASK_TEMPLATE
136+
ubuntu_x64_task:
137+
only_if: $CIRRUS_BRANCH == 'master'
138+
container:
139+
dockerfile: Dockerfile.ubuntu
140+
<<: *DOCKER_ARGS_X64_TEMPLATE
141+
<<: *TEST_FULL_CLI_TASK_TEMPLATE
142+
debian_x64_task:
143+
only_if: $CIRRUS_BRANCH == 'master' || $CIRRUS_PR != ''
144+
container:
145+
dockerfile: Dockerfile.debian.slim
146+
<<: *DOCKER_ARGS_X64_TEMPLATE
147+
<<: *TEST_FULL_CLI_TASK_TEMPLATE
148+
149+
STANDALONE_INSTALL_TASK_TEMPLATE: &STANDALONE_INSTALL_TASK_TEMPLATE
150+
install_script: |
151+
curl -fsSL https://raw.githubusercontent.com/pact-foundation/pact-ruby-standalone/master/install.sh | bash \
152+
&& ln -s $PWD/pact/bin/* /usr/local/bin \
153+
&& ls pact/bin/ \
154+
&& ls /usr/local/bin
155+
## Test published standalone against common debian based images
156+
cli_test_debian_arm_task:
157+
only_if: $CIRRUS_BRANCH == 'master' || $CIRRUS_PR != ''
158+
env:
159+
matrix:
160+
- IMAGE: ruby:3.2.2-slim
161+
- IMAGE: node:20-slim
162+
- IMAGE: golang:1.20.2
163+
arm_container:
164+
image: $IMAGE
165+
<<: *DOCKER_ARGS_ARM64_TEMPLATE
166+
curl_script: apt update && apt install -y curl
167+
<<: *STANDALONE_INSTALL_TASK_TEMPLATE
168+
<<: *TEST_FULL_CLI_TASK_TEMPLATE
169+
170+
## Test published standalone against common alpine based images
171+
cli_test_alpine_arm_task:
172+
only_if: $CIRRUS_BRANCH == 'master' || $CIRRUS_PR != ''
173+
env:
174+
matrix:
175+
- IMAGE: ruby:3.2.2-alpine
176+
- IMAGE: node:20-alpine
177+
- IMAGE: golang:1.20.2-alpine
178+
arm_container:
179+
image: $IMAGE
180+
<<: *DOCKER_ARGS_ARM64_TEMPLATE
181+
curl_script: apk add curl bash gcompat libc6-compat
182+
<<: *STANDALONE_INSTALL_TASK_TEMPLATE
183+
<<: *TEST_RUBY_CLI_TASK_TEMPLATE
59184

185+
## Test published standalone against common debian based images
186+
cli_test_debian_task:
187+
only_if: $CIRRUS_BRANCH == 'master' || $CIRRUS_PR != ''
188+
env:
189+
matrix:
190+
- IMAGE: ruby:3.2.2-slim
191+
- IMAGE: node:20-slim
192+
- IMAGE: golang:1.20.2
193+
container:
194+
image: $IMAGE
195+
<<: *DOCKER_ARGS_ARM64_TEMPLATE
196+
curl_script: apt update && apt install -y curl
197+
<<: *STANDALONE_INSTALL_TASK_TEMPLATE
198+
<<: *TEST_FULL_CLI_TASK_TEMPLATE
199+
200+
## Test published standalone against common alpine based images
201+
cli_test_alpine_task:
202+
only_if: $CIRRUS_BRANCH == 'master' || $CIRRUS_PR != ''
203+
env:
204+
matrix:
205+
- IMAGE: ruby:3.2.2-alpine
206+
- IMAGE: node:20-alpine
207+
- IMAGE: golang:1.20.2-alpine
208+
container:
209+
image: $IMAGE
210+
<<: *DOCKER_ARGS_ARM64_TEMPLATE
211+
curl_script: apk add curl bash gcompat libc6-compat
212+
<<: *STANDALONE_INSTALL_TASK_TEMPLATE
213+
<<: *TEST_RUBY_CLI_TASK_TEMPLATE
214+
215+
216+
## Test published standalone against MacOS arm64
217+
cli_test_macos_task:
218+
only_if: $CIRRUS_BRANCH == 'master' || $CIRRUS_PR != ''
219+
macos_instance:
220+
image: ghcr.io/cirruslabs/macos-ventura-base:latest
221+
setup_script: sudo mkdir -p /usr/local/bin && sudo chown -R `whoami` /usr/local/*
222+
<< : *STANDALONE_INSTALL_TASK_TEMPLATE
223+
<< : *TEST_FULL_CLI_TASK_TEMPLATE

.github/workflows/build.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ jobs:
4040
- name: Download all workflow run artifacts
4141
uses: actions/download-artifact@v3
4242
- name: test ${{ matrix.os }} package
43-
run: ./script/test.sh
43+
run: ./script/unpack-and-test.sh
4444
- name: test x86 package
4545
if: ${{ runner.os == 'Windows'}}
46-
run: ./script/test.sh
46+
run: ./script/unpack-and-test.sh
4747
env:
4848
BINARY_OS: 'windows'
4949
BINARY_ARCH: 'x86'

0 commit comments

Comments
 (0)