Skip to content

Commit ddbdfb5

Browse files
committed
CI fix: vendor eras
1 parent a7cc3ba commit ddbdfb5

4 files changed

Lines changed: 106 additions & 2 deletions

File tree

app/services/patch_ci/eras.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
module PatchCi
2-
# postgres-ci/eras.yml, read from Rails. Until now only
2+
# eras.yml, read from Rails. Until now only postgres-ci's
33
# .github/workflows/build-era-images.yml read it, and the app knew majors only
44
# through EraDetector::SUPPORTED_MAJORS - so a major-to-family mapping in Ruby
55
# would have been a second copy free to drift from the image build.
6+
#
7+
# The file is a copy of postgres-ci's, see its header: reading it out of a
8+
# sibling checkout worked on my machine only, and left the app, its specs and
9+
# the image without the mapping everywhere else.
610
class Eras
7-
PATH = Rails.root.join("postgres-ci/eras.yml")
11+
PATH = Rails.root.join("config/patch_ci/eras.yml")
812

913
Family = Struct.new(:name, :majors, :enabled, keyword_init: true)
1014

bin/container-entrypoint

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ fi
2222

2323
# If running the rails server (directly or via bin/dev), create or migrate the database
2424
if { [ "$1" = "./bin/rails" ] && [ "$2" = "server" ]; } || [ "$1" = "./bin/dev" ]; then
25+
# tmp/ comes from the bind mount, so a pid file outlives the container that
26+
# wrote it - puma leaves one behind whenever it is killed by a signal. The pid
27+
# in it is dead, but pids restart at 1 in the new container and something else
28+
# can hold it by now, and then rails exits with "server is already running".
29+
rm -f tmp/pids/server.pid
30+
2531
./bin/rails db:prepare
2632
fi
2733

config/patch_ci/eras.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Copy of hackorum-dev/postgres-ci eras.yml. That repo owns this file - it
2+
# builds the images from it. The copy exists because the app reads the same
3+
# mapping and postgres-ci is not, and should not be, a checkout hackorum needs:
4+
# the specs, the CI runners and the prod image all have to see it.
5+
#
6+
# Refresh with `cp postgres-ci/eras.yml config/patch_ci/eras.yml` and put this
7+
# header back. Only families, majors and enabled are read here, so a change to
8+
# base_image, eol or runtime_packages needs no re-copy - eras_spec fails when
9+
# the parts that matter drift and postgres-ci is checked out next to us.
10+
#
11+
# Build environments for hackorum patch CI, keyed by the PG major version of
12+
# the base commit. One image per family; every major it serves is a tag on it.
13+
#
14+
# reference_commits warm the baked ccache - one build per major the family
15+
# serves, all sharing one content-addressed cache.
16+
#
17+
# runtime_packages lists the shared-library packages a compiled postgres
18+
# needs at runtime for that family's Debian release. Runtime library package
19+
# names change across releases (openssl, ldap and readline all rename
20+
# theirs), so this is spelled out per family instead of guessed once.
21+
families:
22+
stretch:
23+
enabled: true
24+
base_image: debian/eol:stretch
25+
eol: true
26+
majors:
27+
9: bd6cf3f237c9aeb4dad1ac3ec2008c5768fe4c1b
28+
10: 8569955ee39650a667b9700385e1bc19fbf47069
29+
11: 96102a32a374c3b81ba9c2b24bcf1943a87a9ef6
30+
runtime_packages: >-
31+
libssl1.1 libreadline7 libicu57 libldap-2.4-2 libxml2 libxslt1.1
32+
libpam0g libkrb5-3 libselinux1 libuuid1 zlib1g libperl5.24
33+
buster:
34+
enabled: true
35+
base_image: debian/eol:buster
36+
eol: true
37+
majors:
38+
12: 68a13f28bebc9eb70cc6988bfa2daaf4500f519f
39+
13: 7559d8ebfa11d98728e816f6b655582ce41150f3
40+
runtime_packages: >-
41+
libssl1.1 libreadline7 libicu63 libldap-2.4-2 libxml2 libxslt1.1
42+
libpam0g libkrb5-3 libselinux1 libuuid1 zlib1g libperl5.28
43+
bullseye:
44+
enabled: true
45+
base_image: debian:bullseye
46+
eol: false
47+
majors:
48+
14: 88e014c149cc396fb218b08eda17c47d5b33e94f
49+
15: cab5b9ab2c066ba904f13de2681872dcda31e207
50+
runtime_packages: >-
51+
libssl1.1 libreadline8 libicu67 libldap-2.4-2 libxml2 libxslt1.1
52+
libpam0g libkrb5-3 libselinux1 libuuid1 zlib1g libperl5.32
53+
bookworm:
54+
enabled: true
55+
base_image: debian:bookworm
56+
eol: false
57+
majors:
58+
16: c8e1ba736b2b9e8c98d37a5b77c4ed31baf94147
59+
17: 29275b1d177096597675b5c6e7e7c9db2df8f4df
60+
runtime_packages: >-
61+
libssl3 libreadline8 libicu72 libldap-2.5-0 libxml2 libxslt1.1
62+
libpam0g libkrb5-3 libselinux1 libuuid1 zlib1g libperl5.36
63+
trixie:
64+
enabled: true
65+
base_image: debian:trixie
66+
eol: false
67+
majors:
68+
18: c9b3d4909bbfcaa8cc2ed434d12a562fb30fe422
69+
19: 45d92b76dc4ac31d44e46ca38bee12d5d8fac1f5
70+
20: 1c4b1de888559a47df599dcef356ea7fbf96fd0c
71+
runtime_packages: >-
72+
libssl3t64 libreadline8t64 libicu76 libldap2 libxml2 libxslt1.1
73+
libpam0g libkrb5-3 libselinux1 libuuid1 zlib1g libperl5.40

spec/services/patch_ci/eras_spec.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,25 @@
7575
expect { family.majors << 99 }.to raise_error(FrozenError)
7676
expect { family.name = "mutated!" }.to raise_error(FrozenError)
7777
end
78+
79+
# our config/patch_ci/eras.yml is a copy of postgres-ci's, so it can go stale
80+
# after a family is added there. Nothing on a CI runner can catch that - the
81+
# other repo is not checked out - but a dev box with it next to us can, and
82+
# that is where the copy gets refreshed anyway. Compares what the app reads,
83+
# not the whole file: base images and runtime packages are postgres-ci's
84+
# business and change without touching the mapping.
85+
it "carries the same mapping as postgres-ci's eras.yml" do
86+
source = [ Rails.root.join("postgres-ci/eras.yml"), Rails.root.join("../postgres-ci/eras.yml") ]
87+
.find(&:exist?)
88+
skip "postgres-ci is not checked out next to this repo" unless source
89+
90+
expect(mapping(described_class::PATH)).to eq(mapping(source)),
91+
"config/patch_ci/eras.yml drifted, refresh it: cp #{source} #{described_class::PATH}"
92+
end
93+
94+
def mapping(path)
95+
YAML.safe_load_file(path).fetch("families").transform_values do |config|
96+
{ majors: config.fetch("majors").keys.map(&:to_i).sort, enabled: config["enabled"] == true }
97+
end
98+
end
7899
end

0 commit comments

Comments
 (0)