Skip to content
Open
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
32 changes: 32 additions & 0 deletions .circleci/ca-circleci-cert.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
-----BEGIN CERTIFICATE-----
MIIFkzCCA3ugAwIBAgIUHRet5+cRWT4dJ5GUgWINj2Je0WEwDQYJKoZIhvcNAQEL
BQAwWTELMAkGA1UEBhMCWFgxFTATBgNVBAcMDERlZmF1bHQgQ2l0eTEcMBoGA1UE
CgwTRGVmYXVsdCBDb21wYW55IEx0ZDEVMBMGA1UEAwwMY2EubG9jYWxob3N0MB4X
DTI0MDYwNjA5MDYwN1oXDTM0MDYwNDA5MDYwN1owWTELMAkGA1UEBhMCWFgxFTAT
BgNVBAcMDERlZmF1bHQgQ2l0eTEcMBoGA1UECgwTRGVmYXVsdCBDb21wYW55IEx0
ZDEVMBMGA1UEAwwMY2EubG9jYWxob3N0MIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
MIICCgKCAgEArFuCUyOfIj0u5MOyX9V/nvJLKAKiqJTr99kQ1oCJmVsDDC5NWQc8
2ZcewSnWqIkvGWqtA1s7A0kbQ6rXVTmFU+J5pIiPgEy6XtWKLVGZ1llA7xdmx0Jq
7NGMz2V+zVmYim+G5zD4FptxNt61J5/AVDev7Yp0ADuOwbBqIGMpP0HUvJr4nncb
fg/xNggCwxnqFqR0sDHqM+PbigjXtl/J+YLzo4K7AhJDrvusI1vdXCONQnWt/FA5
ftOSbH47pkW6yST8m96d37mVENF5SfcTlmXvCX3Kwop+IVp/v2HgoiZs8HTmNoGF
V+JO1IJGWi7mCxAcQ/Z/6HIAg4QtWvyDiXR8Z36BVYetO4r7Tm2XAdUl4AnEP3/I
NFSv9dqw/2VJTyqJQYrCXa+ZjKGwhrSZMZF/Ux8jk5mP81bocwyuGjxwKa9hl7HT
SOYvnGrx4QVouuFxC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----END CERTIFICATE-----
52 changes: 52 additions & 0 deletions .circleci/ca-circleci-key.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
-----BEGIN PRIVATE KEY-----
MIIJQwIBADANBgkqhkiG9w0BAQEFAASCCS0wggkpAgEAAoICAQCsW4JTI58iPS7k
w7Jf1X+e8ksoAqKolOv32RDWgImZWwMMLk1ZBzzZlx7BKdaoiS8Zaq0DWzsDSRtD
qtdVOYVT4nmkiI+ATLpe1YotUZnWWUDvF2bHQmrs0YzPZX7NWZiKb4bnMPgWm3E2
3rUnn8BUN6/tinQAO47BsGogYyk/QdS8mviedxt+D/E2CALDGeoWpHSwMeoz49uK
CNe2X8n5gvOjgrsCEkOu+6wjW91cI41Cda38UDl+05JsfjumRbrJJPyb3p3fuZUQ
0XlJ9xOWZe8JfcrCin4hWn+/YeCiJmzwdOY2gYVX4k7UgkZaLuYLEBxD9n/ocgCD
hC1a/IOJdHxnfoFVh607ivtObZcB1SXgCcQ/f8g0VK/12rD/ZUlPKolBisJdr5mM
obCGtJkxkX9THyOTmY/zVuhzDK4aPHApr2GXsdNI5i+cavHhBWi64XELyEpmgMdI
KECiiY/eJqQRfCAEXsFuAk1gzUo6tVMS2/csayog+083kuwwzQM6tQySG32ZdE8v
0E2VaG5WYYSRhFEnrPbCceZcEICXW3v2m12iSjAZt3LUPs5QzFdVDKyigOn6re3Z
31CKFhidWsGDTcMWCJeBJHvSJWolEUEbq7z7njBLQqN1vcv37E2CEYnOQ4Z2GjiH
4kIJ2Z2aIJzeBm5AOd3D39YP10hA6wIDAQABAoICABcNeD1hds/QCh0b1Zg+yH58
XrP/wjy1CmiQdlGSSJUj2KEA8mR1dNyPe1QPof/RtWR7YZ+gzKBQX16qE3n5Iw2I
rYdlonfhC05S1lPgZaiHMImqAhullQKOtnwo0ZBqqt3dM9hpMs1nRfm2SNl/YuyA
tD2bto8vaBUc4NzrFmG5DtiZC6a6PImcXUFCSghJR4d2wIquamo9UChCrYNdhXij
XK3idtu8k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QjNEOqCN4ryyPt6+26g/Gdc+G8w1GrvNvifUqMNbwZ88RG1/h5DDdsz
TTZp5b2Zo37lsdaS0EUbWzIO15Ohd7Q=
-----END PRIVATE KEY-----
27 changes: 27 additions & 0 deletions .circleci/circleci.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-----BEGIN CERTIFICATE-----
MIIEfzCCAmegAwIBAgIUc5OyGFy8dC9+7Qgi+IS8mt/QE6cwDQYJKoZIhvcNAQEL
BQAwWTELMAkGA1UEBhMCWFgxFTATBgNVBAcMDERlZmF1bHQgQ2l0eTEcMBoGA1UE
CgwTRGVmYXVsdCBDb21wYW55IEx0ZDEVMBMGA1UEAwwMY2EubG9jYWxob3N0MB4X
DTI0MDYwNjEwMTgyNloXDTM0MDYwNDEwMTgyNlowVjELMAkGA1UEBhMCWFgxFTAT
BgNVBAcMDERlZmF1bHQgQ2l0eTEcMBoGA1UECgwTRGVmYXVsdCBDb21wYW55IEx0
ZDESMBAGA1UEAwwJbG9jYWxob3N0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
CgKCAQEAmc6WdjXpNQZHySLfQrt/KFErCbMF8yPRJQiY8uG5gX1kUHBEYghP7z9J
T6dmrtkyUnCT4dICV82hxOAJX51tPMyS7x/EENORBEoFCZcBo795YuUwAbsne4ih
hw7Y0BotnN8f1vgeVkpL0bTbeCRjbGWy3Z5Mry7YWmdOvTT+abpzmv/fJJjDGatL
BVSzS2Zs7hqT4LhA3A6ozEaPTk/5WvUsGq5gHj59M5RnA/AlVrHRoQ2F3iZfqIZy
PSlutG3s5MP1N9ffHXLUyuWNexLhbztS92OQR4id83gFqRcrYuYjPVtG8BdtMIW0
sczHj8Ge4AeIThuNBxXKeu4a6CtxTwIDAQABo0IwQDAdBgNVHQ4EFgQUHPfHi6d6
5SymJJIjMyzGNPFl+aEwHwYDVR0jBBgwFoAUd8Ujqs3tZcg9d8DMohlpg2VUBMIw
DQYJKoZIhvcNAQELBQADggIBAI2XzkT0AmtXFQozJCPZiD9sDWT8WwkFZn65b3LJ
9UmwcLZ7bn6eVz0s+BUiDpNDp4FBFEgNtqZWBBH0tzRN7GI8ksii3WR3F3MYvshc
bsgWE+EVEFKABe6cu2sqPbA1xN9YRkw/aLMDCczxA7kRdF4/NkZ2v9GxWaZVSOSD
SBxp0w/LKpod3d/Nt3vbmuWqfWtjQaStYpuiiXKmX95RghEpTStpGTUCPNLVDsAA
TnZRkQLb27XKszD7whGXwx7z6fWJ4Nja5ivwPAfrbMLbh78uvQPbfh6kdEtKG9bv
qG4sCLqyKpGdseE28WfNF5nWKuw2TX4/3vCB30XzVQEAfozoO46o2AuxMHHrZLD+
IDFD3fnvi5MEhdJLds7wDWoZ1i57ytpGFsFnd2Ha7wIHOPMGUv6NVGT9xVz5f5kH
RkWKiqpYgb+gcCNCMHkUd+rdXP7c7ATJL5fEyODTOl7JDYSzMLU8Bpjy1GB95HRd
pcO4zJ7ZiCPezzSv/fQBc7Lc3D5lR45hwhlmiSEJSO2XXjQO0IonY2qa/zDw1c+Z
3PirEEVGzI2c8OpcBfTjL1WXsV2OnBdHQZOKezqeFUgfKKTewDg9868P2sh/EkgY
krFJ8L8cK7J23YV6cdjPCPGZtKU2xJc37Qp4GDpoSHViwd4s3GeAHIt6XEZ5jShf
q7ab
-----END CERTIFICATE-----
28 changes: 28 additions & 0 deletions .circleci/circleci.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCZzpZ2Nek1BkfJ
It9Cu38oUSsJswXzI9ElCJjy4bmBfWRQcERiCE/vP0lPp2au2TJScJPh0gJXzaHE
4AlfnW08zJLvH8QQ05EESgUJlwGjv3li5TABuyd7iKGHDtjQGi2c3x/W+B5WSkvR
tNt4JGNsZbLdnkyvLthaZ069NP5punOa/98kmMMZq0sFVLNLZmzuGpPguEDcDqjM
Ro9OT/la9SwarmAePn0zlG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dw9NTIn1cMQ
z3SFlvvxEI+qA0wc8XOtoABgp415uM23JNGFZGdRBA7mrywJACquP+I9F8MXIlew
6j8s4k+aGuaMX1hSjpt+5cMq/wYoCSi6Q7DAOYECgYAWtUKCQ4dOOK4vtgK3r1TX
QuIRkLk+MMB6kQf2szu9rFdkd0tzJmgKkaa92EjXV9/QnL5XM8PGBzEYpv6T0Xej
0GtFtKlGamn6XwSTmd4WLuSopvwT64f4DZ3C9axuOQ97CfkS26Hh0v2bmJy6kDp0
3WrcwsPRpEkpsgbyQvE4HQ==
-----END PRIVATE KEY-----
167 changes: 140 additions & 27 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,77 @@
version: 2.1

