Skip to content

Commit

Permalink
Bleeding edge workflow
Browse files Browse the repository at this point in the history
Test (almost) all gems against their latest commit
  • Loading branch information
Earlopain committed Nov 1, 2024
1 parent df6816d commit 8da83ca
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 4 deletions.
26 changes: 26 additions & 0 deletions .github/bleeding_edge.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require "bundler"

remote = "https://rubygems.org"
fetcher = Bundler::Fetcher.new(Bundler::Source::Rubygems::Remote.new(remote))
dsl = Bundler::Dsl.evaluate("#{__dir__}/../Gemfile", "#{__dir__}/../Gemfile.lock", {})
stubs = dsl.resolve.materialize(dsl.dependencies_for(%w[default test])).map do |stub|
Bundler::RemoteSpecification.new(stub.name, stub.version, stub.platform, fetcher)
end

lines = ["source #{remote.inspect}"]
NO_GIT = %w[minitest i18n logger simplecov].freeze
FULL_SKIP = %w[simplecov-html nokogiri mini_portile2].freeze

stubs.each do |stub|
url = stub.metadata["source_code_uri"] || stub.homepage
matched = url[%r{https?://git(?:hub|lab)\.com/[^\/]*/[^\/]*}]
next if FULL_SKIP.include?(stub.name)

lines << if matched && !NO_GIT.include?(stub.name) # rubocop:disable Rails/NegateInclude
"gem #{stub.name.inspect}, git: #{matched.inspect}, submodules: true"
else
"gem #{stub.name.inspect}"
end
end

File.write("Gemfile", lines.join("\n"))
27 changes: 26 additions & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ on: # yamllint disable-line rule:truthy
pull_request:
branches:
- master
schedule:
- cron: 49 3 * * *
workflow_dispatch:
inputs:
bleeding_edge:
type: boolean
default: false
description: Run with gems from git sources

permissions:
contents: read
Expand All @@ -15,18 +23,31 @@ jobs:
tests:
runs-on: ubuntu-latest

env:
BLEEDING_EDGE: ${{ (inputs.bleeding_edge == true || github.event_name == 'schedule') && 'true' || 'false' }}

steps:
- uses: actions/checkout@v4

- if: env.BLEEDING_EDGE == 'true'
uses: ruby/setup-ruby@v1
- if: env.BLEEDING_EDGE == 'true'
name: Use git gem sources
run: ruby .github/bleeding_edge.rb && bundle lock && cat Gemfile.lock

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build
uses: docker/build-push-action@v5
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
load: true
tags: foxtrove
build-args: |
BASE_IMAGE=${{ env.BLEEDING_EDGE == 'true' && 'ghcr.io/docker-ruby-nightly/ruby:alpine3.20-nightly' || ''}}
- name: Set env file
run: |
Expand All @@ -40,13 +61,15 @@ jobs:
- name: Run Tests
run: docker compose run -e CI=1 tests

- name: Upload Coverage
- if: env.BLEEDING_EDGE == 'false'
name: Upload Coverage
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}

rubocop:
runs-on: ubuntu-latest
if: github.event_name != 'schedule' && github.event_name != 'workflow_dispatch'

steps:
- uses: actions/checkout@v4
Expand All @@ -59,6 +82,8 @@ jobs:

docker-checks:
runs-on: ubuntu-latest
if: github.event_name != 'schedule' && github.event_name != 'workflow_dispatch'

name: Run ${{ matrix.service }}
strategy:
fail-fast: false
Expand Down
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM ruby:3.3.4-alpine3.20 AS ruby-builder
ARG BASE_IMAGE
FROM ${BASE_IMAGE:-ruby:3.3.4-alpine3.20} AS ruby-builder

RUN apk --no-cache add build-base cmake postgresql16-dev
RUN apk --no-cache add build-base cmake postgresql16-dev git

COPY Gemfile Gemfile.lock ./
RUN gem i foreman && bundle install \
Expand All @@ -12,7 +13,7 @@ FROM node:20-alpine3.20 AS node-downloader

RUN npm install [email protected] -g

FROM ruby:3.3.4-alpine3.20
FROM ${BASE_IMAGE:-ruby:3.3.4-alpine3.20}

WORKDIR /app

Expand Down
1 change: 1 addition & 0 deletions test/logical/good_job_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

class GoodJobTest < ActiveSupport::TestCase
test "current migrations are applied" do
skip("Skip for bleeding edge") if ENV["CI"]
assert_predicate GoodJob, :migrated?
end

Expand Down

0 comments on commit 8da83ca

Please sign in to comment.