2023-03-21 16:12:13 +08:00
|
|
|
|
help:
|
|
|
|
|
|
@sed \
|
2023-09-07 05:38:19 -06:00
|
|
|
|
-e '/^[a-zA-Z0-9_\-\/\-]*:.*##/!d' \
|
2023-03-21 16:12:13 +08:00
|
|
|
|
-e 's/:.*##\s*/:/' \
|
|
|
|
|
|
-e 's/^\(.\+\):\(.*\)/$(shell tput setaf 6)\1$(shell tput sgr0):\2/' \
|
|
|
|
|
|
$(MAKEFILE_LIST) | column -c2 -t -s :
|
|
|
|
|
|
|
2022-11-07 16:34:43 +01:00
|
|
|
|
DOCKER_COMPOSE_FILE = docker-compose-developer.yml
|
|
|
|
|
|
DOCKER_COMPOSE_DEV_LABEL = com.grafana.oncall.env=dev
|
|
|
|
|
|
|
|
|
|
|
|
# compose profiles
|
|
|
|
|
|
MYSQL_PROFILE = mysql
|
|
|
|
|
|
POSTGRES_PROFILE = postgres
|
|
|
|
|
|
SQLITE_PROFILE = sqlite
|
|
|
|
|
|
ENGINE_PROFILE = engine
|
|
|
|
|
|
UI_PROFILE = oncall_ui
|
|
|
|
|
|
REDIS_PROFILE = redis
|
|
|
|
|
|
RABBITMQ_PROFILE = rabbitmq
|
2023-06-01 09:31:33 -03:00
|
|
|
|
PROMETHEUS_PROFILE = prometheus
|
2022-11-07 16:34:43 +01:00
|
|
|
|
GRAFANA_PROFILE = grafana
|
2023-08-24 13:12:24 +06:00
|
|
|
|
TELEGRAM_POLLING_PROFILE = telegram_polling
|
2022-11-07 16:34:43 +01:00
|
|
|
|
|
|
|
|
|
|
DEV_ENV_DIR = ./dev
|
|
|
|
|
|
DEV_ENV_FILE = $(DEV_ENV_DIR)/.env.dev
|
|
|
|
|
|
DEV_ENV_EXAMPLE_FILE = $(DEV_ENV_FILE).example
|
|
|
|
|
|
|
fix a few flaky e2e tests + allow running project locally via k8s/helm (#2751)
# What this PR does
- updates the GitHub Actions workflow to move the e2e tests into a
"[reusable
workflow](https://docs.github.com/en/actions/using-workflows/reusing-workflows#creating-a-reusable-workflow)"
which are run in two scenarios:
- all tests _except_ those annotated as `@expensive` are run against
`grafana/grafana:latest` on all feature branches
- all tests _including_ `@expensive` tests are run on weekdays @ 07h00
UTC, against a matrix of 6 grafana versions. Results of these builds
will be posted to `#irm-amixr-flux` Slack channel.
- local development will now be:
```bash
make build-dev-images init-k8s start-k8s
```
- `build-dev-images` - builds the engine and UI docker images (only need
to run first time)
- `init-k8s` - creates a `kind` cluster and loads the two Docker images
onto the cluster nodes (only need to run first time)
- `start-k8s` - switches `kubectl` context to the created `kind`
cluster, and uses `helm` to deploy everything as defined in
`./dev/helm-local.yml` and `./dev/helm-local.dev.yml` (that latter file
is `.gitignored` and specific to how _you_ want your setup to look like.
Hot reloading works as before. This is the _start_ of #2381. (I've
marked these `make` commands as beta, because they've not yet been
thoroughly tested for local development).
- modifies the `helm` chart to add the concept of `oncall.devMode`,
`ui`, and ability to run oncall w/ sqlite
- `oncall.devMode` will essentially just add `volumes` and
`volumeMounts` to the various engine/migrate containers +
- `ui.enabled` + `ui.env` - create a ui container (which is needed for
hot reloading locally)
- `sqlite` - this was useful for the e2e test environments where Github
runner resources are scarce. Running `mariadb` eats up precious
resources, instead lets just use sqlite here
- fixes an issue that caused sporadic HTTP 502s from the grafana
plugin-proxy, which led to flaky tests. See [this
comment](https://github.com/grafana/oncall/pull/2751/files#diff-09040e8df192699b9c5742110ebbe8d9d5c3938cb156cc1cb99fa1c3fdee4fefR72-R77)
for more context + a link to a relevant Slack conversation. **tldr;**
there is a bug with the Grafana plugin proxy in Grafana >= v10.0.3.
Let's stop using the `latest`/`main` docker tags in our test and pin to
`10.0.2` for now
- ~~re-enables the e2e test which validates a phone number via SMS, and
asserts that we can receive an alert escalation via SMS (new Mailslurp
API Key has been added as a repo secret)~~ update: this is still blocked
by procurement, will be done in a future PR
## Checklist
- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-08-22 19:03:29 +02:00
|
|
|
|
DEV_HELM_FILE = $(DEV_ENV_DIR)/helm-local.yml
|
|
|
|
|
|
DEV_HELM_USER_SPECIFIC_FILE = $(DEV_ENV_DIR)/helm-local.dev.yml
|
|
|
|
|
|
|
2022-11-07 16:34:43 +01:00
|
|
|
|
ENGINE_DIR = ./engine
|
2024-02-20 14:44:15 -03:00
|
|
|
|
VENV_DIR = ./venv
|
|
|
|
|
|
REQUIREMENTS_DEV_IN = $(ENGINE_DIR)/requirements-dev.in
|
|
|
|
|
|
REQUIREMENTS_DEV_TXT = $(ENGINE_DIR)/requirements-dev.txt
|
|
|
|
|
|
REQUIREMENTS_IN = $(ENGINE_DIR)/requirements.in
|
2022-11-10 16:04:30 +01:00
|
|
|
|
REQUIREMENTS_TXT = $(ENGINE_DIR)/requirements.txt
|
|
|
|
|
|
REQUIREMENTS_ENTERPRISE_TXT = $(ENGINE_DIR)/requirements-enterprise.txt
|
2022-11-07 16:34:43 +01:00
|
|
|
|
SQLITE_DB_FILE = $(ENGINE_DIR)/oncall.db
|
|
|
|
|
|
|
fix a few flaky e2e tests + allow running project locally via k8s/helm (#2751)
# What this PR does
- updates the GitHub Actions workflow to move the e2e tests into a
"[reusable
workflow](https://docs.github.com/en/actions/using-workflows/reusing-workflows#creating-a-reusable-workflow)"
which are run in two scenarios:
- all tests _except_ those annotated as `@expensive` are run against
`grafana/grafana:latest` on all feature branches
- all tests _including_ `@expensive` tests are run on weekdays @ 07h00
UTC, against a matrix of 6 grafana versions. Results of these builds
will be posted to `#irm-amixr-flux` Slack channel.
- local development will now be:
```bash
make build-dev-images init-k8s start-k8s
```
- `build-dev-images` - builds the engine and UI docker images (only need
to run first time)
- `init-k8s` - creates a `kind` cluster and loads the two Docker images
onto the cluster nodes (only need to run first time)
- `start-k8s` - switches `kubectl` context to the created `kind`
cluster, and uses `helm` to deploy everything as defined in
`./dev/helm-local.yml` and `./dev/helm-local.dev.yml` (that latter file
is `.gitignored` and specific to how _you_ want your setup to look like.
Hot reloading works as before. This is the _start_ of #2381. (I've
marked these `make` commands as beta, because they've not yet been
thoroughly tested for local development).
- modifies the `helm` chart to add the concept of `oncall.devMode`,
`ui`, and ability to run oncall w/ sqlite
- `oncall.devMode` will essentially just add `volumes` and
`volumeMounts` to the various engine/migrate containers +
- `ui.enabled` + `ui.env` - create a ui container (which is needed for
hot reloading locally)
- `sqlite` - this was useful for the e2e test environments where Github
runner resources are scarce. Running `mariadb` eats up precious
resources, instead lets just use sqlite here
- fixes an issue that caused sporadic HTTP 502s from the grafana
plugin-proxy, which led to flaky tests. See [this
comment](https://github.com/grafana/oncall/pull/2751/files#diff-09040e8df192699b9c5742110ebbe8d9d5c3938cb156cc1cb99fa1c3fdee4fefR72-R77)
for more context + a link to a relevant Slack conversation. **tldr;**
there is a bug with the Grafana plugin proxy in Grafana >= v10.0.3.
Let's stop using the `latest`/`main` docker tags in our test and pin to
`10.0.2` for now
- ~~re-enables the e2e test which validates a phone number via SMS, and
asserts that we can receive an alert escalation via SMS (new Mailslurp
API Key has been added as a repo secret)~~ update: this is still blocked
by procurement, will be done in a future PR
## Checklist
- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-08-22 19:03:29 +02:00
|
|
|
|
# make sure that DEV_HELM_USER_SPECIFIC_FILE and SQLITE_DB_FILE always exists
|
|
|
|
|
|
# (NOTE: touch will only create the file if it doesn't already exist)
|
|
|
|
|
|
$(shell touch $(DEV_HELM_USER_SPECIFIC_FILE))
|
|
|
|
|
|
$(shell touch $(SQLITE_DB_FILE))
|
|
|
|
|
|
|
2022-11-07 16:34:43 +01:00
|
|
|
|
# -n flag only copies DEV_ENV_EXAMPLE_FILE-> DEV_ENV_FILE if it doesn't already exist
|
|
|
|
|
|
$(shell cp -n $(DEV_ENV_EXAMPLE_FILE) $(DEV_ENV_FILE))
|
|
|
|
|
|
include $(DEV_ENV_FILE)
|
|
|
|
|
|
|
|
|
|
|
|
# if COMPOSE_PROFILES is set in DEV_ENV_FILE use it
|
|
|
|
|
|
# otherwise use a default (or what is passed in as an arg)
|
|
|
|
|
|
ifeq ($(COMPOSE_PROFILES),)
|
|
|
|
|
|
COMPOSE_PROFILES=$(ENGINE_PROFILE),$(UI_PROFILE),$(REDIS_PROFILE),$(GRAFANA_PROFILE)
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
# conditionally assign DB based on what is present in COMPOSE_PROFILES
|
|
|
|
|
|
ifeq ($(findstring $(MYSQL_PROFILE),$(COMPOSE_PROFILES)),$(MYSQL_PROFILE))
|
|
|
|
|
|
DB=$(MYSQL_PROFILE)
|
|
|
|
|
|
else ifeq ($(findstring $(POSTGRES_PROFILE),$(COMPOSE_PROFILES)),$(POSTGRES_PROFILE))
|
|
|
|
|
|
DB=$(POSTGRES_PROFILE)
|
|
|
|
|
|
else
|
|
|
|
|
|
DB=$(SQLITE_PROFILE)
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
# conditionally assign BROKER_TYPE based on what is present in COMPOSE_PROFILES
|
|
|
|
|
|
# if the user specifies both rabbitmq and redis, we'll make the assumption that rabbitmq is the broker
|
|
|
|
|
|
ifeq ($(findstring $(RABBITMQ_PROFILE),$(COMPOSE_PROFILES)),$(RABBITMQ_PROFILE))
|
|
|
|
|
|
BROKER_TYPE=$(RABBITMQ_PROFILE)
|
|
|
|
|
|
else
|
|
|
|
|
|
BROKER_TYPE=$(REDIS_PROFILE)
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
fix a few flaky e2e tests + allow running project locally via k8s/helm (#2751)
# What this PR does
- updates the GitHub Actions workflow to move the e2e tests into a
"[reusable
workflow](https://docs.github.com/en/actions/using-workflows/reusing-workflows#creating-a-reusable-workflow)"
which are run in two scenarios:
- all tests _except_ those annotated as `@expensive` are run against
`grafana/grafana:latest` on all feature branches
- all tests _including_ `@expensive` tests are run on weekdays @ 07h00
UTC, against a matrix of 6 grafana versions. Results of these builds
will be posted to `#irm-amixr-flux` Slack channel.
- local development will now be:
```bash
make build-dev-images init-k8s start-k8s
```
- `build-dev-images` - builds the engine and UI docker images (only need
to run first time)
- `init-k8s` - creates a `kind` cluster and loads the two Docker images
onto the cluster nodes (only need to run first time)
- `start-k8s` - switches `kubectl` context to the created `kind`
cluster, and uses `helm` to deploy everything as defined in
`./dev/helm-local.yml` and `./dev/helm-local.dev.yml` (that latter file
is `.gitignored` and specific to how _you_ want your setup to look like.
Hot reloading works as before. This is the _start_ of #2381. (I've
marked these `make` commands as beta, because they've not yet been
thoroughly tested for local development).
- modifies the `helm` chart to add the concept of `oncall.devMode`,
`ui`, and ability to run oncall w/ sqlite
- `oncall.devMode` will essentially just add `volumes` and
`volumeMounts` to the various engine/migrate containers +
- `ui.enabled` + `ui.env` - create a ui container (which is needed for
hot reloading locally)
- `sqlite` - this was useful for the e2e test environments where Github
runner resources are scarce. Running `mariadb` eats up precious
resources, instead lets just use sqlite here
- fixes an issue that caused sporadic HTTP 502s from the grafana
plugin-proxy, which led to flaky tests. See [this
comment](https://github.com/grafana/oncall/pull/2751/files#diff-09040e8df192699b9c5742110ebbe8d9d5c3938cb156cc1cb99fa1c3fdee4fefR72-R77)
for more context + a link to a relevant Slack conversation. **tldr;**
there is a bug with the Grafana plugin proxy in Grafana >= v10.0.3.
Let's stop using the `latest`/`main` docker tags in our test and pin to
`10.0.2` for now
- ~~re-enables the e2e test which validates a phone number via SMS, and
asserts that we can receive an alert escalation via SMS (new Mailslurp
API Key has been added as a repo secret)~~ update: this is still blocked
by procurement, will be done in a future PR
## Checklist
- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-08-22 19:03:29 +02:00
|
|
|
|
# TODO: remove this when docker-compose local setup is removed
|
|
|
|
|
|
# https://stackoverflow.com/a/649462
|
|
|
|
|
|
define _DEPRECATION_MESSAGE
|
|
|
|
|
|
⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️
|
2023-09-07 05:38:19 -06:00
|
|
|
|
NOTE: docker-compose based make commands will be deprecated on (or around) October 1, 2023, in favour of
|
|
|
|
|
|
tilt/k8s based commands. Please familirize yourself with the tilt/k8s commands.
|
fix a few flaky e2e tests + allow running project locally via k8s/helm (#2751)
# What this PR does
- updates the GitHub Actions workflow to move the e2e tests into a
"[reusable
workflow](https://docs.github.com/en/actions/using-workflows/reusing-workflows#creating-a-reusable-workflow)"
which are run in two scenarios:
- all tests _except_ those annotated as `@expensive` are run against
`grafana/grafana:latest` on all feature branches
- all tests _including_ `@expensive` tests are run on weekdays @ 07h00
UTC, against a matrix of 6 grafana versions. Results of these builds
will be posted to `#irm-amixr-flux` Slack channel.
- local development will now be:
```bash
make build-dev-images init-k8s start-k8s
```
- `build-dev-images` - builds the engine and UI docker images (only need
to run first time)
- `init-k8s` - creates a `kind` cluster and loads the two Docker images
onto the cluster nodes (only need to run first time)
- `start-k8s` - switches `kubectl` context to the created `kind`
cluster, and uses `helm` to deploy everything as defined in
`./dev/helm-local.yml` and `./dev/helm-local.dev.yml` (that latter file
is `.gitignored` and specific to how _you_ want your setup to look like.
Hot reloading works as before. This is the _start_ of #2381. (I've
marked these `make` commands as beta, because they've not yet been
thoroughly tested for local development).
- modifies the `helm` chart to add the concept of `oncall.devMode`,
`ui`, and ability to run oncall w/ sqlite
- `oncall.devMode` will essentially just add `volumes` and
`volumeMounts` to the various engine/migrate containers +
- `ui.enabled` + `ui.env` - create a ui container (which is needed for
hot reloading locally)
- `sqlite` - this was useful for the e2e test environments where Github
runner resources are scarce. Running `mariadb` eats up precious
resources, instead lets just use sqlite here
- fixes an issue that caused sporadic HTTP 502s from the grafana
plugin-proxy, which led to flaky tests. See [this
comment](https://github.com/grafana/oncall/pull/2751/files#diff-09040e8df192699b9c5742110ebbe8d9d5c3938cb156cc1cb99fa1c3fdee4fefR72-R77)
for more context + a link to a relevant Slack conversation. **tldr;**
there is a bug with the Grafana plugin proxy in Grafana >= v10.0.3.
Let's stop using the `latest`/`main` docker tags in our test and pin to
`10.0.2` for now
- ~~re-enables the e2e test which validates a phone number via SMS, and
asserts that we can receive an alert escalation via SMS (new Mailslurp
API Key has been added as a repo secret)~~ update: this is still blocked
by procurement, will be done in a future PR
## Checklist
- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-08-22 19:03:29 +02:00
|
|
|
|
|
2023-09-07 05:38:19 -06:00
|
|
|
|
See https://github.com/grafana/oncall/tree/dev/dev for instructions on how to use tilt helm/k8s commands.
|
fix a few flaky e2e tests + allow running project locally via k8s/helm (#2751)
# What this PR does
- updates the GitHub Actions workflow to move the e2e tests into a
"[reusable
workflow](https://docs.github.com/en/actions/using-workflows/reusing-workflows#creating-a-reusable-workflow)"
which are run in two scenarios:
- all tests _except_ those annotated as `@expensive` are run against
`grafana/grafana:latest` on all feature branches
- all tests _including_ `@expensive` tests are run on weekdays @ 07h00
UTC, against a matrix of 6 grafana versions. Results of these builds
will be posted to `#irm-amixr-flux` Slack channel.
- local development will now be:
```bash
make build-dev-images init-k8s start-k8s
```
- `build-dev-images` - builds the engine and UI docker images (only need
to run first time)
- `init-k8s` - creates a `kind` cluster and loads the two Docker images
onto the cluster nodes (only need to run first time)
- `start-k8s` - switches `kubectl` context to the created `kind`
cluster, and uses `helm` to deploy everything as defined in
`./dev/helm-local.yml` and `./dev/helm-local.dev.yml` (that latter file
is `.gitignored` and specific to how _you_ want your setup to look like.
Hot reloading works as before. This is the _start_ of #2381. (I've
marked these `make` commands as beta, because they've not yet been
thoroughly tested for local development).
- modifies the `helm` chart to add the concept of `oncall.devMode`,
`ui`, and ability to run oncall w/ sqlite
- `oncall.devMode` will essentially just add `volumes` and
`volumeMounts` to the various engine/migrate containers +
- `ui.enabled` + `ui.env` - create a ui container (which is needed for
hot reloading locally)
- `sqlite` - this was useful for the e2e test environments where Github
runner resources are scarce. Running `mariadb` eats up precious
resources, instead lets just use sqlite here
- fixes an issue that caused sporadic HTTP 502s from the grafana
plugin-proxy, which led to flaky tests. See [this
comment](https://github.com/grafana/oncall/pull/2751/files#diff-09040e8df192699b9c5742110ebbe8d9d5c3938cb156cc1cb99fa1c3fdee4fefR72-R77)
for more context + a link to a relevant Slack conversation. **tldr;**
there is a bug with the Grafana plugin proxy in Grafana >= v10.0.3.
Let's stop using the `latest`/`main` docker tags in our test and pin to
`10.0.2` for now
- ~~re-enables the e2e test which validates a phone number via SMS, and
asserts that we can receive an alert escalation via SMS (new Mailslurp
API Key has been added as a repo secret)~~ update: this is still blocked
by procurement, will be done in a future PR
## Checklist
- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-08-22 19:03:29 +02:00
|
|
|
|
⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
endef
|
|
|
|
|
|
export _DEPRECATION_MESSAGE
|
|
|
|
|
|
define echo_deprecation_message
|
|
|
|
|
|
@echo "$$_DEPRECATION_MESSAGE"
|
|
|
|
|
|
endef
|
|
|
|
|
|
|
2022-11-10 16:04:30 +01:00
|
|
|
|
# SQLITE_DB_FiLE is set to properly mount the sqlite db file
|
|
|
|
|
|
DOCKER_COMPOSE_ENV_VARS := COMPOSE_PROFILES=$(COMPOSE_PROFILES) DB=$(DB) BROKER_TYPE=$(BROKER_TYPE)
|
2023-08-30 13:27:08 +02:00
|
|
|
|
|
|
|
|
|
|
# It's better to output pip log on the fly while building because it takes a lot of time
|
|
|
|
|
|
DOCKER_COMPOSE_ENV_VARS += BUILDKIT_PROGRESS=plain
|
|
|
|
|
|
|
2022-11-10 16:04:30 +01:00
|
|
|
|
ifeq ($(DB),$(SQLITE_PROFILE))
|
|
|
|
|
|
DOCKER_COMPOSE_ENV_VARS += SQLITE_DB_FILE=$(SQLITE_DB_FILE)
|
|
|
|
|
|
endif
|
2022-10-07 16:50:00 -03:00
|
|
|
|
|
2022-11-07 16:34:43 +01:00
|
|
|
|
define run_docker_compose_command
|
fix a few flaky e2e tests + allow running project locally via k8s/helm (#2751)
# What this PR does
- updates the GitHub Actions workflow to move the e2e tests into a
"[reusable
workflow](https://docs.github.com/en/actions/using-workflows/reusing-workflows#creating-a-reusable-workflow)"
which are run in two scenarios:
- all tests _except_ those annotated as `@expensive` are run against
`grafana/grafana:latest` on all feature branches
- all tests _including_ `@expensive` tests are run on weekdays @ 07h00
UTC, against a matrix of 6 grafana versions. Results of these builds
will be posted to `#irm-amixr-flux` Slack channel.
- local development will now be:
```bash
make build-dev-images init-k8s start-k8s
```
- `build-dev-images` - builds the engine and UI docker images (only need
to run first time)
- `init-k8s` - creates a `kind` cluster and loads the two Docker images
onto the cluster nodes (only need to run first time)
- `start-k8s` - switches `kubectl` context to the created `kind`
cluster, and uses `helm` to deploy everything as defined in
`./dev/helm-local.yml` and `./dev/helm-local.dev.yml` (that latter file
is `.gitignored` and specific to how _you_ want your setup to look like.
Hot reloading works as before. This is the _start_ of #2381. (I've
marked these `make` commands as beta, because they've not yet been
thoroughly tested for local development).
- modifies the `helm` chart to add the concept of `oncall.devMode`,
`ui`, and ability to run oncall w/ sqlite
- `oncall.devMode` will essentially just add `volumes` and
`volumeMounts` to the various engine/migrate containers +
- `ui.enabled` + `ui.env` - create a ui container (which is needed for
hot reloading locally)
- `sqlite` - this was useful for the e2e test environments where Github
runner resources are scarce. Running `mariadb` eats up precious
resources, instead lets just use sqlite here
- fixes an issue that caused sporadic HTTP 502s from the grafana
plugin-proxy, which led to flaky tests. See [this
comment](https://github.com/grafana/oncall/pull/2751/files#diff-09040e8df192699b9c5742110ebbe8d9d5c3938cb156cc1cb99fa1c3fdee4fefR72-R77)
for more context + a link to a relevant Slack conversation. **tldr;**
there is a bug with the Grafana plugin proxy in Grafana >= v10.0.3.
Let's stop using the `latest`/`main` docker tags in our test and pin to
`10.0.2` for now
- ~~re-enables the e2e test which validates a phone number via SMS, and
asserts that we can receive an alert escalation via SMS (new Mailslurp
API Key has been added as a repo secret)~~ update: this is still blocked
by procurement, will be done in a future PR
## Checklist
- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-08-22 19:03:29 +02:00
|
|
|
|
$(call echo_deprecation_message)
|
2022-11-10 16:04:30 +01:00
|
|
|
|
$(DOCKER_COMPOSE_ENV_VARS) docker compose -f $(DOCKER_COMPOSE_FILE) $(1)
|
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
|
|
|
|
define run_engine_docker_command
|
|
|
|
|
|
$(call run_docker_compose_command,run --rm oncall_engine_commands $(1))
|
2022-11-07 16:34:43 +01:00
|
|
|
|
endef
|
2022-10-07 16:50:00 -03:00
|
|
|
|
|
2023-05-17 22:12:51 +02:00
|
|
|
|
define run_ui_docker_command
|
|
|
|
|
|
$(call run_docker_compose_command,run --rm oncall_ui sh -c '$(1)')
|
|
|
|
|
|
endef
|
|
|
|
|
|
|
2024-05-24 09:55:08 -04:00
|
|
|
|
# always use settings.ci_test django settings file when running the tests
|
2023-07-21 21:35:19 +02:00
|
|
|
|
# if we use settings.dev it's very possible that some fail just based on the settings alone
|
|
|
|
|
|
define run_backend_tests
|
2024-05-24 09:55:08 -04:00
|
|
|
|
$(call run_engine_docker_command,pytest --ds=settings.ci_test $(1))
|
2023-07-21 21:35:19 +02:00
|
|
|
|
endef
|
|
|
|
|
|
|
2023-09-07 05:38:19 -06:00
|
|
|
|
.PHONY: local/up
|
|
|
|
|
|
local/up: cluster/up ## (beta) deploy all containers locally via tilt (k8s cluster will be created if it doesn't exist)
|
|
|
|
|
|
tilt up
|
|
|
|
|
|
|
|
|
|
|
|
.PHONY: local/down
|
|
|
|
|
|
local/down: ## (beta) remove all containers deployed via tilt
|
|
|
|
|
|
tilt down
|
|
|
|
|
|
|
|
|
|
|
|
.PHONY: local/clean
|
|
|
|
|
|
local/clean: cluster/down ## (beta) clean up k8s local dev environment
|
|
|
|
|
|
|
|
|
|
|
|
.PHONY: cluster/up
|
|
|
|
|
|
cluster/up: ## (beta) create a local development k8s cluster
|
|
|
|
|
|
ctlptl apply -f dev/kind-config.yaml
|
|
|
|
|
|
|
|
|
|
|
|
.PHONY: cluster/down
|
|
|
|
|
|
cluster/down: ## (beta) delete local development k8s cluster
|
|
|
|
|
|
ctlptl delete -f dev/kind-config.yaml
|
fix a few flaky e2e tests + allow running project locally via k8s/helm (#2751)
# What this PR does
- updates the GitHub Actions workflow to move the e2e tests into a
"[reusable
workflow](https://docs.github.com/en/actions/using-workflows/reusing-workflows#creating-a-reusable-workflow)"
which are run in two scenarios:
- all tests _except_ those annotated as `@expensive` are run against
`grafana/grafana:latest` on all feature branches
- all tests _including_ `@expensive` tests are run on weekdays @ 07h00
UTC, against a matrix of 6 grafana versions. Results of these builds
will be posted to `#irm-amixr-flux` Slack channel.
- local development will now be:
```bash
make build-dev-images init-k8s start-k8s
```
- `build-dev-images` - builds the engine and UI docker images (only need
to run first time)
- `init-k8s` - creates a `kind` cluster and loads the two Docker images
onto the cluster nodes (only need to run first time)
- `start-k8s` - switches `kubectl` context to the created `kind`
cluster, and uses `helm` to deploy everything as defined in
`./dev/helm-local.yml` and `./dev/helm-local.dev.yml` (that latter file
is `.gitignored` and specific to how _you_ want your setup to look like.
Hot reloading works as before. This is the _start_ of #2381. (I've
marked these `make` commands as beta, because they've not yet been
thoroughly tested for local development).
- modifies the `helm` chart to add the concept of `oncall.devMode`,
`ui`, and ability to run oncall w/ sqlite
- `oncall.devMode` will essentially just add `volumes` and
`volumeMounts` to the various engine/migrate containers +
- `ui.enabled` + `ui.env` - create a ui container (which is needed for
hot reloading locally)
- `sqlite` - this was useful for the e2e test environments where Github
runner resources are scarce. Running `mariadb` eats up precious
resources, instead lets just use sqlite here
- fixes an issue that caused sporadic HTTP 502s from the grafana
plugin-proxy, which led to flaky tests. See [this
comment](https://github.com/grafana/oncall/pull/2751/files#diff-09040e8df192699b9c5742110ebbe8d9d5c3938cb156cc1cb99fa1c3fdee4fefR72-R77)
for more context + a link to a relevant Slack conversation. **tldr;**
there is a bug with the Grafana plugin proxy in Grafana >= v10.0.3.
Let's stop using the `latest`/`main` docker tags in our test and pin to
`10.0.2` for now
- ~~re-enables the e2e test which validates a phone number via SMS, and
asserts that we can receive an alert escalation via SMS (new Mailslurp
API Key has been added as a repo secret)~~ update: this is still blocked
by procurement, will be done in a future PR
## Checklist
- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-08-22 19:03:29 +02:00
|
|
|
|
|
|
|
|
|
|
start: ## start all of the docker containers
|
2022-11-09 07:21:33 +01:00
|
|
|
|
$(call run_docker_compose_command,up --remove-orphans -d)
|
|
|
|
|
|
|
2023-03-21 16:12:13 +08:00
|
|
|
|
init: ## build the frontend plugin code then run make start
|
2022-11-07 16:34:43 +01:00
|
|
|
|
# if the oncall UI is to be run in docker we should do an initial build of the frontend code
|
|
|
|
|
|
# this makes sure that it will be available when the grafana container starts up without the need to
|
|
|
|
|
|
# restart the grafana container initially
|
|
|
|
|
|
ifeq ($(findstring $(UI_PROFILE),$(COMPOSE_PROFILES)),$(UI_PROFILE))
|
2023-05-17 22:12:51 +02:00
|
|
|
|
$(call run_ui_docker_command,yarn install && yarn build:dev)
|
2022-11-07 16:34:43 +01:00
|
|
|
|
endif
|
2022-10-07 16:50:00 -03:00
|
|
|
|
|
2023-03-21 16:12:13 +08:00
|
|
|
|
stop: # stop all of the docker containers
|
2022-11-07 16:34:43 +01:00
|
|
|
|
$(call run_docker_compose_command,down)
|
2022-10-07 16:50:00 -03:00
|
|
|
|
|
2023-03-21 16:12:13 +08:00
|
|
|
|
restart: ## restart all docker containers
|
2022-11-07 16:34:43 +01:00
|
|
|
|
$(call run_docker_compose_command,restart)
|
2022-10-07 16:50:00 -03:00
|
|
|
|
|
2023-03-21 16:12:13 +08:00
|
|
|
|
build: ## rebuild images (e.g. when changing requirements.txt)
|
2022-12-20 12:41:34 +01:00
|
|
|
|
$(call run_docker_compose_command,build)
|
2022-11-09 15:43:12 +00:00
|
|
|
|
|
2023-03-21 16:12:13 +08:00
|
|
|
|
cleanup: stop ## this will remove all of the images, containers, volumes, and networks
|
|
|
|
|
|
## associated with your local OnCall developer setup
|
fix a few flaky e2e tests + allow running project locally via k8s/helm (#2751)
# What this PR does
- updates the GitHub Actions workflow to move the e2e tests into a
"[reusable
workflow](https://docs.github.com/en/actions/using-workflows/reusing-workflows#creating-a-reusable-workflow)"
which are run in two scenarios:
- all tests _except_ those annotated as `@expensive` are run against
`grafana/grafana:latest` on all feature branches
- all tests _including_ `@expensive` tests are run on weekdays @ 07h00
UTC, against a matrix of 6 grafana versions. Results of these builds
will be posted to `#irm-amixr-flux` Slack channel.
- local development will now be:
```bash
make build-dev-images init-k8s start-k8s
```
- `build-dev-images` - builds the engine and UI docker images (only need
to run first time)
- `init-k8s` - creates a `kind` cluster and loads the two Docker images
onto the cluster nodes (only need to run first time)
- `start-k8s` - switches `kubectl` context to the created `kind`
cluster, and uses `helm` to deploy everything as defined in
`./dev/helm-local.yml` and `./dev/helm-local.dev.yml` (that latter file
is `.gitignored` and specific to how _you_ want your setup to look like.
Hot reloading works as before. This is the _start_ of #2381. (I've
marked these `make` commands as beta, because they've not yet been
thoroughly tested for local development).
- modifies the `helm` chart to add the concept of `oncall.devMode`,
`ui`, and ability to run oncall w/ sqlite
- `oncall.devMode` will essentially just add `volumes` and
`volumeMounts` to the various engine/migrate containers +
- `ui.enabled` + `ui.env` - create a ui container (which is needed for
hot reloading locally)
- `sqlite` - this was useful for the e2e test environments where Github
runner resources are scarce. Running `mariadb` eats up precious
resources, instead lets just use sqlite here
- fixes an issue that caused sporadic HTTP 502s from the grafana
plugin-proxy, which led to flaky tests. See [this
comment](https://github.com/grafana/oncall/pull/2751/files#diff-09040e8df192699b9c5742110ebbe8d9d5c3938cb156cc1cb99fa1c3fdee4fefR72-R77)
for more context + a link to a relevant Slack conversation. **tldr;**
there is a bug with the Grafana plugin proxy in Grafana >= v10.0.3.
Let's stop using the `latest`/`main` docker tags in our test and pin to
`10.0.2` for now
- ~~re-enables the e2e test which validates a phone number via SMS, and
asserts that we can receive an alert escalation via SMS (new Mailslurp
API Key has been added as a repo secret)~~ update: this is still blocked
by procurement, will be done in a future PR
## Checklist
- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-08-22 19:03:29 +02:00
|
|
|
|
$(call echo_deprecation_message)
|
2022-11-07 16:34:43 +01:00
|
|
|
|
docker system prune --filter label="$(DOCKER_COMPOSE_DEV_LABEL)" --all --volumes
|
2022-10-07 16:50:00 -03:00
|
|
|
|
|
2022-11-07 16:34:43 +01:00
|
|
|
|
install-pre-commit:
|
2023-12-01 09:56:26 -05:00
|
|
|
|
@if [ ! -x "$$(command -v pre-commit)" ]; then \
|
|
|
|
|
|
echo "installing pre-commit"; \
|
|
|
|
|
|
pip install $$(grep "pre-commit" $(ENGINE_DIR)/requirements-dev.txt); \
|
|
|
|
|
|
else \
|
|
|
|
|
|
echo "pre-commit already installed"; \
|
|
|
|
|
|
fi
|
2022-10-07 16:50:00 -03:00
|
|
|
|
|
2023-03-21 16:12:13 +08:00
|
|
|
|
lint: install-pre-commit ## run both frontend and backend linters
|
|
|
|
|
|
## may need to run `yarn install` from within `grafana-plugin`
|
|
|
|
|
|
## to install several `pre-commit` dependencies
|
2022-11-07 16:34:43 +01:00
|
|
|
|
pre-commit run --all-files
|
2022-10-07 16:50:00 -03:00
|
|
|
|
|
2022-11-07 16:34:43 +01:00
|
|
|
|
install-precommit-hook: install-pre-commit
|
|
|
|
|
|
pre-commit install
|
2022-10-07 16:50:00 -03:00
|
|
|
|
|
2023-03-21 16:12:13 +08:00
|
|
|
|
test: ## run backend tests
|
2023-07-21 21:35:19 +02:00
|
|
|
|
$(call run_backend_tests)
|
|
|
|
|
|
|
|
|
|
|
|
test-dev: ## very similar to `test` command, but allows you to pass arbitray args to pytest
|
|
|
|
|
|
## for example, `make test-dev ARGS="--last-failed --pdb"
|
|
|
|
|
|
$(call run_backend_tests,$(ARGS))
|
2022-10-07 16:50:00 -03:00
|
|
|
|
|
2023-08-29 11:57:26 +02:00
|
|
|
|
test-helm: ## run helm unit tests
|
2023-08-31 09:24:14 +02:00
|
|
|
|
helm unittest ./helm/oncall $(ARGS)
|
2023-08-29 11:57:26 +02:00
|
|
|
|
|
2023-03-21 16:12:13 +08:00
|
|
|
|
start-celery-beat: ## start celery beat
|
2022-11-07 16:34:43 +01:00
|
|
|
|
$(call run_engine_docker_command,celery -A engine beat -l info)
|
2022-10-07 16:50:00 -03:00
|
|
|
|
|
2023-03-21 16:12:13 +08:00
|
|
|
|
purge-queues: ## purge celery queues
|
2022-11-07 16:34:43 +01:00
|
|
|
|
$(call run_engine_docker_command,celery -A engine purge -f)
|
2022-10-07 16:50:00 -03:00
|
|
|
|
|
2023-03-21 16:12:13 +08:00
|
|
|
|
shell: ## starts an OnCall engine Django shell
|
2022-11-07 16:34:43 +01:00
|
|
|
|
$(call run_engine_docker_command,python manage.py shell)
|
2022-10-07 16:50:00 -03:00
|
|
|
|
|
2023-03-21 16:12:13 +08:00
|
|
|
|
dbshell: ## opens a DB shell
|
2022-11-07 16:34:43 +01:00
|
|
|
|
$(call run_engine_docker_command,python manage.py dbshell)
|
|
|
|
|
|
|
2023-03-21 16:12:13 +08:00
|
|
|
|
engine-manage: ## run Django's `manage.py` script, inside of a docker container, passing `$CMD` as arguments.
|
|
|
|
|
|
## e.g. `make engine-manage CMD="makemigrations"`
|
|
|
|
|
|
## https://docs.djangoproject.com/en/4.1/ref/django-admin/#django-admin-makemigrations
|
2022-12-01 14:13:39 +01:00
|
|
|
|
$(call run_engine_docker_command,python manage.py $(CMD))
|
|
|
|
|
|
|
2023-12-15 09:58:25 +01:00
|
|
|
|
test-e2e: ## run the e2e tests in headless mode
|
|
|
|
|
|
yarn --cwd grafana-plugin test:e2e
|
|
|
|
|
|
|
|
|
|
|
|
test-e2e-watch: ## start e2e tests in watch mode
|
|
|
|
|
|
yarn --cwd grafana-plugin test:e2e:watch
|
|
|
|
|
|
|
|
|
|
|
|
test-e2e-show-report: ## open last e2e test report
|
|
|
|
|
|
yarn --cwd grafana-plugin playwright show-report
|
|
|
|
|
|
|
2023-05-17 22:12:51 +02:00
|
|
|
|
ui-test: ## run the UI tests
|
|
|
|
|
|
$(call run_ui_docker_command,yarn test)
|
|
|
|
|
|
|
|
|
|
|
|
ui-lint: ## run the UI linter
|
|
|
|
|
|
$(call run_ui_docker_command,yarn lint)
|
|
|
|
|
|
|
|
|
|
|
|
ui-build: ## build the UI
|
|
|
|
|
|
$(call run_ui_docker_command,yarn build)
|
|
|
|
|
|
|
|
|
|
|
|
ui-command: ## run any command, inside of a UI docker container, passing `$CMD` as arguments.
|
|
|
|
|
|
## e.g. `make ui-command CMD="yarn test"`
|
|
|
|
|
|
$(call run_ui_docker_command,$(CMD))
|
|
|
|
|
|
|
2023-03-21 16:12:13 +08:00
|
|
|
|
exec-engine: ## exec into engine container's bash
|
2022-11-09 15:43:12 +00:00
|
|
|
|
docker exec -it oncall_engine bash
|
|
|
|
|
|
|
2023-03-21 16:12:13 +08:00
|
|
|
|
_backend-debug-enable: ## enable Django's debug mode and Silk profiling (this is disabled by default for performance reasons)
|
2023-02-02 09:08:48 +00:00
|
|
|
|
$(shell ./dev/add_env_var.sh DEBUG True $(DEV_ENV_FILE))
|
|
|
|
|
|
$(shell ./dev/add_env_var.sh SILK_PROFILER_ENABLED True $(DEV_ENV_FILE))
|
|
|
|
|
|
|
2023-03-21 16:12:13 +08:00
|
|
|
|
_backend-debug-disable: ## disable Django's debug mode and Silk profiling
|
2023-02-02 09:08:48 +00:00
|
|
|
|
$(shell ./dev/add_env_var.sh DEBUG False $(DEV_ENV_FILE))
|
|
|
|
|
|
$(shell ./dev/add_env_var.sh SILK_PROFILER_ENABLED False $(DEV_ENV_FILE))
|
|
|
|
|
|
|
|
|
|
|
|
backend-debug-enable: _backend-debug-enable stop start
|
|
|
|
|
|
backend-debug-disable: _backend-debug-disable stop start
|
|
|
|
|
|
|
2024-06-10 15:33:37 -04:00
|
|
|
|
pip-compile-locked-dependencies: ## compile engine requirements.txt files
|
|
|
|
|
|
$(shell cd engine && uv pip compile requirements.in -o requirements.txt)
|
|
|
|
|
|
$(shell cd engine && uv pip compile requirements-dev.in -o requirements-dev.txt)
|
|
|
|
|
|
|
2022-11-07 16:34:43 +01:00
|
|
|
|
# The below commands are useful for running backend services outside of docker
|
|
|
|
|
|
define backend_command
|
|
|
|
|
|
export `grep -v '^#' $(DEV_ENV_FILE) | xargs -0` && \
|
|
|
|
|
|
export BROKER_TYPE=$(BROKER_TYPE) && \
|
2024-06-25 11:43:50 -03:00
|
|
|
|
. $(VENV_DIR)/bin/activate && \
|
2022-11-07 16:34:43 +01:00
|
|
|
|
cd engine && \
|
|
|
|
|
|
$(1)
|
|
|
|
|
|
endef
|
2022-10-07 16:50:00 -03:00
|
|
|
|
|
2022-11-07 16:34:43 +01:00
|
|
|
|
backend-bootstrap:
|
2024-06-10 15:33:37 -04:00
|
|
|
|
python3.12 -m venv $(VENV_DIR)
|
2024-04-26 11:30:38 -03:00
|
|
|
|
$(VENV_DIR)/bin/pip install -U pip wheel uv
|
2024-06-25 11:43:50 -03:00
|
|
|
|
$(VENV_DIR)/bin/uv pip sync --python=$(VENV_DIR)/bin/python $(REQUIREMENTS_TXT) $(REQUIREMENTS_DEV_TXT)
|
2022-11-10 16:04:30 +01:00
|
|
|
|
@if [ -f $(REQUIREMENTS_ENTERPRISE_TXT) ]; then \
|
2024-06-25 11:43:50 -03:00
|
|
|
|
$(VENV_DIR)/bin/uv pip install --python=$(VENV_DIR)/bin/python -r $(REQUIREMENTS_ENTERPRISE_TXT); \
|
2022-11-10 16:04:30 +01:00
|
|
|
|
fi
|
2022-10-07 16:50:00 -03:00
|
|
|
|
|
2022-11-07 16:34:43 +01:00
|
|
|
|
backend-migrate:
|
|
|
|
|
|
$(call backend_command,python manage.py migrate)
|
2022-10-07 16:50:00 -03:00
|
|
|
|
|
2024-02-20 14:44:15 -03:00
|
|
|
|
backend-compile-deps:
|
2024-04-26 11:30:38 -03:00
|
|
|
|
uv pip compile --strip-extras $(REQUIREMENTS_IN)
|
|
|
|
|
|
uv pip compile --strip-extras $(REQUIREMENTS_DEV_IN)
|
2024-02-20 14:44:15 -03:00
|
|
|
|
|
|
|
|
|
|
backend-upgrade-deps:
|
2024-04-26 11:30:38 -03:00
|
|
|
|
uv pip compile --strip-extras --upgrade $(REQUIREMENTS_IN)
|
2024-02-20 14:44:15 -03:00
|
|
|
|
|
2022-11-07 16:34:43 +01:00
|
|
|
|
run-backend-server:
|
2022-11-09 15:42:03 +01:00
|
|
|
|
$(call backend_command,python manage.py runserver 0.0.0.0:8080)
|
2022-10-07 16:50:00 -03:00
|
|
|
|
|
2022-11-07 16:34:43 +01:00
|
|
|
|
run-backend-celery:
|
|
|
|
|
|
$(call backend_command,python manage.py start_celery)
|
2022-10-07 16:50:00 -03:00
|
|
|
|
|
2022-11-07 16:34:43 +01:00
|
|
|
|
backend-command:
|
|
|
|
|
|
$(call backend_command,$(CMD))
|
2022-11-22 13:15:22 -08:00
|
|
|
|
|
2023-03-21 16:12:13 +08:00
|
|
|
|
backend-manage-command: ## run Django's `manage.py` script, passing `$CMD` as arguments.
|
|
|
|
|
|
## e.g. `make backend-manage-command CMD="makemigrations"`
|
|
|
|
|
|
## https://docs.djangoproject.com/en/4.1/ref/django-admin/#django-admin-makemigrations
|
|
|
|
|
|
## alternatively you can open docker container with engine and run commands from there
|
2022-11-23 19:31:26 +01:00
|
|
|
|
$(call backend_command,python manage.py $(CMD))
|