Skip to content

Commit

Permalink
Bleeding edge workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Earlopain committed Oct 22, 2024
1 parent df6816d commit df5c413
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 6 deletions.
24 changes: 24 additions & 0 deletions .github/bleeding_edge.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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[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
stubs.each do |stub|
url = stub.metadata["source_code_uri"] || stub.homepage
matched = url[%r{https?://git(?:hub|lab)\.com/[^\/]*/[^\/]*}]
next if stub.name == "simplecov-html"

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"))
30 changes: 27 additions & 3 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,47 @@ on: # yamllint disable-line rule:truthy
pull_request:
branches:
- master
schedule:
- cron: 0 3 * * *
workflow_dispatch:
inputs:
bleeding_edge:
type: boolean
default: false
description: "Run with gems from git sources"

permissions:
contents: read

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

jobs:
tests:
runs-on: ubuntu-latest

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,7 +61,8 @@ 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 }}
Expand All @@ -54,7 +76,8 @@ jobs:
with:
bundler-cache: true

- name: Run Rubocop
- if: env.BLEEDING_EDGE == 'false'
name: Run Rubocop
run: bundle exec rubocop --format github

docker-checks:
Expand All @@ -67,5 +90,6 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Run ${{ matrix.service }}
- if: env.BLEEDING_EDGE == 'false'
name: Run ${{ matrix.service }}
run: docker compose run ${{ matrix.service }}
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 df5c413

Please sign in to comment.