commands:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Both jobs run the same tests, this is to reuse them

bundle_install:
parameters:
run_in_zync:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When true, we run the command inside zync container, required for SSL

type: boolean
default: false
steps:
- run:
name: bundle install
command: |
<<# parameters.run_in_zync >>docker exec zync bash -c "<</ parameters.run_in_zync >>
bundle config set --local force_ruby_platform true
bundle config set --local deployment 'true'
bundle config set --local path 'vendor/bundle'
bundle install --jobs $(grep -c processor /proc/cpuinfo) --retry 3
<<# parameters.run_in_zync >>"<</ parameters.run_in_zync >>

boot_zync:
parameters:
run_in_zync:
type: boolean
default: false
steps:
- run:
name: boot zync
command: |
<<# parameters.run_in_zync >>docker exec zync bash -c "<</ parameters.run_in_zync >>
BUNDLE_WITHOUT=development:test bundle exec bin/rails runner --environment=production 'puts Rails.env'
<<# parameters.run_in_zync >>"<</ parameters.run_in_zync >>

setup_db:
parameters:
run_in_zync:
type: boolean
default: false
steps:
- run:
name: Set up the DB
command: |
<<# parameters.run_in_zync >>docker exec zync bash -c "<</ parameters.run_in_zync >>
bundle exec bin/rails db:wait db:setup
<<# parameters.run_in_zync >>"<</ parameters.run_in_zync >>

