Skip to content

Commit

Permalink
Release 150
Browse files Browse the repository at this point in the history
  • Loading branch information
mec committed Nov 25, 2024
2 parents c7bb596 + 1e05108 commit 2dfa0c9
Show file tree
Hide file tree
Showing 30 changed files with 263 additions and 97 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/build_and_cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Build and cache
description: |
Builds the Docker image, caches layers to the Github action cache
and loads the built image into Docker"
runs:
using: "composite"
steps:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Build and cache
uses: docker/build-push-action@v6
with:
context: .
build-args: |
RAILS_ENV=test
push: false
load: true
tags: app_test:latest
cache-from: type=gha
cache-to: type=gha,mode=min
69 changes: 69 additions & 0 deletions .github/workflows/ci_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: CI Checks

on:
push:

jobs:
lint-and-format:
name: Linting and formatting
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Build and cache
uses: ./.github/workflows/build_and_cache
-
name: Run Standard Ruby
run: |
docker run --rm app_test:latest /bin/bash -c "bundle exec standardrb -f simple"
-
name: Run Shellcheck
run: |
for file in $(git ls-files script/*)
do shellcheck -x "$file"
done
static-analysis:
name: Static analysis
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Build and cache
uses: ./.github/workflows/build_and_cache
-
name: Run Brakeman
run: |
docker run --rm app_test:latest /bin/bash -c "bundle exec brakeman -o /dev/stdout"
specs:
name: Specs and coverage
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Build and cache
uses: ./.github/workflows/build_and_cache
-
name: Run Rspec and Simplecov
run: |
docker compose -p app_test -f docker-compose.ci.yml \
run --name app_test test /bin/bash -c "bin/rspec --format=documentation"
-
name: Copy coverage report from container
run: mkdir coverage && docker cp app_test:/app/coverage/lcov.info coverage/lcov.info
-
name: Shutdown containers
run: docker compose -p app_test down && docker compose -p app_test rm
-
name: Send coverage report to Coveralls
uses: coverallsapp/github-action@v2
with:
file: ./coverage/lcov.info
fail-on-error: false
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

[Full changelog][unreleased]

## Release 150 - 2024-11-25

- Separate out users into tabbed view of active and inactive

## Release 149 - 2024-11-21

[Full changelog][149]
Expand Down Expand Up @@ -1695,7 +1699,8 @@
- Planned start and end dates are mandatory
- Actual start and end dates must not be in the future

[unreleased]: https://github.com/UKGovernmentBEIS/beis-report-official-development-assistance/compare/release-149...HEAD
[unreleased]: https://github.com/UKGovernmentBEIS/beis-report-official-development-assistance/compare/release-150...HEAD
[150]: https://github.com/UKGovernmentBEIS/beis-report-official-development-assistance/compare/release-149...release-150
[149]: https://github.com/UKGovernmentBEIS/beis-report-official-development-assistance/compare/release-148...release-149
[148]: https://github.com/UKGovernmentBEIS/beis-report-official-development-assistance/compare/release-147...release-148
[147]: https://github.com/UKGovernmentBEIS/beis-report-official-development-assistance/compare/release-146...release-147
Expand Down
44 changes: 22 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
# base
# ------------------------------------------------------------------------------
FROM ruby:3.1.2 AS base
MAINTAINER dxw <[email protected]>

ARG RAILS_ENV
ARG NODE_MAJOR

ENV APP_HOME /app
ENV DEPS_HOME /deps
ENV APP_HOME=/app
ENV DEPS_HOME=/deps

ENV NODE_MAJOR ${NODE_MAJOR:-16}
ENV RAILS_ENV ${RAILS_ENV:-production}
ENV NODE_ENV ${RAILS_ENV:-production}
ENV NODE_MAJOR=${NODE_MAJOR:-16}
ENV RAILS_ENV=${RAILS_ENV:-production}
ENV NODE_ENV=${RAILS_ENV:-production}

# Setup Node installation
# https://github.com/nodesource/distributions#installation-instructions
Expand Down Expand Up @@ -40,6 +39,23 @@ RUN apt-get update && apt-get install -qq -y \
yarn \
--fix-missing --no-install-recommends

# Install Firefox and Gecko driver if RAILS_ENV=test
RUN \
if [ "${RAILS_ENV}" = "test" ]; then \
apt-get install -qq -y --fix-missing firefox-esr shellcheck; \
fi

ARG gecko_driver_version=0.31.0

RUN \
if [ "${RAILS_ENV}" = "test" ]; then \
wget https://github.com/mozilla/geckodriver/releases/download/v$gecko_driver_version/geckodriver-v$gecko_driver_version-linux64.tar.gz && \
tar -xvzf geckodriver-v$gecko_driver_version-linux64.tar.gz && \
rm geckodriver-v$gecko_driver_version-linux64.tar.gz && \
chmod +x geckodriver && \
mv geckodriver* /usr/local/bin; \
fi

RUN echo "\nexport PATH=/usr/local/bin:\$PATH\n\n# Stop here if non-interactive shell\n[[ \$- == *i* ]] || return\n\ncd /app" >> ~/.bashrc

# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -124,19 +140,3 @@ ENTRYPOINT ["/docker-entrypoint.sh"]
EXPOSE 3000

CMD ["bundle", "exec", "puma"]

# ------------------------------------------------------------------------------
# test
# ------------------------------------------------------------------------------
FROM web as test

RUN apt-get install -qq -y --fix-missing firefox-esr \
shellcheck

ARG gecko_driver_version=0.31.0

RUN wget https://github.com/mozilla/geckodriver/releases/download/v$gecko_driver_version/geckodriver-v$gecko_driver_version-linux64.tar.gz
RUN tar -xvzf geckodriver-v$gecko_driver_version-linux64.tar.gz
RUN rm geckodriver-v$gecko_driver_version-linux64.tar.gz
RUN chmod +x geckodriver
RUN mv geckodriver* /usr/local/bin
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ ruby File.read(".ruby-version").strip
gem "acts_as_tree"
gem "addressable"
gem "audited", "~> 5.4"
gem "aws-sdk-s3", "~> 1.170"
gem "aws-sdk-s3", "~> 1.173"
gem "bootsnap", ">= 1.1.0", require: false
gem "cssbundling-rails", "~> 1.4"
gem "csv-safe"
gem "govuk_design_system_formbuilder", "~> 4.1.1"
gem "haml-rails"
gem "high_voltage"
gem "ipaddr"
gem "jbuilder", "~> 2.11"
gem "jbuilder", "~> 2.13"
gem "jsbundling-rails", "~> 1.3"
gem "pg"
gem "mail-notify"
Expand Down
38 changes: 19 additions & 19 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ GEM
activerecord (>= 5.0, < 7.2)
request_store (~> 1.2)
aws-eventstream (1.3.0)
aws-partitions (1.1004.0)
aws-sdk-core (3.212.0)
aws-partitions (1.1012.0)
aws-sdk-core (3.213.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.992.0)
aws-sigv4 (~> 1.9)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.95.0)
aws-sdk-kms (1.96.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.170.1)
aws-sdk-s3 (1.173.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
Expand All @@ -94,8 +94,8 @@ GEM
rouge (>= 1.0.0)
bigdecimal (3.1.8)
bindex (0.8.1)
binding_of_caller (1.0.0)
debug_inspector (>= 0.0.1)
binding_of_caller (1.0.1)
debug_inspector (>= 1.2.0)
bootsnap (1.18.4)
msgpack (~> 1.2)
brakeman (6.1.1)
Expand Down Expand Up @@ -138,8 +138,8 @@ GEM
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1)
date (3.4.0)
debug_inspector (1.1.0)
devise (4.9.3)
debug_inspector (1.2.0)
devise (4.9.4)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
Expand Down Expand Up @@ -193,7 +193,7 @@ GEM
haml (>= 4.0.6)
railties (>= 5.1)
hashdiff (1.1.2)
high_voltage (3.1.2)
high_voltage (4.0.0)
highline (3.1.1)
reline
html-attributes-utils (1.0.2)
Expand All @@ -217,7 +217,7 @@ GEM
terminal-table (>= 1.5.1)
io-console (0.7.2)
ipaddr (1.2.7)
jbuilder (2.11.5)
jbuilder (2.13.0)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
jmespath (1.6.2)
Expand Down Expand Up @@ -262,10 +262,10 @@ GEM
matrix (0.4.2)
method_source (1.1.0)
mini_mime (1.1.5)
mini_portile2 (2.8.7)
mini_portile2 (2.8.8)
mini_racer (0.8.0)
libv8-node (~> 18.16.0.0)
minitest (5.25.1)
minitest (5.25.2)
monetize (1.13.0)
money (~> 6.12)
money (6.19.0)
Expand Down Expand Up @@ -301,7 +301,7 @@ GEM
parser (3.3.6.0)
ast (~> 2.4.1)
racc
pg (1.5.4)
pg (1.5.9)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
Expand All @@ -313,7 +313,7 @@ GEM
public_suffix (5.1.1)
puma (6.4.3)
nio4r (~> 2.0)
pundit (2.3.1)
pundit (2.4.0)
activesupport (>= 3.0.0)
pundit-matchers (3.1.2)
rspec-core (~> 3.12)
Expand Down Expand Up @@ -372,8 +372,8 @@ GEM
rb-inotify (0.11.1)
ffi (~> 1.0)
redis (4.8.1)
redis-actionpack (5.4.0)
actionpack (>= 5, < 8)
redis-actionpack (5.5.0)
actionpack (>= 5)
redis-rack (>= 2.1.0, < 4)
redis-store (>= 1.1.0, < 2)
redis-namespace (1.11.0)
Expand All @@ -392,7 +392,7 @@ GEM
actionpack (>= 5.2)
railties (>= 5.2)
rexml (3.3.9)
rollbar (3.5.1)
rollbar (3.6.0)
rollout (2.5.0)
redis (~> 4.0)
rollout-ui (0.5.3)
Expand Down Expand Up @@ -541,7 +541,7 @@ DEPENDENCIES
acts_as_tree
addressable
audited (~> 5.4)
aws-sdk-s3 (~> 1.170)
aws-sdk-s3 (~> 1.173)
better_errors
binding_of_caller
bootsnap (>= 1.1.0)
Expand All @@ -568,7 +568,7 @@ DEPENDENCIES
html2haml
i18n-tasks (~> 1.0.14)
ipaddr
jbuilder (~> 2.11)
jbuilder (~> 2.13)
jsbundling-rails (~> 1.3)
launchy
listen (>= 3.0.5, < 3.10)
Expand Down
8 changes: 7 additions & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ class UsersController < BaseController

def index
authorize :user, :index?
@users = policy_scope(User).includes(:organisation).joins(:organisation).order("users.active DESC, organisations.name ASC, users.name ASC")
@user_state = params[:user_state]
@users = policy_scope(User).includes(:organisation).joins(:organisation).order("organisations.name ASC, users.name ASC")
@users = if @user_state == "active"
@users.active
else
@users.inactive
end
end

def show
Expand Down
6 changes: 3 additions & 3 deletions app/jobs/spending_breakdown_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ def perform(requester_id:, fund_id:)
fund_activity.save!

DownloadLinkMailer.send_link(
recipient: requester,
file_name: upload.timestamped_filename
requester,
upload.timestamped_filename
).deliver
rescue => error
log_error(error, requester)
DownloadLinkMailer.send_failure_notification(recipient: requester).deliver
DownloadLinkMailer.send_failure_notification(requester).deliver
end

def save_tempfile(export)
Expand Down
4 changes: 2 additions & 2 deletions app/mailers/download_link_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class DownloadLinkMailer < ApplicationMailer
def send_link(recipient:, file_name:)
def send_link(recipient, file_name)
@file_name = file_name
@file_url = exports_url

Expand All @@ -15,7 +15,7 @@ def send_link(recipient:, file_name:)
)
end

def send_failure_notification(recipient:)
def send_failure_notification(recipient)
view_mail(
ENV["NOTIFY_VIEW_TEMPLATE"],
to: recipient.email,
Expand Down
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class User < ApplicationRecord
}.freeze

scope :active, -> { where(active: true) }
scope :inactive, -> { where(active: false) }

delegate :service_owner?, :partner_organisation?, to: :organisation

Expand Down
Loading

0 comments on commit 2dfa0c9

Please sign in to comment.