-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PP-11224: Add Dockerfile, config, and unit test workflow #2
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a5a4512
PP-11224: Add Dockerfile, config, and unit test workflow
jfharden 2f3dd4c
PP-11224: Add post-merge workflow
jfharden 85b441e
PP-11224: Remove workflow_dispatch trigger
jfharden 83d0f3a
PP-11224: Remove incorrect comment
jfharden 094eabd
PP-11224: Added npm config to dependabot
jfharden 78342c2
PP-11224: Always docker-compose build in the tests
jfharden feea0e8
PP-11224: Remove unused import in test node_service
jfharden File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Post Merge | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths-ignore: | ||
- '.github/**' | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
tests: | ||
uses: ./.github/workflows/run-tests.yml | ||
|
||
tag-release: | ||
needs: | ||
- tests | ||
permissions: | ||
contents: write | ||
uses: alphagov/pay-ci/.github/workflows/_create-alpha-release-tag.yml@master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Build and test | ||
|
||
on: | ||
workflow_call: | ||
pull_request: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
detect-secrets: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Git checkout | ||
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab | ||
- name: Detect secrets | ||
uses: alphagov/pay-ci/actions/detect-secrets@master | ||
|
||
build-and-test: | ||
name: Container Build Tests | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab | ||
- name: Docker build | ||
run: | | ||
docker build -t pay-adot:github-tests . | ||
- name: Run tests | ||
working-directory: tests/ | ||
run: ./test.sh | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM amazon/aws-otel-collector:v0.30.0 | ||
|
||
COPY config.yml /etc/ecs/govuk-pay-adot-sidecar-config.yaml | ||
|
||
CMD ["--config=/etc/ecs/govuk-pay-adot-sidecar-config.yaml"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
receivers: | ||
prometheus: | ||
config: | ||
global: | ||
scrape_interval: 15s | ||
scrape_timeout: 10s | ||
scrape_configs: | ||
- job_name: "adot-sidecar-scrape-application" | ||
static_configs: | ||
- targets: [ "127.0.0.1:$APPLICATION_PORT" ] | ||
honor_labels: true | ||
honor_timestamps: true | ||
|
||
processors: | ||
|
||
exporters: | ||
prometheusremotewrite: | ||
endpoint: $PROMETHEUS_ENDPOINT_URL | ||
resource_to_telemetry_conversion: | ||
enabled: false | ||
auth: | ||
authenticator: sigv4auth | ||
logging: | ||
loglevel: info | ||
|
||
extensions: | ||
sigv4auth: | ||
region: $AWS_REGION | ||
service: aps | ||
assume_role: | ||
arn: $PROMETHEUS_WRITE_ASSUME_ROLE_ARN | ||
|
||
service: | ||
extensions: [sigv4auth] | ||
pipelines: | ||
metrics/application: | ||
receivers: [prometheus] | ||
exporters: [logging, prometheusremotewrite] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
version: "3" | ||
services: | ||
test-app: | ||
build: node_service/ | ||
expose: | ||
- 3000 | ||
ports: | ||
- 3000:3000 | ||
healthcheck: | ||
test: ["CMD", "wget", "-O", "/dev/null", "-q", "http://localhost:3000/metrics"] | ||
interval: 1s | ||
timeout: 10s | ||
retries: 30 | ||
|
||
adot-sidecar: | ||
build: ../. | ||
volumes: | ||
- "./test-config.yml:/etc/ecs/govuk-pay-adot-sidecar-config.yaml" | ||
depends_on: | ||
- prometheus | ||
- test-app | ||
environment: | ||
- APPLICATION_PORT=3000 | ||
- PROMETHEUS_REMOTE_WRITE_URL=http://prometheus:9090/api/v1/write | ||
|
||
prometheus: | ||
image: prom/prometheus:v2.45.0 | ||
expose: | ||
- 9090 | ||
ports: | ||
- 9090:9090 | ||
command: | ||
- --web.enable-remote-write-receiver | ||
- --config.file=/etc/prometheus/prometheus.yml | ||
healthcheck: | ||
test: ["CMD", "wget", "-O", "/dev/null", "-q", "http://localhost:9090/-/ready"] | ||
interval: 5s | ||
timeout: 10s | ||
retries: 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM node:20-alpine | ||
|
||
RUN apk add --no-cache tini | ||
|
||
WORKDIR /app | ||
|
||
COPY package*.json ./ | ||
RUN npm ci --no-progress --omit=dev | ||
|
||
COPY ./index.mjs index.mjs | ||
|
||
EXPOSE 3000 | ||
|
||
ENTRYPOINT ["/sbin/tini", "--"] | ||
|
||
CMD ["node", "index.mjs"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import promClient from 'prom-client' | ||
import express from 'express' | ||
|
||
promClient.collectDefaultMetrics({ timeout: 10000 }) | ||
promClient.register.metrics().then(str => console.log('Metrics registered')) | ||
|
||
function defaultLabels() { | ||
return { | ||
ecsClusterName: "local-test", | ||
ecsServiceName: "test-node-app", | ||
awsAccountName: "local", | ||
} | ||
} | ||
|
||
try { | ||
promClient.register.setDefaultLabels(defaultLabels()); | ||
} catch (ex) { | ||
const labels = {} | ||
console.log(`Failed to get labels ${ex}`) | ||
} | ||
|
||
const counters = { | ||
index: new promClient.Counter({ | ||
name: 'page_count_index', | ||
help: 'Count of hits to the index page', | ||
}), | ||
foo: new promClient.Counter({ | ||
name: 'page_count_foo', | ||
help: 'Count of hits to the foo page', | ||
}), | ||
metrics: new promClient.Counter({ | ||
name: 'page_count_metrics', | ||
help: 'Count of hits to the metrics page', | ||
}), | ||
|
||
} | ||
|
||
const app = express() | ||
const port = 3000 | ||
|
||
app.get('/', (req, res) => { | ||
counters.index.inc() | ||
console.log('GET /') | ||
res.send('Hello World!') | ||
}) | ||
|
||
app.get('/foo', (req, res) => { | ||
counters.foo.inc() | ||
console.log('GET /foo') | ||
res.send('Foo woo hoo') | ||
}) | ||
|
||
app.get('/metrics', async (req, res) => { | ||
counters.metrics.inc() | ||
console.log('GET /metrics') | ||
try { | ||
res.set('Content-Type', promClient.register.contentType) | ||
const metrics = await promClient.register.metrics() | ||
res.end(metrics) | ||
} catch (ex) { | ||
res.status(500).end(ex) | ||
} | ||
}) | ||
|
||
app.listen(port, () => { | ||
console.log(`Example app listening on port ${port}`) | ||
}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we tag the build with the SHA (like we do on the telegraf tests)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's needed, we're not actually putting this image anywhere so the tag is completely ephemeral anyway