run_tests:
parameters:
run_in_zync:
type: boolean
default: false
steps:
- run:
name: rails test
command: |
<<# parameters.run_in_zync >>
circleci tests glob "test/**/*_test.rb" | circleci tests run --command="xargs docker exec zync bundle exec rake test TESTOPTS='-v'" --verbose --split-by=timings
<</ parameters.run_in_zync >>
<<^ parameters.run_in_zync >>
Copy link
Contributor

Choose a reason for hiding this comment

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

can you explain a little the parameters syntax and choices?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes:

<<# parameters.run_in_zync >>: This means "if parameters.run_in_zync is true"
<<^ parameters.run_in_zync >>: This means "if parameters.run_in_zync is false"
<</ parameters.run_in_zync >>: This is just to close the if statement

So when run_in_zync is true, it runs the tests inside the zync container (it adds docker exec zync ...). Otherwise it doesn't.

circleci tests glob "test/**/*_test.rb" | circleci tests run --command="xargs bundle exec rake test TESTOPTS='-v'" --verbose --split-by=timings
<</ parameters.run_in_zync >>

run_license_finder:
parameters:
run_in_zync:
type: boolean
default: false
steps:
- run:
name: license_finder
command: |
<<# parameters.run_in_zync >>docker exec zync bash -c "<</ parameters.run_in_zync >>
bundle exec license_finder
<<# parameters.run_in_zync >>"<</ parameters.run_in_zync >>

