Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,8 @@ updates:
timezone: "UTC"
cooldown:
default-days: 7
ignore:
# Dependabot only changes the Dockerfile, but CI tests on .ruby-version, so a
# Ruby bump from here ships a Ruby that CI never ran. The Ruby version bump
# workflow updates both; a new Ruby series is a deliberate upgrade.
- dependency-name: "ruby"
79 changes: 76 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ on:
- master
pull_request:
workflow_dispatch:
# Weekly rebuild of the published image, before WhyJustRun's Tuesday 10:30 UTC
# redeploy. It picks up base-image fixes, and the Dependabot updates merged that
# week: merges made with GITHUB_TOKEN don't trigger the push event.
schedule:
- cron: "0 9 * * 2"

permissions:
contents: read
Expand Down Expand Up @@ -155,17 +160,85 @@ jobs:
- name: Audit gems for known vulnerabilities
run: gem install bundler-audit --no-document && bundle-audit check --update

push:
image:
runs-on: ubuntu-24.04
needs: [test, system-test, brakeman, audit]
if: github.event_name == 'push'
env:
RAILS_ENV: production
SECRET_KEY_BASE: placeholder
WJR_DATABASE_NAME: placeholder
WJR_DATABASE_TEST_NAME: placeholder
WJR_DATABASE_HOST: placeholder
WJR_DATABASE_USERNAME: placeholder
WJR_DATABASE_PASSWORD: placeholder
WJR_PASSWORD_SALT: placeholder
WJR_SECRET_BASE: placeholder
WJR_SECRET_TOKEN: placeholder
WJR_DEVISE_SECRET_KEY: placeholder
WJR_RECAPTCHA_SITE_KEY: placeholder
WJR_RECAPTCHA_SECRET_KEY: placeholder
WJR_SMTP_ADDRESS: placeholder
WJR_SMTP_DOMAIN: placeholder
WJR_SMTP_USER_NAME: placeholder
WJR_SMTP_PASSWORD: placeholder
WJR_DATA_FOLDER: /tmp/whyjustrun-data/
WJR_DATA_URL: placeholder

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7

- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME

- name: Check that the app boots in production
# The test jobs run on the runner's Ruby without precompiled assets; this runs
# the image that gets deployed (its Ruby, its gems, its asset manifest).
run: |
env_args=()
for name in RAILS_ENV SECRET_KEY_BASE ${!WJR_*}; do env_args+=(-e "$name"); done
docker run --rm --entrypoint "" "${env_args[@]}" $IMAGE_NAME \
bundle exec rails runner 'puts "Booted Rails #{Rails.version} on Ruby #{RUBY_VERSION}"'

push:
runs-on: ubuntu-24.04
needs: [test, system-test, brakeman, audit, image]
# Only master is published (as `latest`), never a branch the CI was dispatched on.
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request'
env:
RAILS_ENV: production
SECRET_KEY_BASE: placeholder
WJR_DATABASE_NAME: placeholder
WJR_DATABASE_TEST_NAME: placeholder
WJR_DATABASE_HOST: placeholder
WJR_DATABASE_USERNAME: placeholder
WJR_DATABASE_PASSWORD: placeholder
WJR_PASSWORD_SALT: placeholder
WJR_SECRET_BASE: placeholder
WJR_SECRET_TOKEN: placeholder
WJR_DEVISE_SECRET_KEY: placeholder
WJR_RECAPTCHA_SITE_KEY: placeholder
WJR_RECAPTCHA_SECRET_KEY: placeholder
WJR_SMTP_ADDRESS: placeholder
WJR_SMTP_DOMAIN: placeholder
WJR_SMTP_USER_NAME: placeholder
WJR_SMTP_PASSWORD: placeholder
WJR_DATA_FOLDER: /tmp/whyjustrun-data/
WJR_DATA_URL: placeholder

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7

- name: Build image
run: docker build . --pull --file Dockerfile --tag $IMAGE_NAME

- name: Check that the app boots in production
# The test jobs run on the runner's Ruby without precompiled assets; this runs
# the image that gets deployed (its Ruby, its gems, its asset manifest).
run: |
env_args=()
for name in RAILS_ENV SECRET_KEY_BASE ${!WJR_*}; do env_args+=(-e "$name"); done
docker run --rm --entrypoint "" "${env_args[@]}" $IMAGE_NAME \
bundle exec rails runner 'puts "Booted Rails #{Rails.version} on Ruby #{RUBY_VERSION}"'

- name: Log into GitHub Container Registry
run: echo "${{ secrets.CR_PAT }}" | docker login https://ghcr.io -u ${{ secrets.CR_USER }} --password-stdin

Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ jobs:
github.event.pull_request.user.login == 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- name: Fetch update metadata
id: metadata
uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0

# Major updates can break the app in ways the tests miss (json 3 did), so they
# wait for a human review.
- name: Enable auto-merge
if: steps.metadata.outputs.update-type != 'version-update:semver-major'
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
Expand Down Expand Up @@ -50,6 +57,12 @@ jobs:
exit 0
fi

# Major updates wait for a human review (see enable-auto-merge).
if gh api "repos/$REPO/commits/$HEAD_SHA" --jq '.commit.message' | grep -q 'update-type: version-update:semver-major'; then
echo "PR #$pr is a major update; leaving it for review"
exit 0
fi

state=$(gh pr view "$pr" --repo "$REPO" --json state --jq '.state')
if [ "$state" != "OPEN" ]; then
echo "PR #$pr is $state; skipping"
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.4
3.3.13
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
FROM ruby:4.0.0-alpine AS dev
FROM ruby:3.3.13-alpine AS dev
# linux-headers and libffi-dev are for compiling the ffi gem; older Alpine releases
# pulled them in as dependencies of the other packages.
RUN apk add --no-cache \
make \
pkgconfig \
build-base \
autoconf \
linux-headers \
libffi-dev \
libstdc++ \
mariadb-dev \
imagemagick \
Expand Down
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ gem "geocoder", "~> 1.8.6"
# JSON Builder
gem 'jbuilder', '~> 2.15.1'

# json 3 removed keywords still used by Rails 7.x and ExecJS 2.9.
# json 3 removed the create_additions keyword, which sprockets 4.2 still passed (4.4 doesn't).
# Before taking json 4, check that the production image boots (CI's image job).
gem 'json', '< 4'

# Logging (email)
Expand Down
7 changes: 4 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ GEM
prism (2.1.0)
prism (2.1.0-x86_64-linux-gnu)
public_suffix (7.0.5)
puma (8.1.1)
puma (8.1.2)
nio4r (~> 2.0)
pundit (2.5.2)
activesupport (>= 3.0.0)
Expand Down Expand Up @@ -287,8 +287,9 @@ GEM
logger (~> 1.4)
rubyzip (>= 1.2.2, < 4.0)
websocket (~> 1.0)
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
sprockets (4.4.1)
concurrent-ruby (~> 1.1)
logger
rack (>= 2.2.4, < 4)
sprockets-rails (3.5.2)
actionpack (>= 6.1)
Expand Down