Skip to content

Commit

Permalink
fixup! EES-5396 Update public API docs to use generated OpenAPI docs …
Browse files Browse the repository at this point in the history
…when deploying
  • Loading branch information
ntsim committed Dec 19, 2024
1 parent 0100327 commit 7a3ad02
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 13 deletions.
40 changes: 29 additions & 11 deletions azure-pipelines-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ jobs:
projects: '**/GovUk.Education.ExploreEducationStatistics.Admin.csproj'
arguments: --self-contained true -r win-x64 --configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)

- task: PublishPipelineArtifact@0
- task: PublishPipelineArtifact@1
condition: and(succeeded(), eq(variables.IsBranchDeployable, true))
displayName: Publish Admin artifact
inputs:
Expand Down Expand Up @@ -423,6 +423,7 @@ jobs:
workspace:
clean: all
variables:
BUNDLE_PATH: $(Pipeline.Workspace)/.bundle
WorkingDirectory: src/explore-education-statistics-api-docs
steps:
- task: UseNode@1
Expand All @@ -435,23 +436,40 @@ jobs:
inputs:
versionSpec: '>= $(RubyVersion)'

- task: Cache@2
displayName: Cache Gems
inputs:
key: 'gems | "$(Agent.OS)" | $(WorkingDirectory)/Gemfile.lock'
path: $(BUNDLE_PATH)
restoreKeys: |
gems | "$(Agent.OS)"
gems
- task: Bash@3
displayName: Build
env:
TECH_DOCS_API_URL: https://dev.statistics.api.education.gov.uk
displayName: Install Gems
inputs:
workingDirectory: $(WorkingDirectory)
targetType: inline
script: |
bundle install
bundle exec middleman build
script: bundle install

- task: Bash@3
displayName: Build
inputs:
workingDirectory: $(WorkingDirectory)
targetType: inline
script: bundle exec middleman build

# Note that we're not publishing the built API docs as an artifact as
# we're to re-building the API docs for each environment during
# the deployment stages so we can inject different env variables.
#
# We're still building the API docs so that we can get earlier
# feedback on any build errors at PR stage.
- task: PublishPipelineArtifact@1
displayName: Publish artifact
displayName: Publish Public API docs gems artifact
inputs:
artifactName: public-api-docs
targetPath: $(WorkingDirectory)/build

artifactName: public-api-docs-gems
path: $(BUNDLE_PATH)

- job: MiscellaneousArtifacts
pool:
Expand Down
15 changes: 14 additions & 1 deletion infrastructure/templates/public-api/ci/jobs/deploy-api-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
environment: ${{ parameters.environment }}
variables:
docsPath: $(Pipeline.Workspace)/MainBuild/public-api-docs
docsGemsPath: $(Pipeline.Workspace)/MainBuild/public-api-docs-gems
nodeVersion: '20.16.0'
rubyVersion: '3.2'
strategy:
Expand All @@ -24,6 +25,10 @@ jobs:
displayName: Download Public API docs artifact
artifact: public-api-docs

- download: MainBuild
displayName: Download Public API docs gems artifact
artifact: public-api-docs-gems

- task: UseNode@1
displayName: Install Node.js $(nodeVersion)
inputs:
Expand All @@ -34,6 +39,13 @@ jobs:
inputs:
versionSpec: '>= $(rubyVersion)'

- task: Bash@3
displayName: Set Bundle path
inputs:
workingDirectory: $(docsPath)
targetType: inline
script: bundle config --local path $(docsGemsPath)

- task: Bash@3
displayName: Install Gems
inputs:
Expand All @@ -44,7 +56,8 @@ jobs:
- task: Bash@3
displayName: Build API docs
env:
TECH_DOCS_API_URL: $(publicApiUrl)
TECH_DOCS_API_URL: $(apiAppUrl)
TECH_DOCS_ALLOW_INDEXING: $(docsPreventIndexing)
inputs:
workingDirectory: $(docsPath)
targetType: inline
Expand Down
3 changes: 2 additions & 1 deletion src/explore-education-statistics-api-docs/config.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'dotenv'
require 'govuk_tech_docs'
require 'lib/utils/env'
require 'lib/api_reference_pages_extension'
require 'lib/helpers'
require 'lib/api_reference_helpers'
Expand All @@ -19,7 +20,7 @@
end

if ENV.has_key?("TECH_DOCS_PREVENT_INDEXING")
config[:tech_docs][:prevent_indexing] = ENV["TECH_DOCS_PREVENT_INDEXING"]
config[:tech_docs][:prevent_indexing] = EnvUtils.get_bool("TECH_DOCS_PREVENT_INDEXING")
end

if ENV.has_key?("TECH_DOCS_API_URL")
Expand Down
13 changes: 13 additions & 0 deletions src/explore-education-statistics-api-docs/lib/utils/env.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class EnvUtils

# @param [String] key
# @return [Boolean]
def self.get_bool(key)
case ENV[key]
when "false", "f", "no", "n", "0", ""
false
else
true
end
end
end

0 comments on commit 7a3ad02

Please sign in to comment.