jobs:
docker-build:
resource_class: small
Expand Down Expand Up @@ -37,50 +110,86 @@ jobs:
RAILS_ENV: test
DISABLE_SPRING: 1 # we can't really run spring as it hangs on local circleci build
DATABASE_URL: postgres://postgres:@localhost/circle_test
SECRET_KEY_BASE: test
steps:
- checkout

# Restore bundle cache
- restore_cache:
keys:
- zync-bundle-v2-{{ .Environment.CACHE_VERSION }}-{{ arch }}-{{ checksum "Gemfile.lock" }}

- run:
name: bundle install
command: |
bundle config --local force_ruby_platform true
bundle config set --local deployment 'true'
bundle config set --local path 'vendor/bundle'
bundle install --jobs $(grep -c processor /proc/cpuinfo) --retry 3
- run:
name: boot zync
command: SECRET_KEY_BASE=test BUNDLE_WITHOUT=development:test bundle exec bin/rails runner --environment=production 'puts Rails.env'

- bundle_install
- save_cache:
key: zync-bundle-v2-{{ .Environment.CACHE_VERSION }}-{{ arch }}-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
- boot_zync
- setup_db
- run_tests
- run_license_finder
- store_test_results:
path: test/reports

build_ssl:
parameters:
postgresql_image:
type: string
machine:
image: ubuntu-2204:current
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The docker executor doesn't accept mounting volumes to the postgres container, I faced the same issue when I added SSL pipelines to apisonator. We must use the mahine executor and launch the containers manually.

Copy link
Contributor

@akostadinov akostadinov Feb 9, 2026

Choose a reason for hiding this comment

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

I read that setup_remote_docker step allows for using docker from within the main container, so that we can use the old approach, just add the setup remote docker step to then run postgres as we wish.

But also it is in fact not hard to start postgres with a custom entrypoint that generates a SSL certificate.

podman run --rm -e POSTGRES_HOST_AUTH_METHOD=trust -e POSTGRES_DB=test --entrypoint bash cimg/postgres:15.15 -c ' openssl req -nodes -new -x509 -subj "/CN=localhost" -keyout /server.key -out /server.crt && chown postgres /server.* && exec docker-entrypoint.sh postgres -c ssl=on -c ssl_cert_file=/server.crt -c ssl_key_file=/server.key '

Then we can extract the CA in the main container with:

openssl s_client \
  -starttls postgres \
  -connect localhost:5432 \
  -showcerts < /dev/null > ca.pem

I think both options are preferable to switching to the VM executor especially if we anticipate using custom executors. WDYT about these options?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That might work, I don't know, but I don't think it's worth the effort because every change you make in the CircleCI file, even if it seems easy, always ends up taking a whole day of try & error. I don't see much improvement on using a docker executor over a machine executor to justify the effort.

Copy link
Contributor

Choose a reason for hiding this comment

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

even if it seems easy, always ends up taking a whole day of try & error

That's true. But also this native executor is very shitty with some old software like old podman and stuff. And then it makes it much harder to use custom executors. Also current approach looks complicated, although I can't tell if using pure docker executor will make it noticeably less complicated 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's gonna be complicated whatever approach we try. CircleCI won't allow you to pass until you hit your head against a wall for at least 8 hours.

steps:
- checkout
- run:
name: Set up the DB
command: bundle exec bin/rails db:wait db:setup

