Skip to content
Snippets Groups Projects
Commit 3dd2c8bb authored by Malte Finsterwalder's avatar Malte Finsterwalder
Browse files

Merge branch 'main' into production

parents 403b96a0 efb5c6f8
No related branches found
No related tags found
No related merge requests found
......@@ -34,12 +34,13 @@ variables:
resource_group: $ENVIRONMENT_ID # never execute terraform in parallel on the same environment
interruptible: false
.e2e:
image: 'europe-north1-docker.pkg.dev/holi-shared/docker-hub-remote/archlinux:latest'
.smoketest:
image: 'europe-north1-docker.pkg.dev/holi-shared/docker/holi-docker/holi-k6-builder'
script:
- API_DOMAIN=`cat $API_DOMAIN_PATH`
- echo "e2e tests against $CI_ENVIRONMENT_SLUG environment go here and against $API_DOMAIN"
- API_DOMAIN=$(cat $API_DOMAIN_PATH)
- terraform/environments/scripts/wait-for-ssl.sh "https://${API_DOMAIN}"
- BASE_URL="https://${API_DOMAIN}/graphql" k6 run smoketest/main.js
# TODO should/could we roll back the service to the last working revision on test failure?
# end job templates
......@@ -48,13 +49,13 @@ variables:
## common steps
cache_lint_test:
image: 'europe-north1-docker.pkg.dev/holi-shared/docker-hub-remote/denoland/deno:alpine-1.45.2'
image: 'europe-north1-docker.pkg.dev/holi-shared/docker-hub-remote/denoland/deno:2.0.0'
stage: 'test'
script:
- deno cache --lock=deno.lock app/deps.ts app/dev_deps.ts
- deno cache --allow-import --lock=deno.lock app/deps.ts app/dev_deps.ts
- deno fmt --check
- deno lint
- deno test
- deno test --allow-import
# You can override the included template(s) by including variable overrides
# SAST customization: https://docs.gitlab.com/ee/user/application_security/sast/#customizing-the-sast-settings
......@@ -98,8 +99,8 @@ review_deploy:
- production
- /^noenv\/.*/
review_e2e:
extends: .e2e
review_smoketest:
extends: .smoketest
needs: ['review_deploy']
except:
- main
......@@ -134,7 +135,7 @@ review_destroy:
- terraform/environments/scripts/destroy-env.sh $CI_ENVIRONMENT_SLUG
# can't use rules here: https://gitlab.com/gitlab-org/gitlab/-/issues/34077
when: manual
allow_failure: false
allow_failure: true
except:
- main
- production
......@@ -156,19 +157,18 @@ staging_deploy:
only:
- main
staging_trigger_unified-api_redeployment:
staging_smoketest:
extends: .smoketest
needs: ['staging_deploy']
trigger:
project: 'app/holi-unified-api'
branch: 'main'
only:
- main
resource_group: unified-api-staging
staging_e2e:
extends: .e2e
# if staging_e2e would actually run tests (other than ensuring SSL works), we'd have to
# wait for the unified-api pipeline to finish.
needs: ['staging_deploy']
staging_trigger_unified-api_redeployment:
needs: ['staging_smoketest']
trigger:
project: 'app/holi-unified-api'
branch: 'main'
only:
- main
......@@ -187,10 +187,17 @@ production_deploy:
only:
- production
production_trigger_unified-api_redeployment:
production_smoketest:
extends: .smoketest
needs: ['production_deploy']
only:
- production
production_trigger_unified-api_redeployment:
needs: ['production_smoketest']
trigger:
project: 'app/holi-unified-api'
branch: 'production'
only:
- production
resource_group: unified-api-production
FROM europe-north1-docker.pkg.dev/holi-shared/docker-hub-remote/denoland/deno:alpine-1.45.2
FROM europe-north1-docker.pkg.dev/holi-shared/docker-hub-remote/denoland/deno:2.0.0
# The port that your application listens to.
EXPOSE 8003
......@@ -10,7 +10,7 @@ COPY deno.lock .
COPY deno.json .
COPY ./app ./app
RUN deno cache --lock=deno.lock app/deps.ts
RUN deno cache --lock=deno.lock app/main.ts
RUN deno cache --allow-import --lock=deno.lock app/deps.ts
RUN deno cache --allow-import --lock=deno.lock app/main.ts
CMD ["deno", "run", "--allow-net", "--allow-env", "--lock=deno.lock", "--cached-only", "app/main.ts"]
CMD ["deno", "run", "--allow-import", "--allow-net", "--allow-env", "--lock=deno.lock", "--cached-only", "app/main.ts"]
......@@ -4,14 +4,14 @@
"lint": "deno lint",
"fmt": "deno fmt",
"fmt:check": "deno fmt --check",
"test": "deno test",
"test": "deno test --allow-import ",
"updateDeps": "deno cache --allow-import --lock=deno.lock --lock-write app/deps.ts app/dev_deps.ts",
"install": "deno cache --allow-import --reload --lock=deno.lock app/deps.ts app/dev_deps.ts",
"cache": "deno cache --allow-import app/main.ts",
"dev": "deno run --allow-import --allow-net --allow-env --lock=deno.lock --cached-only --watch app/main.ts",
"start": "deno run --allow-import --allow-net --allow-env --lock=deno.lock --cached-only app/main.ts",
"docker": "docker build -t geo-service . && docker run -it --init -p 8003:8003 geo-service",
"coverage": "deno test --coverage=coverage && deno coverage coverage",
"coverage": "deno test --allow-import --coverage=coverage && deno coverage coverage",
"pre-commit": {
"cmd": "vr lint && vr fmt:check",
"gitHook": "pre-commit"
......@@ -22,6 +22,8 @@
"lineWidth": 120,
"singleQuote": true,
"semiColons": false,
"exclude": ["*.md"]
"exclude": [
"*.md"
]
}
}
import http from 'k6/http'
import { check } from 'k6'
// You don't need to change anything in this section, it's k6 glue code.
// See the default function at the end of the file for defining your smoketest.
// This configuration only executes 1 test, enough for a smoketest. The smoketest will fail on any check failing.
const allChecksNeedToPassTreshold = { checks: [{ threshold: 'rate==1', abortOnFail: true }] }
export const options = {
vus: 1,
iterations: 1,
thresholds: allChecksNeedToPassTreshold,
}
/**
* Performs a GraphQL query and checks the response using the provided function. Fails if any of the provided expectations are not met.
* @param {string} query The GraphQL query to perform
* @param {(response: http.Response) => Array<boolean>} checkFunction
* A function that takes the HTTP response as an argument and returns an array
* of boolean values, each indicating success or failure of a test.
*/
function forQuery(query, checkFunction) {
const response = http.post(`${__ENV.BASE_URL}`, JSON.stringify({ query }), {
headers: { 'Content-Type': 'application/json' },
})
checkFunction(response)
}
// Define your smoketest(s) here.
export default () => {
forQuery(
`{placeDetails(id:"51223999b85500244059f052ea9271c64a40f00101f9013ef5000000000000c00208"){name}}`,
(response) => {
check(response, {
'is status 200': (r) => r.status === 200,
})
check(JSON.parse(response.body), {
// there can be multiple tests here, e.g.
//"contains topics object": (r) => typeof r.data.topics != null,
'returns name for place': (r) => typeof r.data.placeDetails.name === 'string',
})
},
)
}
......@@ -82,6 +82,7 @@ resource "google_cloud_run_service" "geo_api" {
"run.googleapis.com/vpc-access-connector" = data.terraform_remote_state.holi_infra_state.outputs.vpc_access_connector_name
# possible values: all-traffic/private-ranges-only(default) https://cloud.google.com/sdk/gcloud/reference/run/services/update#--vpc-egress
"run.googleapis.com/vpc-access-egress" = "private-ranges-only"
"run.googleapis.com/startup-cpu-boost" = "true"
}
# labels set on the revision level
labels = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment