Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to avo 3 #4342

Merged
merged 27 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
68c6423
Add avo-advanced v3 to gemfile
segiddins Sep 1, 2024
f2dab44
[WIP] Upgrade to avo 3
segiddins Jan 10, 2024
c0b114b
Avo working?
segiddins Sep 4, 2024
846b771
Ensure avo advanced when responding to requests in prod/staging
segiddins Sep 4, 2024
ebb2e0b
More tests work without avo pro
segiddins Sep 4, 2024
d28c886
Better skip
segiddins Sep 4, 2024
2c05af3
More avo tests passing
segiddins Sep 8, 2024
d9a8090
Hacks migrated to avo 3
segiddins Sep 11, 2024
abec4d7
Avo pro test fixes
segiddins Sep 11, 2024
36667a3
Fix docker builds with avo 3
segiddins Sep 20, 2024
0b1321d
Fix policy tests
segiddins Sep 20, 2024
4eeec10
Bundle install
segiddins Sep 20, 2024
c885b82
Remove manual editing of oidc api key roles
segiddins Sep 20, 2024
0a86c37
Fix avo job ruby version
segiddins Sep 21, 2024
fe8c6bf
Fix new action
segiddins Sep 21, 2024
d041f72
Update for no manual editing
segiddins Sep 21, 2024
7a6b5a6
Fix docker building on CI
segiddins Sep 23, 2024
51e6828
Use avo main for actionstorage fix
segiddins Sep 23, 2024
3ef0600
Add missing env
segiddins Sep 23, 2024
4948425
Build avo assets
segiddins Sep 23, 2024
8e95444
Add git in builder
segiddins Sep 23, 2024
653c333
Fix deleting js sourcemaps in dockerfile
segiddins Sep 23, 2024
ac0f3b2
Skip avo pro in that CI job
segiddins Sep 23, 2024
8cf4d90
Fix checking for REQUIRE_AVO_PRO
segiddins Sep 23, 2024
1fddf31
Fix finding comment field when avo pro is missing
segiddins Sep 24, 2024
068834f
Avo 3.13
segiddins Oct 1, 2024
56325b1
Remove outdated comments
segiddins Oct 13, 2024
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
9 changes: 9 additions & 0 deletions .github/actions/setup-rubygems.org/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,22 @@ inputs:
rubygems-version:
description: "RubyGems version to use"
required: true
install-avo-pro:
description: "Install Avo gem"
required: false
default: "true"
runs:
using: "composite"
steps:
- name: Install and start services
shell: bash
run: |
docker compose up -d --wait
- name: Configure bundler environment
shell: bash
if: github.secret_source != 'None' && inputs.install-avo-pro == 'true'
run: |
printf "BUNDLE_WITH=avo\nRAILS_GROUPS=avo\n" >> $GITHUB_ENV
- uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # v1.191.0
with:
ruby-version: ${{ inputs.ruby-version }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ jobs:
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
- name: build, test and optionally push docker image
run: ./script/build_docker.sh
env:
BUNDLE_PACKAGER__DEV: ${{ secrets.BUNDLE_PACKAGER__DEV }}
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,19 @@ jobs:
command: test
- name: system
command: test:system
include:
- rubygems: { name: latest, version: latest }
ruby_version: "3.3.5"
tests: { name: "avo without pro", command: "test test/*/avo" }
name: Rails tests ${{ matrix.tests.name }} (RubyGems ${{ matrix.rubygems.name }}, Ruby ${{ matrix.ruby_version }})
runs-on: ubuntu-22.04
env:
RUBYGEMS_VERSION: ${{ matrix.rubygems.version }}
# Fail hard when Toxiproxy is not running to ensure all tests (even Toxiproxy optional ones) are passing
REQUIRE_TOXIPROXY: true
REQUIRE_AVO_PRO: ${{ github.secret_source != 'None' && matrix.tests.name != 'avo without pro' }}
AVO_LICENSE_KEY: ${{ secrets.AVO_LICENSE_KEY }}
BUNDLE_PACKAGER__DEV: ${{ secrets.BUNDLE_PACKAGER__DEV }}
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1

Expand All @@ -49,6 +56,7 @@ jobs:
with:
ruby-version: ${{ matrix.ruby_version }}
rubygems-version: ${{ matrix.rubygems.version }}
install-avo-pro: ${{ matrix.tests.name != 'avo without pro' }}

- name: Tests ${{ matrix.tests.name }}
id: test-all
Expand Down
13 changes: 9 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# syntax = docker/dockerfile:1.4
# syntax = docker/dockerfile:1.10

# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
ARG RUBY_VERSION=3.3.5
Expand Down Expand Up @@ -40,18 +40,23 @@ RUN \
build-base \
linux-headers \
zlib-dev \
tzdata
tzdata \
git

WORKDIR /app

ENV RAILS_ENV="production"
ARG BUNDLE_WITH=""

# Install application gems
COPY Gemfile* .ruby-version /app/
RUN --mount=type=cache,id=bld-gem-cache,sharing=locked,target=/srv/vendor <<BASH
RUN --mount=type=cache,id=bld-gem-cache,sharing=locked,target=/srv/vendor \
--mount=type=secret,id=BUNDLE_PACKAGER__DEV,env=BUNDLE_PACKAGER__DEV \
<<BASH
set -ex

bundle config set --local without 'development test'
bundle config set --local with ${BUNDLE_WITH:-}
bundle config set --local path /srv/vendor
bundle install --jobs 20 --retry 5
bundle clean
Expand All @@ -66,7 +71,7 @@ RUN --mount=type=cache,id=bld-gem-cache,sharing=locked,target=/srv/vendor <<BASH
rm /app/vendor/ruby/*/extensions/*/*/*/gem_make.out

# Remove avo source maps (8+ MB!)
rm /app/vendor/ruby/*/gems/avo-*/public/avo-assets/*.js.map
find /app/vendor/ruby -type f -name '*.js.map' -exec rm {} \;

# Remove ruby 2.x source code
find /app/vendor/ruby/*/gems/debase-ruby_core_source-*/lib/debase/ruby_core_source -maxdepth 1 -type d -name 'ruby-2.*' -exec rm -r {} \;
Expand Down
13 changes: 11 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,19 @@ gem "faraday-multipart", "~> 1.0"
gem "timescaledb", "~> 0.3"

# Admin dashboard
gem "avo", "~> 2.53"
gem "avo", "~> 3.13"
gem "pagy", "~> 8.4"
gem "view_component", "~> 3.14"
gem "view_component", "~> 3.14.0"
gem "pundit", "~> 2.4"
gem "chartkick", "~> 5.1"
gem "groupdate", "~> 6.5"
gem "dry-initializer", "~> 3.1"

group :avo, optional: true do
source "https://packager.dev/avo-hq/" do
gem "avo-advanced", "~> 3.13"
end
end

# Logging
gem "amazing_print", "~> 1.6"
Expand Down Expand Up @@ -146,3 +153,5 @@ group :test do
gem "minitest-reporters", "~> 1.7"
gem "gem_server_conformance", "~> 0.1.4"
end

gem "avo_upgrade", "~> 0.1.1", group: :development
93 changes: 67 additions & 26 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
GEM
remote: https://packager.dev/avo-hq/
specs:
avo-advanced (3.13.1)
avo (= 3.13.1)
avo-dynamic_filters (= 3.13.1)
avo-pro (= 3.13.1)
zeitwerk (>= 2.6.12)
avo-dashboards (3.13.1)
avo (= 3.13.1)
turbo-rails
view_component (>= 3.7.0)
zeitwerk (>= 2.6.12)
avo-dynamic_filters (3.13.1)
avo (= 3.13.1)
ransack (>= 4.2.0)
view_component (>= 3.7.0)
zeitwerk (>= 2.6.12)
avo-menu (3.13.1)
avo (= 3.13.1)
docile
zeitwerk (>= 2.6.12)
avo-pro (3.13.1)
avo (= 3.13.1)
avo-dashboards (= 3.13.1)
avo-menu (= 3.13.1)
zeitwerk (>= 2.6.12)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -89,21 +117,24 @@ GEM
attr_required (1.0.2)
autoprefixer-rails (10.4.19.0)
execjs (~> 2)
avo (2.53.0)
actionview (>= 6.0)
avo (3.13.1)
actionview (>= 6.1)
active_link_to
activerecord (>= 6.0)
activerecord (>= 6.1)
activesupport (>= 6.1)
addressable
docile
dry-initializer
httparty
inline_svg
literal (~> 0.2)
meta-tags
pagy
turbo-rails
turbo_power (~> 0.5.0)
view_component (>= 2.54.0)
zeitwerk (>= 2.6.2)
pagy (>= 7.0.0)
turbo-rails (>= 2.0.0)
turbo_power (>= 0.6.0)
view_component (>= 3.7.0)
zeitwerk (>= 2.6.12)
avo_upgrade (0.1.1)
rails (>= 6.0.0)
zeitwerk
awrence (1.2.1)
aws-eventstream (1.3.0)
aws-partitions (1.983.0)
Expand Down Expand Up @@ -313,10 +344,6 @@ GEM
domain_name (~> 0.5)
http-form_data (2.3.0)
http_accept_language (2.1.1)
httparty (0.22.0)
csv
mini_mime (>= 1.0.0)
multi_xml (>= 0.5.2)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
importmap-rails (2.0.1)
Expand Down Expand Up @@ -392,6 +419,7 @@ GEM
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
literal (0.2.1)
llhttp-ffi (0.5.0)
ffi-compiler (~> 1.0)
rake (~> 13.0)
Expand Down Expand Up @@ -428,7 +456,7 @@ GEM
marcel (1.0.4)
matrix (0.4.2)
memory_profiler (1.1.0)
meta-tags (2.22.0)
meta-tags (2.22.1)
actionpack (>= 6.0.0, < 8.1)
method_source (1.1.0)
mini_histogram (0.3.1)
Expand Down Expand Up @@ -621,6 +649,10 @@ GEM
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.2.1)
ransack (4.2.1)
activerecord (>= 6.1.5)
activesupport (>= 6.1.5)
i18n
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
Expand Down Expand Up @@ -790,12 +822,11 @@ GEM
bindata (~> 2.4)
openssl (> 2.0)
openssl-signature_algorithm (~> 1.0)
turbo-rails (1.5.0)
turbo-rails (2.0.10)
actionpack (>= 6.0.0)
activejob (>= 6.0.0)
railties (>= 6.0.0)
turbo_power (0.5.0)
turbo-rails (~> 1.3)
turbo_power (0.6.2)
turbo-rails (>= 1.3.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.6.0)
Expand Down Expand Up @@ -858,7 +889,9 @@ DEPENDENCIES
aggregate_assertions (~> 0.2.0)
amazing_print (~> 1.6)
autoprefixer-rails (~> 10.4)
avo (~> 2.53)
avo (~> 3.13)
avo-advanced (~> 3.13)!
avo_upgrade (~> 0.1.1)
aws-sdk-s3 (~> 1.167)
aws-sdk-sqs (~> 1.86)
bcrypt (~> 3.1)
Expand All @@ -879,6 +912,7 @@ DEPENDENCIES
discard (~> 1.3)
dogstatsd-ruby (~> 5.6)
dotenv-rails (~> 3.1)
dry-initializer (~> 3.1)
factory_bot_rails (~> 6.4)
faraday (~> 2.12)
faraday-multipart (~> 1.0)
Expand Down Expand Up @@ -966,7 +1000,7 @@ DEPENDENCIES
unpwn (~> 1.0)
user_agent_parser (~> 2.18)
validates_formatting_of (~> 0.9)
view_component (~> 3.14)
view_component (~> 3.14.0)
webauthn (~> 3.1)
webmock (~> 3.24)
xml-simple (~> 1.1)
Expand Down Expand Up @@ -994,7 +1028,13 @@ CHECKSUMS
ast (2.4.2) sha256=1e280232e6a33754cde542bc5ef85520b74db2aac73ec14acef453784447cc12
attr_required (1.0.2) sha256=f0ebfc56b35e874f4d0ae799066dbc1f81efefe2364ca3803dc9ea6a4de6cb99
autoprefixer-rails (10.4.19.0) sha256=ccd21f47e5a07a581c7d239025e0d8d06a005825e96e06f72382d818fe665f4e
avo (2.53.0) sha256=e8f1fb9abaf6d874d898449d4db863586c16e60634a136d97ae436ded976d1a6
avo (3.13.1) sha256=6fd001bda35c4b307579fbc6f597de60d89846b04b96d2bc4cb06bcd54b5945b
avo-advanced (3.13.1) sha256=87d87a6e0837dbeab549428f3afbcb0e0c81e23e46de62dffd0a1270bffc1d0e
avo-dashboards (3.13.1) sha256=073cdbb7c7e9ad46693291d6d5976bdba1a900bf572376a88e02b793f9e4e528
avo-dynamic_filters (3.13.1) sha256=adb72eae45ca400c595e6999dcfcea7d28f3c2d513b0520599a3fe0d39538671
avo-menu (3.13.1) sha256=444fec35ccc1956bbbb6ff7489c48641d88350d8dfb55652681cadb03b87d901
avo-pro (3.13.1) sha256=c465c9886926f155dd9fd8d46bbb96018260cced9af8206bf64c428a25793f09
avo_upgrade (0.1.1) sha256=8d841083b9956392f5c8fe195f25bec0d139e3646d276f8a59e66b7d2e9ebf30
awrence (1.2.1) sha256=dd1d214c12a91f449d1ef81d7ee3babc2816944e450752e7522c65521872483e
aws-eventstream (1.3.0) sha256=f1434cc03ab2248756eb02cfa45e900e59a061d7fbdc4a9fd82a5dd23d796d3f
aws-partitions (1.983.0) sha256=eb3ab086749ca426e735a50bd1ea669a4b7bc52be3c119a772bd277cc906bb11
Expand Down Expand Up @@ -1091,7 +1131,6 @@ CHECKSUMS
http-cookie (1.0.7) sha256=cb7a399f3344f720b8a0f3b0765f29b62608ebb9c3ce4abf4d6eeff2caf42253
http-form_data (2.3.0) sha256=cc4eeb1361d9876821e31d7b1cf0b68f1cf874b201d27903480479d86448a5f3
http_accept_language (2.1.1) sha256=0043f0d55a148cf45b604dbdd197cb36437133e990016c68c892d49dbea31634
httparty (0.22.0) sha256=78652a5c9471cf0093d3b2083c2295c9c8f12b44c65112f1846af2b71430fa6c
i18n (1.14.6) sha256=dc229a74f5d181f09942dd60ab5d6e667f7392c4ee826f35096db36d1fe3614c
importmap-rails (2.0.1) sha256=e739a6e70c09f797688c6983fa79567ec1edc9becc30d55b3f7cc897b1825586
inline_svg (1.10.0) sha256=5b652934236fd9f8adc61f3fd6e208b7ca3282698b19f28659971da84bf9a10f
Expand Down Expand Up @@ -1121,6 +1160,7 @@ CHECKSUMS
libddwaf (1.14.0.0.0-x86_64-darwin) sha256=33017c057fd6b4948ef4577c4a13bc89d878541961b205309fac1e71516433ff
libddwaf (1.14.0.0.0-x86_64-linux) sha256=030640a4158ae05f9276cc1e09bfe9d19dda5af26703235cf17cf3752f1985b1
listen (3.9.0) sha256=db9e4424e0e5834480385197c139cb6b0ae0ef28cc13310cfd1ca78377d59c67
literal (0.2.1) sha256=7544725886486ce6ae701fea1ea23bb7955ef218ef109f91ad4414f3b7921261
llhttp-ffi (0.5.0) sha256=496f40ad44bcbf99de02da1f26b1ad64e6593cd487b931508a86228e2a3af0fa
local_time (3.0.2) sha256=cb8abb2d56726ae285d00b0bd7f4c34bafc38c0c1cbc70ddc28f3a5661168d9d
logger (1.6.1) sha256=3ad9587ed3940bf7897ea64a673971415523f4f7d6b22c5e3af5219705669653
Expand All @@ -1131,7 +1171,7 @@ CHECKSUMS
marcel (1.0.4) sha256=0d5649feb64b8f19f3d3468b96c680bae9746335d02194270287868a661516a4
matrix (0.4.2) sha256=71083ccbd67a14a43bfa78d3e4dc0f4b503b9cc18e5b4b1d686dc0f9ef7c4cc0
memory_profiler (1.1.0) sha256=79a17df7980a140c83c469785905409d3027ca614c42c086089d128b805aa8f8
meta-tags (2.22.0) sha256=c04df1f39cfbf7d48e2ae955124d89a2429ab508fc936b9a8f9a8ce4d326e6ec
meta-tags (2.22.1) sha256=e5ae1febbd320d396c7226d7edb868e5d63466c14b9c8b06622a1a74e6dce354
method_source (1.1.0) sha256=181301c9c45b731b4769bc81e8860e72f9161ad7d66dd99103c9ab84f560f5c5
mini_histogram (0.3.1) sha256=6a114b504e4618b0e076cc672996036870f7cc6f16b8e5c25c0c637726d2dd94
mini_mime (1.1.5) sha256=8681b7e2e4215f2a159f9400b5816d85e9d8c6c6b491e96a12797e798f8bccef
Expand Down Expand Up @@ -1206,6 +1246,7 @@ CHECKSUMS
railties (7.2.1) sha256=4b6ad279bbfb9228d7e7fbc8df562a8f5d4910e179b957d801fcec176d548463
rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
rake (13.2.1) sha256=46cb38dae65d7d74b6020a4ac9d48afed8eb8149c040eccf0523bec91907059d
ransack (4.2.1) sha256=e0f688c6ef35abe0bad3cf5afc1b050f36a819bdd56eb454c955c63cdd1bef40
rb-fsevent (0.11.2) sha256=43900b972e7301d6570f64b850a5aa67833ee7d87b458ee92805d56b7318aefe
rb-inotify (0.10.1) sha256=050062d4f31d307cca52c3f6a7f4b946df8de25fc4bd373e1a5142e41034a7ca
rbtrace (0.5.1) sha256=e8cba64d462bfb8ba102d7be2ecaacc789247d52ac587d8003549d909cb9c5dc
Expand Down Expand Up @@ -1280,8 +1321,8 @@ CHECKSUMS
timescaledb (0.3.0) sha256=9ce2b39417d30544054cb609fbd84e18e304c7b7952a793846b8f4489551a28f
toxiproxy (2.0.2) sha256=2e3b53604fb921d40da3db8f78a52b3133fcae33e93d440725335b15974e440a
tpm-key_attestation (0.12.0) sha256=e133d80cf24fef0e7a7dfad00fd6aeff01fc79875fbfc66cd8537bbd622b1e6d
turbo-rails (1.5.0) sha256=b426cc762fb0940277729b3f1751a9f0bd269f5613c1d62ac73e5f0be7c7a83e
turbo_power (0.5.0) sha256=869726c3a4308b038d6244f7a80eb1331bdd3171fa320dddcff71899fcae24fb
turbo-rails (2.0.10) sha256=11cde241f9335ef6962322642dfd764178de192d0ba45101963da0f10f8e5738
turbo_power (0.6.2) sha256=c9080d0d1bb79deed67bee2a7654dd38f9c903b57ad52b98d19d000958fde2cc
tzinfo (2.0.6) sha256=8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b
unicode-display_width (2.6.0) sha256=12279874bba6d5e4d2728cef814b19197dbb10d7a7837a869bab65da943b7f5a
unpwn (1.0.0) sha256=6239d17d46a882b3719b24fb79c78a34caff89d57ab0f5e546be5b5c882bc7d3
Expand Down
16 changes: 10 additions & 6 deletions app/avo/actions/add_owner.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
class AddOwner < BaseAction
class Avo::Actions::AddOwner < Avo::Actions::ApplicationAction
self.name = "Add owner"
self.visible = lambda {
current_user.team_member?("rubygems-org") && view == :show
}