- run:
name: rails test
name: Start PostgreSQL with SSL
command: |
circleci tests glob "test/**/*_test.rb" | circleci tests run --command="xargs bundle exec rake test TESTOPTS='-v'" --verbose --split-by=timings
docker run -d --name postgres --network host \
-e POSTGRES_HOST_AUTH_METHOD=trust \
-e POSTGRES_DB=circle_test \
-v $(pwd)/.circleci/circleci.crt:/tmp/server.crt:ro \
-v $(pwd)/.circleci/circleci.key:/tmp/server.key:ro \
-v $(pwd)/.circleci/ca-circleci-cert.pem:/tmp/ca.crt:ro \
<< parameters.postgresql_image >> \
bash -c "
cp /tmp/server.crt /server.crt
cp /tmp/server.key /server.key
cp /tmp/ca.crt /ca.crt
chown postgres:postgres /server.crt /server.key /ca.crt
chmod 600 /server.key
exec docker-entrypoint.sh postgres -c ssl=on -c ssl_cert_file=/server.crt -c ssl_key_file=/server.key -c ssl_ca_file=/ca.crt
Comment on lines +150 to +155
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All this is because postgres doesn't accept a cert key which is not owned by itself and with 0600 permissions

"
- run:
name: license_finder
name: Start zync container
command: |
bundle exec license_finder

- store_test_results:
path: test/reports

chmod 600 $(pwd)/.circleci/circleci.key && \
Copy link
Contributor Author

Choose a reason for hiding this comment

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

postgres doesn't accept the client not owning the client key neither, and permissions must be 0600 as well

docker run -d --name zync --network host \
-v $(pwd):/opt/app-root/src -w /opt/app-root/src \
-e RAILS_ENV=test \
-e DISABLE_SPRING=1 \
-e DATABASE_URL=postgres://postgres:@localhost/circle_test \
-e DATABASE_SSL_CA=/opt/app-root/src/.circleci/ca-circleci-cert.pem \
-e DATABASE_SSL_CERT=/opt/app-root/src/.circleci/circleci.crt \
-e DATABASE_SSL_KEY=/opt/app-root/src/.circleci/circleci.key \
-e DATABASE_SSL_MODE=verify-full \
-e SECRET_KEY_BASE=test \
-e HOME=/opt/app-root/src \
quay.io/3scale/zync:ci-builder-ruby-3.3 \
sleep infinity
- restore_cache:
keys:
- zync-bundle-v2-{{ .Environment.CACHE_VERSION }}-{{ arch }}-{{ checksum "Gemfile.lock" }}
- bundle_install:
run_in_zync: true
- save_cache:
Copy link
Contributor

Choose a reason for hiding this comment

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

save cache should be directly under bundle install maybe 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done: 97f24d7

key: zync-branch-v2-{{ arch }}-{{ .Branch }}
key: zync-bundle-v2-{{ .Environment.CACHE_VERSION }}-{{ arch }}-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
- boot_zync:
run_in_zync: true
- setup_db:
run_in_zync: true
- run_tests:
run_in_zync: true
- run_license_finder:
run_in_zync: true
- store_test_results:
path: test/reports

workflows:
version: 2.1
Expand All @@ -90,4 +199,8 @@ workflows:
matrix:
parameters:
postgresql_image: [ "cimg/postgres:14.19", "cimg/postgres:15.14", "cimg/postgres:16.10", "cimg/postgres:17.6", "cimg/postgres:18.0" ]
- build_ssl:
matrix:
parameters:
postgresql_image: [ "cimg/postgres:14.19", "cimg/postgres:15.14", "cimg/postgres:16.10", "cimg/postgres:17.6", "cimg/postgres:18.0" ]
- docker-build
8 changes: 8 additions & 0 deletions .gitleaks.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[allowlist]
description = "Global Allowlist"

# Ignore based on any subset of the file path
paths = [
# Ignore all fake private keys for CircleCI, they are for tests
'''.circleci\/.+\.(pem|key)$'''
]
Comment on lines +1 to +8
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is to bypass our secret leak detector. The certificates I pushed here are fake.

9 changes: 8 additions & 1 deletion config/initializers/que.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@

def Que.start!
require 'que/locker'
require 'que/db_connection_url'

# Workaround for https://github.com/chanks/que/pull/192
require 'active_record/base'
Que.locker = Que::Locker.new(**Rails.application.config.x.que)

# Build connection URL with SSL parameters from database config
# Workaround for https://github.com/que-rb/que/issues/442
db_config = ActiveRecord::Base.connection_db_config.configuration_hash
connection_url = Que::DBConnectionURL.build_connection_url(db_config)

Que.locker = Que::Locker.new(connection_url: connection_url, **Rails.application.config.x.que)
end

def Que.stop!
Expand Down