Skip to content

Commit

Permalink
Merge pull request #127 from OpenSourcePolitics/develop
Browse files Browse the repository at this point in the history
Bump 0.27
  • Loading branch information
Quentinchampenois authored Sep 25, 2023
2 parents 95e7869 + 73406db commit a813f77
Show file tree
Hide file tree
Showing 325 changed files with 191,560 additions and 21,304 deletions.
126 changes: 31 additions & 95 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ env:
CI: "true"
SIMPLECOV: "true"
RSPEC_FORMAT: "documentation"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.6
RAILS_ENV: test
NODE_VERSION: 16.9.1
RUBYOPT: '-W:no-deprecated'
Expand Down Expand Up @@ -37,11 +37,23 @@ jobs:
with:
ruby_version: ${{ env.RUBY_VERSION }}
node_version: ${{ env.NODE_VERSION }}
zeitwerk:
name: Check for Zeitwerk errors
runs-on: ubuntu-latest
if: "!startsWith(github.head_ref, 'chore/l10n')"
timeout-minutes: 60
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true
- name: Check for Zeitwerk errors
run: |
bundle exec rails zeitwerk:check
tests:
strategy:
fail-fast: false
matrix:
slice: [ "0-2", "1-2" ]
name: Tests
runs-on: ubuntu-latest
services:
Expand All @@ -64,58 +76,17 @@ jobs:
if: "github.ref != 'refs/heads/master' || github.ref != 'refs/heads/develop'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: yarn install --prefer-offline --frozen-lockfile
- name: Create db
run: |
bundle exec rails parallel:create parallel:migrate
- name: Register cache hash
id: cache-hash
run: |
echo "::set-output name=hash::$(bundle exec rake test:assets_hash)"
- uses: OpenSourcePolitics/cache-precompile-action@master
- uses: OpenSourcePolitics/rspec-action@master
with:
key: asset-cache-${{ runner.os }}-${{ steps.cache-hash.outputs.hash }}
- run: mkdir -p ./spec/tmp/screenshots
name: Create the screenshots folder
# TODO: Use latest version
- uses: nanasess/setup-chromedriver@v2
with:
chromedriver-version: "114.0.5735.90"
- run: bundle exec rake "test:run[exclude, spec/system/**/*_spec.rb, ${{ matrix.slice }}]"
name: RSpec
- run: ./.github/upload_coverage.sh decidim-app $GITHUB_EVENT_PATH
name: Upload coverage
- uses: actions/upload-artifact@v3
if: always()
with:
name: screenshots
path: ./spec/tmp/screenshots
- uses: actions/upload-artifact@v3
if: always()
with:
name: assets-manifest-${{ matrix.slice }}
path: ./tmp/assets_manifest.json
command: 'bundle exec rspec --exclude-pattern "spec/system/**/*_spec.rb"'
prepare_command: "bundle exec rails db:create db:migrate"
system_tests:
strategy:
matrix:
slice: [ "0-4", "1-4", "2-4", "3-4" ]
name: System tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11
ports: ["5432:5432"]
ports: [ "5432:5432" ]
options: >-
--health-cmd pg_isready
--health-interval 10s
Expand All @@ -127,53 +98,18 @@ jobs:
DATABASE_USERNAME: postgres
DATABASE_PASSWORD: postgres
DATABASE_HOST: localhost
RAILS_ENV: test
# Set locales available for i18n tasks
ENFORCED_LOCALES: "en"
steps:
- uses: rokroskar/[email protected]
if: "github.ref != 'refs/heads/master' || github.ref != 'refs/heads/develop'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- uses: actions/checkout@v3
- uses: OpenSourcePolitics/rspec-action@master
with:
fetch-depth: 1
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: yarn install --prefer-offline --frozen-lockfile
- name: Create db
run: |
bundle exec rails parallel:create parallel:migrate
- name: Register cache hash
id: cache-hash
run: |
echo "::set-output name=hash::$(bundle exec rake test:assets_hash)"
- uses: OpenSourcePolitics/cache-precompile-action@master
with:
key: asset-cache-${{ runner.os }}-${{ steps.cache-hash.outputs.hash }}
- run: mkdir -p ./spec/tmp/screenshots
name: Create the screenshots folder
# TODO: Use latest version
- uses: nanasess/setup-chromedriver@v2
with:
chromedriver-version: "114.0.5735.90"
- run: bundle exec rake "test:run[include, spec/system/**/*_spec.rb, ${{ matrix.slice }}]"
name: RSpec
- run: ./.github/upload_coverage.sh decidim-app $GITHUB_EVENT_PATH
name: Upload coverage
- uses: actions/upload-artifact@v3
if: always()
with:
name: screenshots
path: ./spec/tmp/screenshots
- uses: actions/upload-artifact@v3
if: always()
with:
name: assets-manifest-${{ matrix.slice }}
path: ./tmp/assets_manifest.json
command: 'bundle exec rspec "spec/system"'
prepare_command: "bundle exec rails db:create db:migrate"
test_build:
name: Test build docker image
runs-on: ubuntu-latest
Expand Down Expand Up @@ -204,9 +140,9 @@ jobs:
database_password: ${{ env.DATABASE_PASSWORD }}
database_host: ${{ env.DATABASE_HOST }}
build_and_push_image_dev:
name: Build and push image to Registry
if: "github.ref == 'refs/heads/develop'"
needs: [lint, tests, system_tests, test_build]
name: Build and push image to Registry
needs: [ lint, zeitwerk, tests, system_tests, test_build ]
runs-on: ubuntu-latest
steps:
- uses: OpenSourcePolitics/build-and-push-images-action@master
Expand All @@ -215,10 +151,10 @@ jobs:
namespace: ${{ vars.REGISTRY_NAMESPACE }}
password: ${{ secrets.TOKEN }}
image_name: ${{ vars.IMAGE_NAME }}
tag: "develop"
tag: ${{ github.ref }}
generate_release:
name: Generate release
needs: [lint, tests, system_tests, test_build]
needs: [ lint, zeitwerk, tests, system_tests, test_build ]
if: "github.ref == 'refs/heads/master'"
runs-on: ubuntu-latest
steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,4 @@ git-status.txt
/yarn-error.log
yarn-debug.log*
.yarn-integrity
app/compiled_views/
11 changes: 11 additions & 0 deletions .rubocop-disabled.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Style/OpenStructUse:
Enabled: false

