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

Bump master #28

Merged
merged 23 commits into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 34 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
name: Bug report
about: Create a report to help us improve

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Stacktrace**
If applicable, add the error stacktrace to help explain your problem.

**Extra data (please complete the following information):**
- Device: [e.g. iPhone6, Desktop]
- Device OS: [e.g. iOS8.1, Windows 10]
- Browser: [e.g. Chrome, Firefox, Safari]
- Decidim Version: [e.g. 0.10]
- Decidim installation: [e.g. Metadecidim]

**Additional context**
Add any other context about the problem here. For instance, add Metadecidim link.
25 changes: 25 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#### :tophat: Description
*Please describe your pull request.*

#### :pushpin: Related Issues
*Link your PR to an issue*
- Related to #?
- Fixes #?
- [Notion card]()

#### Testing
*Describe the best way to test or validate your PR.*

Example:
* Log in as admin
* Access Backoffice
* Go to organization settings
* See ...

#### Tasks
- [ ] Add specs
- [ ] Add note about overrides in OVERLOADS.md
- [ ] In case of new dependencies or version bump, update related documentation

### :camera: Screenshots
*Please add screenshots of the changes you're proposing if related to the UI*
105 changes: 79 additions & 26 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
name: "CI-CD"
on: push
name: "CI/CD"
on: [push]

env:
CI: "true"
SIMPLECOV: "true"
RSPEC_FORMAT: "documentation"
RUBY_VERSION: 2.7.5
RAILS_ENV: test
NODE_VERSION: 16.9.1
RUBYOPT: '-W:no-deprecated'

