Skip to content

Commit 8b701e7

Browse files
authored
Merge branch 'main' into appease_tflint
2 parents fd30469 + c6aafbf commit 8b701e7

7 files changed

Lines changed: 45 additions & 15 deletions

File tree

support/pipeline-visualiser/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ FROM ruby:${RUBY_VERSION}-alpine${ALPINE_VERSION}@${DOCKER_IMAGE_DIGEST}
77
# Install system-level dependnecies early on so they can be cached effectively for subsequent builds
88
# build-base: needed to install be able to install BigDecimal extension requried by 'activesupport-duration-human_string' gem
99
# libxml2-dev: needed to be able to install libxml-ruby gem required by 'activesupport-duration-human_string' gem
10-
RUN apk add build-base libxml2-dev
10+
# tzdata: needed for setting the correct timezone in the container
11+
RUN apk add build-base libxml2-dev tzdata
1112

1213
WORKDIR /app
1314
ADD Gemfile /app/Gemfile
@@ -18,6 +19,8 @@ RUN bundle config set --local system true && \
1819
bundle config set --local without development && \
1920
bundle install
2021

22+
RUN ln -s /usr/share/zoneinfo/Europe/London /etc/localtime
23+
2124
EXPOSE 4567
2225

2326
CMD ["ruby", "index.rb"]

support/pipeline-visualiser/Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ run:
88
AWS_SESSION_TOKEN="$$(echo "$${CREDS_JSON}" | jq -r '.Credentials.SessionToken')" \
99
ruby index.rb
1010

11+
run_in_docker:
12+
@docker build . -t forms-pipeline-visualiser:latest
13+
14+
CREDS_JSON="$$(aws sts assume-role --role-arn "arn:aws:iam::711966560482:role/deploy-pipeline-visualiser-ecs-task" --role-session-name "run-pipeline-visualiser")"; \
15+
AWS_ACCESS_KEY_ID="$$(echo "$${CREDS_JSON}" | jq -r '.Credentials.AccessKeyId')" \
16+
AWS_SECRET_ACCESS_KEY="$$(echo "$${CREDS_JSON}" | jq -r '.Credentials.SecretAccessKey')" \
17+
AWS_SESSION_TOKEN="$$(echo "$${CREDS_JSON}" | jq -r '.Credentials.SessionToken')" \
18+
\
19+
docker run \
20+
-p "4567:4567" \
21+
-e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_SESSION_TOKEN -e AWS_REGION \
22+
-v "$$(pwd):/app" \
23+
forms-pipeline-visualiser:latest
24+
1125
.PHONY: dev
1226
dev:
1327
PIPELINE_VISUALISER_DEV_MODE=true ruby index.rb

support/pipeline-visualiser/index.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
require_relative "lib/views/group"
1414

1515
set :public_folder, "public"
16+
set :bind, "0.0.0.0"
17+
1618
helpers do
1719
def slugify(str)
1820
str.downcase

support/pipeline-visualiser/views/group.erb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,10 @@
3030
</td>
3131
<td class="govuk-table__cell"><%= pipeline.current_stage_name if pipeline.is_running? %></td>
3232
<td class="govuk-table__cell">
33-
<time datetime="<%= pipeline.last_started_at %>" title="<%= pipeline.last_started_at %>">
34-
<% if pipeline.is_running? %>
35-
<%= pipeline.running_duration.human_str %> ago
36-
<% else %>
37-
<%= pipeline.last_started_at.strftime("%H:%M, %A %d %b %Y ") %>
38-
<% end %>
33+
<%= erb :'partials/time', :locals => {
34+
time: pipeline.last_started_at,
35+
text: pipeline.is_running? ? pipeline.running_duration.human_str + " ago" : nil
36+
} %>
3937
</time>
4038
</td>
4139
</tr>

support/pipeline-visualiser/views/layout.erb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@
1818
background-color: #F2F3F3;
1919
padding: 2px 5px;
2020
}
21-
22-
time {
23-
text-decoration: underline;
24-
text-decoration-style: dashed;
25-
text-underline-offset: 8px;
26-
}
2721
</style>
2822
</head>
2923

@@ -118,9 +112,19 @@
118112
<script type="module">
119113
import {
120114
initAll
121-
} from '/javascript/govuk-frontend-5.3.0.min.js'
115+
} from '/javascript/govuk-frontend-5.8.0.min.js'
122116
initAll()
123117
</script>
118+
119+
<script type="module">
120+
document.querySelectorAll("time:not([data-relative-time])").forEach((time) => {
121+
if(time.dateTime != null ) {
122+
let globalTime = new Date(time.dateTime);
123+
let localTime = globalTime.toLocaleString();
124+
time.innerText = localTime;
125+
}
126+
});
127+
</script>
124128
</body>
125129

126130
</html>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<% text = defined?(text) ? text : nil %>
2+
<% puts(text) %>
3+
<time datetime="<%= time.utc.strftime('%Y-%m-%dT%H:%M:%S.%L%z')%>" title="<%= time.utc.strftime('%Y-%m-%dT%H:%M:%S.%L%z')%>" <%= text.nil? ? '' : 'data-relative-time' %>>
4+
<% if text.nil? %>
5+
<%= time.strftime("%H:%M, %A %d %b %Y ") %>
6+
<% else %>
7+
<%= text %>
8+
<% end %>
9+
</time>

support/pipeline-visualiser/views/pipeline.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</h1>
1212

1313
<p class="govuk-body">
14-
<strong>Last execution time</strong> <%= pipeline.last_started_at.strftime("%H:%M, %A %d %b %Y ") %>
14+
<strong>Last execution time</strong> <%= erb :'partials/time', :locals => {time: pipeline.last_started_at } %>
1515
</p>
1616
<p class="govuk-body">
1717
<strong>Execution id</strong> <%= pipeline.execution_id %>

0 commit comments

Comments
 (0)