field :owner, as: :select_record, searchable: true, name: "New owner", use_resource: UserResource
def fields
field :owner, as: :select_record, searchable: true, name: "New owner", use_resource: Avo::Resources::User

super
end

self.message = lambda {
"Are you sure you would like to add an owner to #{record.name}?"
}

self.confirm_button_label = "Add owner"

class ActionHandler < ActionHandler
class ActionHandler < Avo::Actions::ActionHandler
set_callback :handle, :before do
@owner = fields[:owner]
error "Must specify a valid user to add as owner" if @owner.blank?
Expand All @@ -22,16 +26,16 @@ class ActionHandler < ActionHandler
error "Cannot add #{@owner.name} as an owner since they are unconfirmed" if @owner.unconfirmed?
end

def do_handle_model(rubygem)
def do_handle_record(rubygem)
@rubygem = rubygem
super
end

set_callback :handle_model, :before do
set_callback :handle_record, :before do
error "Cannot add #{@owner.name} as an owner since they are already an owner of #{@rubygem.name}" if @owner.rubygems.include?(@rubygem)
end

def handle_model(rubygem)
def handle_record(rubygem)
authorizer = User.security_user
rubygem.ownerships.create!(user: @owner, authorizer: authorizer, confirmed_at: Time.current)
succeed "Added #{@owner.name} to #{@rubygem.name}"
Expand Down
Loading