jobs:
lint:
Expand All @@ -17,38 +21,18 @@ jobs:
if: "github.ref != 'refs/heads/develop'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- uses: actions/[email protected]
- uses: OpenSourcePolitics/lint-action@master
with:
fetch-depth: 1
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true
- uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- name: Get npm cache directory path
id: npm-cache-dir-path
run: echo "::set-output name=dir::$(npm get cache)-lint"
- uses: actions/cache@v2
id: npm-cache
with:
path: ${{ steps.npm-cache-dir-path.outputs.dir }}
key: npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-
- name: Install JS dependencies
run: npm ci
- run: bundle exec rubocop -P
name: Lint Ruby files
ruby_version: ${{ env.RUBY_VERSION }}
node_version: ${{ env.NODE_VERSION }}
tests:
name: Tests
runs-on: ubuntu-latest
if: "!startsWith(github.head_ref, 'chore/l10n')"
services:
postgres:
image: postgres:11
ports: ["5432:5432"]
ports: [ "5432:5432" ]
options: >-
--health-cmd pg_isready
--health-interval 10s
Expand Down Expand Up @@ -91,3 +75,72 @@ jobs:
with:
name: screenshots
path: ./spec/decidim_dummy_app/tmp/screenshots
test_build:
name: Test build docker image
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11
ports: [ "5432:5432" ]
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
POSTGRES_PASSWORD: postgres
env:
DATABASE_USERNAME: postgres
DATABASE_PASSWORD: postgres
DATABASE_HOST: host.docker.internal
steps:
- uses: OpenSourcePolitics/build-and-test-images-action@master
with:
registry: ${{ vars.REGISTRY_ENDPOINT }}
namespace: ${{ vars.REGISTRY_NAMESPACE }}
image_name: ${{ vars.IMAGE_NAME }}
tag: ${{ github.ref }}
password: ${{ secrets.TOKEN }}
database_username: ${{ env.DATABASE_USERNAME }}
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, test_build ]
runs-on: ubuntu-latest
steps:
- uses: OpenSourcePolitics/build-and-push-images-action@master
with:
registry: ${{ vars.REGISTRY_ENDPOINT }}
namespace: ${{ vars.REGISTRY_NAMESPACE }}
password: ${{ secrets.TOKEN }}
image_name: ${{ vars.IMAGE_NAME }}
tag: "develop-${{ github.sha }}"
generate_release:
name: Generate release
needs: [ lint, tests, test_build ]
if: "github.ref == 'refs/heads/master'"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: mathieudutour/[email protected]
name: Bump version and push tag
id: tag_version
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- uses: ncipollo/release-action@v1
name: Create a GitHub release
with:
generateReleaseNotes: true
tag: ${{ steps.tag_version.outputs.new_tag }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
- uses: OpenSourcePolitics/build-and-push-images-action@master
with:
registry: ${{ vars.REGISTRY_ENDPOINT }}
namespace: ${{ vars.REGISTRY_NAMESPACE }}
password: ${{ secrets.TOKEN }}
image_name: ${{ vars.IMAGE_NAME }}
tag: ${{ steps.tag_version.outputs.new_tag }}

66 changes: 32 additions & 34 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
FROM ruby:2.6.3

ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ENV RAILS_ENV=production
ENV RAILS_LOG_TO_STDOUT=true
ENV PORT=3000
ENV SECRET_KEY_BASE=f97271c0788641d98a8a7feaa2b8b40fdc28f83285a4f23703abdaf3ac0641a4f047788fd15e4b698e026325ebda371573c370fd6a3bdb720d7e04a580b84882
ENV RAILS_SERVE_STATIC_FILES=true

# Installs bundler dependencies
ENV \
BUNDLE_BIN=/usr/local/bundle/bin \
BUNDLE_JOBS=10 \
BUNDLE_PATH=/usr/local/bundle \
BUNDLE_RETRY=3 \
GEM_HOME=/bundle
ENV PATH="${BUNDLE_BIN}:${PATH}"

RUN apt-get update -qq
RUN apt-get install -y git imagemagick wget \
&& apt-get clean
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - \
&& apt-get install -y nodejs \
&& apt-get clean
RUN npm install -g [email protected]
FROM ruby:2.7.5

ENV RAILS_ENV=production \
SECRET_KEY_BASE=dummy

WORKDIR /app
RUN mkdir -p /app

COPY docker-entrypoint.sh /app/
RUN chmod +x /app/docker-entrypoint.sh
# Install NodeJS
RUN --mount=type=cache,target=/var/cache/apt \
curl https://deb.nodesource.com/setup_16.x | bash && \
apt install -y nodejs && \
apt update && \
npm install -g [email protected] && \
npm install --global yarn && \
apt install -y libicu-dev postgresql-client && \
gem install bundler:2.2.17 && \
rm -rf /var/lib/apt/lists/*

COPY Gemfile* ./
RUN bundle config set --local without 'development test' && bundle install

COPY package* ./
COPY yarn.lock .
RUN yarn install

COPY Gemfile* /app/
RUN export BUNDLER_VERSION=$(cat Gemfile.lock | tail -1 | tr -d " ")
RUN gem install bundler
RUN bundle check || bundle install --system
COPY . /app/
COPY . .

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

# Configure endpoint.
COPY ./entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000

CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ gem "sys-filesystem"

group :development, :test do
gem "byebug", "~> 11.0", platform: :mri
gem "climate_control", "~> 1.2"

gem "decidim-dev", DECIDIM_VERSION
end
Expand All @@ -50,6 +51,7 @@ end

group :production do
gem "dalli"
gem "health_check", "~> 3.1"
gem "lograge"
gem "newrelic_rpm"
gem "passenger"
Expand All @@ -58,5 +60,6 @@ group :production do
gem "sentry-ruby"
gem "sentry-sidekiq"
gem "sidekiq"
gem "sidekiq_alive", "~> 2.2"
gem "sidekiq-scheduler"
end
13 changes: 12 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ GEM
chef-utils (17.7.22)
concurrent-ruby
childprocess (3.0.0)
climate_control (1.2.0)
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
coffee-rails (5.0.0)
Expand Down Expand Up @@ -505,6 +506,8 @@ GEM
graphql (1.12.17)
hashdiff (1.0.1)
hashie (4.1.0)
health_check (3.1.0)
railties (>= 5.0)
highline (2.0.3)
html_tokenizer (0.0.7)
htmlentities (4.3.4)
Expand Down Expand Up @@ -846,6 +849,10 @@ GEM
sidekiq (>= 3)
thwait
tilt (>= 1.4.0)
sidekiq_alive (2.2.0)
rack (< 3)
sidekiq (>= 5, < 8)
webrick (>= 1, < 2)
simplecov (0.19.1)
docile (~> 1.1)
simplecov-html (~> 0.11)
Expand Down Expand Up @@ -918,6 +925,7 @@ GEM
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
webrick (1.8.1)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
Expand All @@ -936,6 +944,7 @@ DEPENDENCIES
activejob-uniqueness
bootsnap (~> 1.4)
byebug (~> 11.0)
climate_control (~> 1.2)
dalli
decidim!
decidim-anonymous_proposals!
Expand All @@ -947,6 +956,7 @@ DEPENDENCIES
faker (~> 2.14)
fog-aws
globalid (~> 1.0)
health_check (~> 3.1)
letter_opener_web (~> 1.3)
listen (~> 3.1)
lograge
Expand All @@ -961,6 +971,7 @@ DEPENDENCIES
sentry-sidekiq
sidekiq
sidekiq-scheduler
sidekiq_alive (~> 2.2)
spring (~> 2.0)
spring-watcher-listen (~> 2.0)
sprockets (~> 3.7)
Expand All @@ -972,4 +983,4 @@ RUBY VERSION
ruby 2.7.5p203

BUNDLED WITH
2.4.9
2.3.26
29 changes: 29 additions & 0 deletions config/initializers/health_check.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

return unless Rails.env.production?

HealthCheck.setup do |config|
# uri prefix (no leading slash)
config.uri = "health_check"

# Text output upon success
config.success = "success"

# Text output upon failure
config.failure = "health_check failed"

# Disable the error message to prevent /health_check from leaking
# sensitive information
config.include_error_in_response_body = false

# Log level (success or failure message with error details is sent to rails log unless this is set to nil)
config.log_level = "info"

# Timeout in seconds used when checking smtp server
config.smtp_timeout = 30.0

config.http_status_for_error_object = 500

# You can customize which checks happen on a standard health check, eg to set an explicit list use:
config.standard_checks = %w(database migrations)
end
7 changes: 7 additions & 0 deletions config/initializers/sidekiq_alive.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

return unless Rails.env.production?

SidekiqAlive.setup do |config|
config.path = "/sidekiq_alive"
end
Loading