From e5cfbab511a408092617246dc8e257c0742eb59d Mon Sep 17 00:00:00 2001 From: Viachaslau Tyshkavets Date: Fri, 9 Jan 2026 11:08:24 +0400 Subject: [PATCH 1/8] chore(ci): add GitHub Actions workflow for Rails smoke test --- .github/workflows/ci.yml | 101 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e796ce8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,101 @@ +name: ci + +on: + push: + branches: + - main + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + services: + postgres: + image: postgres:9.6 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: blog_development + ports: + - 5432:5432 + options: >- + --health-cmd "pg_isready -U postgres" + --health-interval 5s + --health-timeout 5s + --health-retries 10 + env: + PGHOST: localhost + PGPORT: 5432 + PGUSER: postgres + PGPASSWORD: postgres + PGDATABASE: blog_development + DATABASE_URL: postgres://postgres:postgres@localhost:5432/blog_development + steps: + - uses: actions/checkout@v4 + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: "2.3.3" + + - name: Install system deps + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends \ + build-essential \ + libpq-dev \ + libxml2-dev \ + libxslt1-dev \ + nodejs \ + zlib1g-dev + + - name: Install bundler + run: gem install bundler -v 1.10.6 + + - name: Configure bundler for nokogiri + run: bundle config build.nokogiri --use-system-libraries + + - name: Install gems + run: bundle install + + - name: Wait for postgres + run: | + for i in $(seq 1 30); do + bundle exec ruby -e "require 'pg'; PG.connect(host: ENV['PGHOST'], port: ENV['PGPORT'].to_i, dbname: ENV['PGDATABASE'], user: ENV['PGUSER'], password: ENV['PGPASSWORD']);" && exit 0 + sleep 2 + done + exit 1 + + - name: Setup database + run: bundle exec rake db:create db:migrate db:seed + + - name: Start server + run: | + bundle exec rails server -b 0.0.0.0 -p 3000 >rails.log 2>&1 & + + - name: Wait for server readiness + run: | + READY=0 + for i in $(seq 1 30); do + echo "Attempt ${i}/30: checking http://localhost:3000" + if curl -sSfL http://localhost:3000 >/dev/null; then + echo "Server responded successfully on attempt ${i}." + READY=1 + break + fi + echo "Server still starting up, waiting 2s before retry." + sleep 2 + done + if [ "$READY" -ne 1 ]; then + echo "Server failed to start" + tail -n 200 rails.log || true + exit 1 + fi + echo "Server is ready; last 200 lines of rails.log:" + tail -n 200 rails.log || true + + - name: Check homepage + run: | + if ! curl -sSfL http://localhost:3000 | grep -F "Home"; then + echo "Homepage check failed" + exit 1 + fi \ No newline at end of file From 890c6d129c245fe4a9d01323c0fa175e1fe6db1e Mon Sep 17 00:00:00 2001 From: Viachaslau Tyshkavets Date: Fri, 9 Jan 2026 11:57:29 +0400 Subject: [PATCH 2/8] chore(ci): run test job in container mode for legacy Ruby compatibility --- .github/workflows/ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e796ce8..7f4b2e5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,8 @@ on: jobs: test: runs-on: ubuntu-latest + container: + image: ruby:2.3 services: postgres: image: postgres:9.6 @@ -39,8 +41,8 @@ jobs: - name: Install system deps run: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends \ + apt-get update + apt-get install -y --no-install-recommends \ build-essential \ libpq-dev \ libxml2-dev \ From 5408c9b3915700c342680eb7a8624b78bf0da1df Mon Sep 17 00:00:00 2001 From: Viachaslau Tyshkavets Date: Fri, 9 Jan 2026 12:02:07 +0400 Subject: [PATCH 3/8] chore(ci): switch job image to buildpack-deps:buster for native build tooling --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f4b2e5..fa7fe4b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: test: runs-on: ubuntu-latest container: - image: ruby:2.3 + image: buildpack-deps:buster services: postgres: image: postgres:9.6 From 0f619cceea5ad433476524d9951647df4bcecbfa Mon Sep 17 00:00:00 2001 From: Viachaslau Tyshkavets Date: Fri, 9 Jan 2026 12:41:19 +0400 Subject: [PATCH 4/8] chore(ci): build Ruby 2.3.3 from source via ruby-build --- .github/workflows/ci.yml | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa7fe4b..3012e2a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,20 +35,30 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: ruby/setup-ruby@v1 - with: - ruby-version: "2.3.3" - - name: Install system deps run: | apt-get update apt-get install -y --no-install-recommends \ - build-essential \ - libpq-dev \ - libxml2-dev \ - libxslt1-dev \ - nodejs \ - zlib1g-dev + build-essential \ + libffi-dev \ + libgdbm-dev \ + libpq-dev \ + libreadline-dev \ + libssl-dev \ + libxml2-dev \ + libxslt1-dev \ + nodejs \ + libyaml-dev \ + zlib1g-dev + + - name: Install Ruby 2.3.3 + env: + RUBY_PREFIX: /opt/ruby-2.3.3 + run: | + git clone --depth=1 https://github.com/rbenv/ruby-build.git /tmp/ruby-build + /tmp/ruby-build/install.sh + ruby-build 2.3.3 "$RUBY_PREFIX" + echo "$RUBY_PREFIX/bin" >> "$GITHUB_PATH" - name: Install bundler run: gem install bundler -v 1.10.6 From 4059255f1802de12a9155d0e375874b59682a3cb Mon Sep 17 00:00:00 2001 From: Viachaslau Tyshkavets Date: Fri, 9 Jan 2026 12:46:25 +0400 Subject: [PATCH 5/8] chore(ci): use Debian archive mirrors for EOL buster apt repos --- .github/workflows/ci.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3012e2a..92c905e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,10 +35,16 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Point apt to Debian archive + run: | + sed -i 's|deb.debian.org/debian|archive.debian.org/debian|g' /etc/apt/sources.list + sed -i 's|security.debian.org/debian-security|archive.debian.org/debian-security|g' /etc/apt/sources.list + sed -i '/buster-updates/d' /etc/apt/sources.list + - name: Install system deps run: | - apt-get update - apt-get install -y --no-install-recommends \ + apt-get -o Acquire::Check-Valid-Until=false -o Acquire::AllowInsecureRepositories=true update + apt-get -o Acquire::Check-Valid-Until=false -o Acquire::AllowInsecureRepositories=true install -y --no-install-recommends \ build-essential \ libffi-dev \ libgdbm-dev \ From b4a6ba1ad9f84690acb43bd7c73fb079b0101779 Mon Sep 17 00:00:00 2001 From: Viachaslau Tyshkavets Date: Fri, 9 Jan 2026 12:56:41 +0400 Subject: [PATCH 6/8] chore(ci): fix Postgres host and readiness checks for container-mode networking --- .github/workflows/ci.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 92c905e..720a590 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,17 +21,18 @@ jobs: ports: - 5432:5432 options: >- + --name postgres --health-cmd "pg_isready -U postgres" --health-interval 5s --health-timeout 5s --health-retries 10 env: - PGHOST: localhost + PGHOST: postgres PGPORT: 5432 PGUSER: postgres PGPASSWORD: postgres PGDATABASE: blog_development - DATABASE_URL: postgres://postgres:postgres@localhost:5432/blog_development + DATABASE_URL: postgres://postgres:postgres@postgres:5432/blog_development steps: - uses: actions/checkout@v4 @@ -78,10 +79,10 @@ jobs: - name: Wait for postgres run: | for i in $(seq 1 30); do - bundle exec ruby -e "require 'pg'; PG.connect(host: ENV['PGHOST'], port: ENV['PGPORT'].to_i, dbname: ENV['PGDATABASE'], user: ENV['PGUSER'], password: ENV['PGPASSWORD']);" && exit 0 + pg_isready -h "$PGHOST" -p "$PGPORT" -d "$PGDATABASE" && break sleep 2 done - exit 1 + bundle exec ruby -e "require 'pg'; PG.connect(host: ENV['PGHOST'], port: ENV['PGPORT'].to_i, dbname: ENV['PGDATABASE'], user: ENV['PGUSER'], password: ENV['PGPASSWORD']);" - name: Setup database run: bundle exec rake db:create db:migrate db:seed From f821f91e353d363d45d73b8b692ba566a00aaeda Mon Sep 17 00:00:00 2001 From: Viachaslau Tyshkavets Date: Mon, 16 Feb 2026 11:16:03 +0400 Subject: [PATCH 7/8] chore(ci): add install postgresql-client --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 720a590..4620fbf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,6 +54,7 @@ jobs: libssl-dev \ libxml2-dev \ libxslt1-dev \ + postgresql-client \ nodejs \ libyaml-dev \ zlib1g-dev @@ -117,4 +118,4 @@ jobs: if ! curl -sSfL http://localhost:3000 | grep -F "Home"; then echo "Homepage check failed" exit 1 - fi \ No newline at end of file + fi From d6ab3321c9981a7121e332a96478c3c78238caf7 Mon Sep 17 00:00:00 2001 From: Viachaslau Tyshkavets Date: Mon, 16 Feb 2026 16:46:45 +0400 Subject: [PATCH 8/8] chore(ci): set bash as explicit default shell --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4620fbf..4e2a120 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,9 @@ jobs: runs-on: ubuntu-latest container: image: buildpack-deps:buster + defaults: + run: + shell: bash services: postgres: image: postgres:9.6