Gemspec/RequireMFA:
Enabled: false

Naming/MemoizedInstanceVariableName:
Enabled: false

RSpec/VerifiedDoubleReference:
Enabled: false
3 changes: 2 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
inherit_from:
- .rubocop_ruby.yml
- .rubocop_rails.yml
- .rubocop_rails.yml
- .rubocop-disabled.yml
4 changes: 4 additions & 0 deletions .rubocop_rails.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
require: rubocop-rails

Lint/MissingSuper:
Exclude:
- lib/decidim/proposals/proposal_serializer.rb

Rails:
Enabled: true

Expand Down
13 changes: 3 additions & 10 deletions .rubocop_ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,7 @@ AllCops:
# If a value is specified for TargetRubyVersion then it is used.
# Else if .ruby-version exists and it contains an MRI version it is used.
# Otherwise we fallback to the oldest officially supported Ruby version (2.0).
TargetRubyVersion: 2.7

RSpec:
Patterns:
- "(?:^|/)spec/"
- "(?:^|/)test/"
TargetRubyVersion: 3.0

Lint/SafeNavigationChain:
Exclude:
Expand Down Expand Up @@ -468,6 +463,7 @@ Naming/FileName:
- "**/Gemfile"
- "**/Rakefile"
- "**/*.gemspec"

# When true, requires that each source file should define a class or module
# with a name which matches the file name (converted to ... case).
# It further expects it to be nested inside modules which match the names
Expand Down Expand Up @@ -1098,10 +1094,6 @@ Style/WordArray:
# The regular expression WordRegex decides what is considered a word.
WordRegex: !ruby/regexp '/\A[\p{Word}\n\t]+\z/'

Style/MutableConstant:
Exclude:
- "bin/overloads"

##################### Metrics ##################################

Metrics/AbcSize:
Expand Down Expand Up @@ -1276,6 +1268,7 @@ RSpec/RepeatedExampleGroupDescription:

RSpec/RepeatedExampleGroupBody:
Enabled: false

RSpec/VerifiedDoubles:
Enabled: false

Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.5
3.0.6
51 changes: 34 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,39 +1,56 @@
FROM ruby:2.7.5
FROM ruby:3.0.6-slim as builder

ENV RAILS_ENV=production \
SECRET_KEY_BASE=dummy

WORKDIR /app

