From 9c8ff8303a64dec6ea6a96767f5704023f902764 Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:50:07 +0200 Subject: [PATCH] Bleeding edge workflow --- .github/bleeding_edge.rb | 13 +++++++++++++ .github/workflows/checks.yml | 30 ++++++++++++++++++++++++++++-- Dockerfile | 5 +++-- 3 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 .github/bleeding_edge.rb diff --git a/.github/bleeding_edge.rb b/.github/bleeding_edge.rb new file mode 100644 index 00000000..55f7bec8 --- /dev/null +++ b/.github/bleeding_edge.rb @@ -0,0 +1,13 @@ +lines = ["source \"https://rubygems.org\""] + +Gem::Specification.stubs.each do |stub| + url = stub.metadata["source_code_uri"] || stub.homepage + matched = url[%r{https?://git(?:hub|lab)\.com/[^\/]*/[^\/]*}] + if matched && stub.name != "minitest" + lines << "gem #{stub.name.inspect}, git: #{matched.inspect}" + else + lines << "gem #{stub.name.inspect}" + end +end + +File.write("Gemfile", lines.join("\n")) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index b5a74b39..dd0ce0f8 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -7,10 +7,20 @@ on: # yamllint disable-line rule:truthy pull_request: branches: - master + schedule: + - cron: 0 20 * * * + workflow_dispatch: + inputs: + bleeding_edge: + type: boolean + default: false permissions: contents: read +env: + BLEEDING_EDGE: "${{ (inputs.bleeding_edge == true || github.event_name == 'schedule') && 'true' || 'false' }}" + jobs: tests: runs-on: ubuntu-latest @@ -19,6 +29,18 @@ jobs: - uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + + - if: env.BLEEDING_EDGE == 'true' + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + - if: env.BLEEDING_EDGE == 'true' + name: Unfreeze bundler + run: bundle config --local deployment false + - if: env.BLEEDING_EDGE == 'true' + name: "Use git gem sources" + run: bundle exec ruby .github/bleeding_edge.rb && bundle lock && cat Gemfile.lock + - name: Build uses: docker/build-push-action@v5 @@ -27,6 +49,8 @@ jobs: 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: | @@ -54,7 +78,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: @@ -67,5 +92,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 }} diff --git a/Dockerfile b/Dockerfile index a5089a96..73afc691 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ -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 @@ -12,7 +13,7 @@ FROM node:20-alpine3.20 AS node-downloader RUN npm install esbuild@0.23.1 -g -FROM ruby:3.3.4-alpine3.20 +FROM ${BASE_IMAGE:-ruby:3.3.4-alpine3.20} WORKDIR /app