Skip to content
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
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: bundler
directory: "/"
schedule:
interval: daily
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: daily
1 change: 1 addition & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This application is owned by the Publishing Platform team. Please let us know in [#govuk-publishing-platform](https://gds.slack.com/archives/C03D792LYJG) when you raise any PRs.
12 changes: 12 additions & 0 deletions .github/workflows/actionlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Lint GitHub Actions
on:
push:
paths: ['.github/**']
jobs:
actionlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
show-progress: false
- uses: alphagov/govuk-infrastructure/.github/actions/actionlint@main
12 changes: 12 additions & 0 deletions .github/workflows/autorelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
on:
workflow_dispatch: {}
schedule:
- cron: '15 9 * * 1-5' # 9:15am UTC, Mon-Fri.

jobs:
autorelease:
uses: alphagov/govuk-infrastructure/.github/workflows/autorelease-rubygem.yml@main
with:
gem_name: content_block_tools
secrets:
GH_TOKEN: ${{ secrets.GOVUK_CI_GITHUB_API_TOKEN }}
63 changes: 63 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: CI

on:
push:
branches:
- main
pull_request:
workflow_dispatch:
inputs:
ref:
description: 'The branch, tag or SHA to checkout'
default: main
type: string

concurrency:
group: ${{ github.workflow }}-${{ github.repository }}-${{ github.ref_name }}
cancel-in-progress: false

jobs:
codeql-sast:
name: CodeQL SAST scan
uses: alphagov/govuk-infrastructure/.github/workflows/codeql-analysis.yml@main
permissions:
security-events: write

dependency-review:
name: Dependency Review scan
uses: alphagov/govuk-infrastructure/.github/workflows/dependency-review.yml@main

# Run the test suite against multiple Ruby and Rails versions
test_matrix:
strategy:
fail-fast: false
matrix:
ruby: [3.2, 3.3, 3.4]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ inputs.ref || github.ref }}
- uses: ruby/setup-ruby@09a7688d3b55cf0e976497ff046b70949eeaccfd # v1.288.0
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bundle exec rake

# Branch protection rules cannot directly depend on status checks from matrix jobs.
# So instead we define `test` as a dummy job which only runs after the preceding `test_matrix` checks have passed.
# Solution inspired by: https://github.community/t/status-check-for-a-matrix-jobs/127354/3
test:
needs: test_matrix
runs-on: ubuntu-latest
steps:
- run: echo "All matrix tests have passed 🚀"

publish:
needs: test
if: ${{ github.ref == 'refs/heads/main' }}
permissions:
contents: write
uses: alphagov/govuk-infrastructure/.github/workflows/publish-rubygem.yml@main
secrets:
GEM_HOST_API_KEY: ${{ secrets.ALPHAGOV_RUBYGEMS_API_KEY }}
9 changes: 9 additions & 0 deletions .github/workflows/gem-bump-checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
on:
workflow_dispatch: {}
pull_request: {}

jobs:
gem-bump-checker:
uses: alphagov/govuk-infrastructure/.github/workflows/gem-bump-checker.yml@main
secrets:
GH_TOKEN: ${{ secrets.GOVUK_CI_GITHUB_API_TOKEN }}
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/.bundle/
/.yardoc
/_yardoc/
/coverage/
/Gemfile.lock
/pkg/
/spec/reports/
/tmp/
spec/examples.txt
.rspec_status
4 changes: 4 additions & 0 deletions .govuk_dependabot_merger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
api_version: 2
defaults:
auto_merge: true
update_external_dependencies: true
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require spec_helper
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
inherit_gem:
rubocop-govuk:
- config/default.yml
- config/rspec.yml
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.2.9
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## 0.1.0

Initial release
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source "https://rubygems.org"

gemspec
21 changes: 21 additions & 0 deletions LICENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2026 Crown Copyright (Government Digital Service)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

Ruby gem that standardises how GOV.UK frontend apps load content items. It provides configurable GraphQL traffic rates per content schema and a request-level loader that routes requests to the Publishing API via GraphQL or falls back to the Content Store ensuring consistent traffic management across applications.

## License
## Licence

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
11 changes: 11 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require "bundler/gem_tasks"
require "rspec/core/rake_task"

RSpec::Core::RakeTask.new(:spec)

desc "Lint Ruby"
task :lint do
sh "bundle exec rubocop"
end

task default: %i[spec lint]
29 changes: 29 additions & 0 deletions govuk_content_item_loader.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "govuk_content_item_loader/version"

Gem::Specification.new do |spec|
spec.name = "govuk_content_item_loader"
spec.version = GovukContentItemLoader::VERSION
spec.authors = ["GOV.UK Dev"]
spec.email = ["govuk-dev@digital.cabinet-office.gov.uk"]

spec.summary = "Provides a standardised content item loader for GOV.UK frontend apps with configurable GraphQL traffic routing and automatic fallback to the Content Store"
spec.homepage = "https://github.com/alphagov/govuk_content_item_loader"
spec.license = "MIT"

spec.required_ruby_version = ">= 3.2"

spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = %w[lib]

spec.add_dependency "gds-api-adapters", ">= 99.3"

spec.add_development_dependency "rails", ">= 7.2"
spec.add_development_dependency "rake", ">= 10.0"
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "rubocop-govuk", "~> 5.2"
spec.add_development_dependency "simplecov"
end
1 change: 1 addition & 0 deletions lib/govuk_content_item_loader.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require "govuk_content_item_loader/version"
3 changes: 3 additions & 0 deletions lib/govuk_content_item_loader/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module GovukContentItemLoader
VERSION = "0.1.0".freeze
end
5 changes: 5 additions & 0 deletions spec/govuk_content_item_loader_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
RSpec.describe GovukContentItemLoader do
it "has a version number" do
expect(GovukContentItemLoader::VERSION).not_to be_nil
end
end
31 changes: 31 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require "active_support"
require "simplecov"
SimpleCov.start

RSpec.configure do |config|
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end

config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end

config.shared_context_metadata_behavior = :apply_to_host_groups

config.filter_run_when_matching :focus

config.example_status_persistence_file_path = "spec/examples.txt"

config.disable_monkey_patching!

config.warnings = true

if config.files_to_run.one?
config.default_formatter = "doc"
end

config.order = :random

Kernel.srand config.seed
end