# Install NodeJS
RUN --mount=type=cache,target=/var/cache/apt \
RUN apt-get update && \
apt-get -y install libpq-dev curl git libicu-dev build-essential && \
curl https://deb.nodesource.com/setup_16.x | bash && \
apt install -y nodejs && \
apt update && \
npm install -g [email protected] && \
apt-get install -y nodejs && \
npm install --global yarn && \
apt install -y libicu-dev postgresql-client && \
gem install bundler:2.2.17 && \
rm -rf /var/lib/apt/lists/*
gem install bundler:2.4.9

COPY Gemfile* ./
RUN bundle config set --local without 'development test' && bundle install
RUN bundle config set --local without 'development test' && \
bundle install -j"$(nproc)"

COPY package* ./
COPY yarn.lock .
COPY packages packages
RUN yarn install
RUN yarn install --frozen-lockfile

COPY . .

RUN bundle exec bootsnap precompile --gemfile app/ lib/ config/ bin/ db/ && \
bundle exec rails assets:precompile && \
bundle exec rails deface:precompile

# Configure endpoint.
COPY ./entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000
RUN rm -rf node_modules tmp/cache vendor/bundle spec \
&& rm -rf /usr/local/bundle/cache/*.gem \
&& find /usr/local/bundle/gems/ -name "*.c" -delete \
&& find /usr/local/bundle/gems/ -name "*.o" -delete \
&& find /usr/local/bundle/gems/ -type d -name "spec" -prune -exec rm -rf {} \; \
&& rm -rf log/*.log

FROM ruby:3.0.6-slim as runner

ENV RAILS_ENV=production \
SECRET_KEY_BASE=dummy \
RAILS_LOG_TO_STDOUT=true

RUN apt update && \
apt install -y postgresql-client imagemagick libproj-dev proj-bin libjemalloc2 && \
gem install bundler:2.4.9

CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]
WORKDIR /app

COPY --from=builder /usr/local/bundle /usr/local/bundle
COPY --from=builder /app /app

ENV LD_PRELOAD="libjemalloc.so.2" \
MALLOC_CONF="background_thread:true,metadata_thp:auto,dirty_decay_ms:5000,muzzy_decay_ms:5000,narenas:2"

EXPOSE 3000
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]
26 changes: 13 additions & 13 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@

source "https://rubygems.org"

DECIDIM_VERSION = "0.26"
DECIDIM_BRANCH = "release/#{DECIDIM_VERSION}-stable"
DECIDIM_VERSION = "0.27"
DECIDIM_BRANCH = "release/#{DECIDIM_VERSION}-stable".freeze

ruby RUBY_VERSION

# Many gems depend on environment variables, so we load them as soon as possible
gem "dotenv-rails", require: "dotenv/rails-now"

# Core gems
gem "decidim", "~> #{DECIDIM_VERSION}.0"
gem "decidim-initiatives", "~> #{DECIDIM_VERSION}.0"

# External Decidim gems
gem "acts_as_textcaptcha", "~> 4.6.0"
gem "decidim-budgets_importer", git: "https://github.com/OpenSourcePolitics/decidim-module-budgets_importer.git", branch: DECIDIM_BRANCH
gem "decidim-budgets_paper_ballots", git: "https://github.com/digidemlab/decidim-module-budgets_paper_ballots", branch: DECIDIM_BRANCH
gem "decidim-budgets_booth", github: "Pipeline-to-Power/decidim-module-ptp", branch: "main"
gem "decidim-budgets_importer", git: "https://github.com/OpenSourcePolitics/decidim-module-budgets_importer.git"
gem "decidim-budgets_paper_ballots", git: "https://github.com/armandfardeau/decidim-module-budgets_paper_ballots"
gem "decidim-cache_cleaner"
gem "decidim-decidim_awesome"
gem "decidim-extended_socio_demographic_authorization_handler", git: "https://github.com/OpenSourcePolitics/decidim-module-extended_socio_demographic_authorization_handler"
gem "decidim-friendly_signup", git: "https://github.com/OpenSourcePolitics/decidim-module-friendly_signup.git"
gem "decidim-question_captcha", git: "https://github.com/OpenSourcePolitics/decidim-module-question_captcha.git"
gem "decidim-simple_proposal", git: "https://github.com/OpenSourcePolitics/decidim-module-simple_proposal.git", branch: "fix/0.26-proposal-form"
gem "decidim-spam_detection"
gem "decidim-term_customizer", git: "https://github.com/armandfardeau/decidim-module-term_customizer.git", branch: "fix/precompile-on-docker-0.26"
gem "decidim-decidim_awesome", "~> 0.9.1"
gem "decidim-extended_socio_demographic_authorization_handler", git: "https://github.com/OpenSourcePolitics/decidim-module-extended_socio_demographic_authorization_handler",
branch: DECIDIM_BRANCH
gem "decidim-friendly_signup", git: "https://github.com/OpenSourcePolitics/decidim-module-friendly_signup", branch: "fast_sign_up_management"
gem "decidim-question_captcha", git: "https://github.com/OpenSourcePolitics/decidim-module-question_captcha.git", branch: DECIDIM_BRANCH
gem "decidim-simple_proposal", git: "https://github.com/opensourcepolitics/decidim-module-simple_proposal.git", branch: "fix/0.27_scope_picker_override"
gem "decidim-spam_detection", "4.0.0"
gem "decidim-term_customizer", git: "https://github.com/armandfardeau/decidim-module-term_customizer.git", branch: "fix/precompile-on-docker-0.27"

# Omniauth gems
gem "omniauth-publik", git: "https://github.com/OpenSourcePolitics/omniauth-publik"
Expand Down
Loading

0 comments on commit a813f77

Please sign in to comment.