Gov.uk content schemas tech monthly may 2015
-
Upload
david-heath -
Category
Technology
-
view
86 -
download
2
Transcript of Gov.uk content schemas tech monthly may 2015
![Page 1: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/1.jpg)
GOV.UK Tech Monthly - Publishing 2.0 team29th May 2015
David HeathDeveloper@dgheath21
![Page 2: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/2.jpg)
GOV.UK Content
Schemas
GOV.UKDavid Heath
![Page 3: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/3.jpg)
@bradwright - GOV.UKGOV.UK
What’s it for?
David Heath
![Page 4: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/4.jpg)
@bradwright - GOV.UKGOV.UK
What’s it for?- confidence
David Heath
![Page 5: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/5.jpg)
@bradwright - GOV.UKGOV.UK
What’s it for?- confidence- go faster
David Heath
![Page 6: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/6.jpg)
@bradwright - GOV.UKGOV.UK
Publishing pipeline overview
David Heath
![Page 7: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/7.jpg)
@bradwright - GOV.UKGOV.UKDavid Heath
Publishing app
Content store Frontend
JSON JSON
{ “base_path”: ..., …}
{ “base_path”: ..., …}
![Page 8: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/8.jpg)
@bradwright - GOV.UKGOV.UKDavid Heath
Publishing app
Content store Frontend
JSON JSON
{ “base_path”: ..., …}
{ “base_path”: ..., …}Transformation
![Page 9: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/9.jpg)
@bradwright - GOV.UKGOV.UKDavid Heath
Metadata
Details
Links
Content item{ base_path: format: public_updated_at: details: { ... }, links: { … }}
![Page 10: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/10.jpg)
@bradwright - GOV.UKGOV.UKDavid Heath
Publisher
"required": [ "publishing_app", "rendering_app", "update_type", "format", "locale", "public_updated_at" ],
Frontend
"required": [ "base_path", "format", "locale", "public_updated_at" ],
Metadata changes
![Page 11: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/11.jpg)
@bradwright - GOV.UKGOV.UKDavid Heath
Publisher Frontend
content_id currently optional (maybe required in future)
Absent
routes Routes (must be within base_path)
Absent
redirects Only for format==’redirect’ Absent
![Page 12: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/12.jpg)
@bradwright - GOV.UKGOV.UKDavid Heath
Links expansion (publisher)“links”: { “lead_organisations”: [ “ab517cc2-80df-48f2-8325-1b8af95b8f71” ]}
![Page 13: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/13.jpg)
Links expansion (frontend)“links”: { “lead_organisations”: [ { "title": "Department for International Development", "base_path": "/government/organisations/dfid", "api_url": "https://www.gov.uk/api/organisations/dfid", "web_url": "https://www.gov.uk/government/organisations/dfid", "locale": "en" } ]}
@bradwright - GOV.UKGOV.UKDavid Heath
![Page 14: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/14.jpg)
Details hash
stays the same :-)
@bradwright - GOV.UKGOV.UKDavid Heath
![Page 15: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/15.jpg)
Content item transformation{ base_path: format: public_updated_at: details: { ... }, links: { … }}
@bradwright - GOV.UKGOV.UKDavid Heath
Metadata (fields change)
Details (stays same)
Links (expanded)
![Page 16: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/16.jpg)
@bradwright - GOV.UKGOV.UK
How can we test this?
David Heath
![Page 17: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/17.jpg)
@bradwright - GOV.UKGOV.UKDavid Heath
Publishing app
Content store Frontend
![Page 18: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/18.jpg)
@bradwright - GOV.UKGOV.UKDavid Heath
Publishing app FrontendContent
store
![Page 19: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/19.jpg)
@bradwright - GOV.UKGOV.UKDavid Heath
Publishing app Frontend
Test that this produces the right output
Test that this works with a variety of valid inputs
![Page 20: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/20.jpg)
@bradwright - GOV.UKGOV.UKDavid Heath
Publishing app Frontend
Schema
![Page 21: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/21.jpg)
Examples
@bradwright - GOV.UKGOV.UKDavid Heath
Publishing app Frontend
Schema
![Page 22: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/22.jpg)
Examples
@bradwright - GOV.UKGOV.UKDavid Heath
Publishing app Frontend
Schema
Match?
![Page 23: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/23.jpg)
Examples
@bradwright - GOV.UKGOV.UKDavid Heath
Publishing app Frontend
Schema
Match?
GOV.UK Content Schemas
![Page 24: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/24.jpg)
@bradwright - GOV.UKGOV.UKDavid Heath
govuk-content-schemas
![Page 25: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/25.jpg)
@bradwright - GOV.UKGOV.UKDavid Heath
![Page 26: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/26.jpg)
@bradwright - GOV.UKGOV.UKDavid Heath
details.json
metadata.json
links.jsonpublisher/schema.json
frontend/ schema.json
curated examplescurated examples
combine_publisher_schema
generate_frontend_schema
validate;
ensure_example_base_paths_unique
validated examples
Build process (Makefile)
![Page 27: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/27.jpg)
Examples
@bradwright - GOV.UKGOV.UKDavid Heath
Publishing app Frontend
Schema
Match?
GOV.UK Content Schemas
![Page 28: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/28.jpg)
@bradwright - GOV.UKGOV.UKDavid Heath
Publisher testjenkins-schema.sh
# Clone govuk-content-schemas dependency for contract testsrm -rf tmp/govuk-content-schemasgit clone [email protected]:alphagov/govuk-content-schemas.git \ tmp/govuk-content-schemascd tmp/govuk-content-schemasgit checkout $SCHEMA_GIT_COMMITcd ../..
# Run teststime bundle install --path "${HOME}/bundles/${JOB_NAME}" --deploymentRAILS_ENV=test GOVUK_CONTENT_SCHEMAS_PATH=tmp/govuk-content-schemas time bundle exec rake test:publishing_schemas --trace
![Page 29: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/29.jpg)
@bradwright - GOV.UKGOV.UKDavid Heath
Publisher testtest_publishing_schemas.rake
namespace :test do Rake::TestTask.new(:publishing_schemas => "test:prepare") do |t| t.libs << 'test' t.test_files = FileList['test/unit/presenters/publishing_api_presenters/*_test.rb'] end Rake::Task['test:publishing_schemas'].comment = "Test publishing API presenters against external schemas"end
![Page 30: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/30.jpg)
@bradwright - GOV.UKGOV.UKDavid Heath
Publisher testtest/unit/presenters/publishing_api_presenters/case_study_test.rb
test "links hash includes world locations" do location = create(:world_location) case_study = create(:published_case_study, world_locations: [location]) presented_hash = present(case_study) assert_valid_against_schema(presented_hash, 'case_study') assert_equal [location.content_id], presented_hash[:links][:world_locations]end
![Page 31: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/31.jpg)
@bradwright - GOV.UKGOV.UKDavid Heath
Publisher test- use govuk-content-schema-test-helpers- define jenkins-schema.sh- contract tests should ideally be stand-
alone (separate test file)
![Page 32: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/32.jpg)
Examples
@bradwright - GOV.UKGOV.UKDavid Heath
Publishing app Frontend
Schema
Match?
GOV.UK Content Schemas
![Page 33: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/33.jpg)
Frontend testtest/contracts/govuk_content_schemas_test.sh
class GovukContentSchemasTest < ActionDispatch::IntegrationTest include GovukContentSchemaExamples
all_examples_for_supported_formats.each do |content_item| test "can successfully render #{content_item['base_path']} schema example" do content_store_has_item(content_item['base_path'], content_item)
get content_item['base_path'].sub(/^\//, '')
assert_response :success end endend
@bradwright - GOV.UKGOV.UKDavid Heath
![Page 34: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/34.jpg)
Adding a field to a format
1. Branch govuk-content-schemas2. Add optional field3. Push branch, all contract tests run4. Merge!
@bradwright - GOV.UKGOV.UKDavid Heath
![Page 35: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/35.jpg)
@bradwright - GOV.UKGOV.UKDavid Heath
![Page 36: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/36.jpg)
Adding a new format
1. Branch govuk-content-schemas2. Add schema and examples3. Make sure publisher and frontend
tests set up4. Push branch
@bradwright - GOV.UKGOV.UKDavid Heath
![Page 37: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/37.jpg)
Dummy content store
@bradwright - GOV.UKGOV.UKDavid Heath
![Page 38: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/38.jpg)
@bradwright - GOV.UKGOV.UK
Summing up
David Heath
![Page 39: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/39.jpg)
@bradwright - GOV.UK
Your safetynet
![Page 40: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/40.jpg)
@bradwright - GOV.UK
confidence
publisher
frontend
![Page 41: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/41.jpg)
Links● https://github.com/alphagov/govuk-content-schemas● https://github.com/alphagov/govuk-content-schema-test-helpers● https://github.com/alphagov/govuk-dummy_content_store
@bradwright - GOV.UKGOV.UKDavid Heath
![Page 42: Gov.uk content schemas tech monthly may 2015](https://reader036.fdocuments.us/reader036/viewer/2022062406/55ced161bb61eb2f2c8b47bc/html5/thumbnails/42.jpg)
GOV.UK Tech Monthly - Publishing 2.0 team29th May 2015
David HeathDeveloper@dgheath21