Commit graph

55 commits

Author SHA1 Message Date
Ethan
fb046b3abd
Snyk monitor workflow change (#1549)
# What this PR does
Replaces `snyk test` with `snyk monitor` so results get pushed to out
Snyk platform and the [Snyk
Dashboards](https://ops.grafana-ops.net/d/H0w7l5NVk/snyk-overview?orgId=1)
gets updated.

## Which issue(s) this PR fixes

## Checklist

- [ ] Tests updated
- [ ] Documentation added
- [ ] `CHANGELOG.md` updated
2023-03-28 08:26:29 +00:00
Joey Orlando
0eb4bd95e6
Revert "Revert "speed up ci builds from 15 to <7 minutes"" (#1643)
Reverts grafana/oncall#1639
2023-03-28 09:34:03 +02:00
Innokentii Konstantinov
cbb06492ae
Revert "speed up ci builds from 15 to <7 minutes" (#1639)
Reverted due to stuck ci
2023-03-28 13:01:49 +08:00
Joey Orlando
23cd736c30
speed up ci builds from 15 to <7 minutes (#1615)
This PR cuts GitHub Action build times from 14-15 minutes, down to just
under 7 minutes. It does this by:
- caching `grafana-plugins/node_modules` and `pip` dependencies based on
their respective dependency files (eg. `requirements.txt` &
`yarn.lock`). This step alone saves ~3 minutes.
- get rid of the "build-engine-docker-image" and
"backend-integration-tests" jobs in the old "Integration Tests"
workflow. This was split out this way so that we could build the backend
docker image once, upload the artifact, and then reuse it across the
backend and e2e tests. We no longer need these backend integration tests
because we are testing the same thing in the e2e tests. This saves ~45
seconds of having to upload the image artifact.
- few improvements within the integration tests themselves:
- move plugin configuration to the `globalSetup.ts`. This means that
every test does not need to check if the plugin has been configured
because it is done once before all the tests are run.
- cache the plugin frontend build. If your commit doesn't change
anything to `grafana-plugin/src` or `grafana-plugin/yarn.lock` it should
be safe to reuse a previously built/cached version of the plugin
frontend. This saves ~3 minutes
- cache playwright binaries/dependencies. Only re-install them if the
version of `@playwright/test` in `grafana-plugin/yarn.lock` changes.
This saves ~3 minutes.
  
**Other things to mention**
Once we refactor the `GSelect` component to not call the `onChange`
callback on every keyDown event (#1628), this should allow us to
parallelize the integration tests, and cut the time required to execute
the tests themselves in half
2023-03-27 18:07:19 +02:00
Joey Orlando
b65daa165d
update pr template (#1610) 2023-03-23 11:48:33 +01:00
Joey Orlando
10fa332dd1
fix failing markdownlint (#1609) 2023-03-23 11:17:18 +01:00
Matvey Kukuy
79deaec281
Update issue-template.md 2023-03-23 08:49:42 +02:00
Matias Bordese
cebfec5ef9
Add support for web overrides to Terraform schedules (#1222)
Related to #828 

- Enable web UI for API/Terraform schedules to add overrides
- Refactor backend to add a flag toggling between web-based and
iCal-based overrides (these options are mutually exclusive)

Also updated read-only tooltips (related to #1483)
2023-03-10 16:21:50 +00:00
Joey Orlando
6ad30bfd33
remove dependabot config 2023-03-06 17:40:23 +01:00
Joey Orlando
8f22b2fd74
first UI integration test - phone verification + receive SMS alert flow (#900)
**What this PR does**:
Adds our first UI integration test using
[Playwright](https://playwright.dev/) and runs the test on CI. Right now
the test:
- logs into Grafana
- configures the plugin (if it isn't already)
- creates an OnCall schedule, where the current user will be OnCall
- creates an escalation chain to notify based on the newly created
OnCall schedule
- creates a webhook integration, attached to the created escalation
chain
- sends a demo alert for the new integration
- goes to the alert groups page and validates that the escalation step
to alert the OnCall user actually happened

Currently the Playwright tests are run against the 3 default headless
browsers, chromium, Firefox, and webkit. The CI job that runs these
tests is run as a matrix against 3 tagged versions of `grafana`; `main`,
`latest`, and `9.2.6`.

Secondly, it adds most of the logic for a second test which:
- logs into Grafana
- configures the plugin (if it isn't already)
- goes to the user's settings, verifies their phone number (using a tool
called [MailSlurp](https://www.mailslurp.com/))
- configures the current user's default escalation policy to send alerts
via SMS
- creates an escalation policy and configures it to send alerts to our
current user
- creates an integration and assigns the created escalation policy
- triggers a test alert + verifies that we receive the SMS alert text
(again, using MailSlurp)

**Which issue(s) this PR fixes**:
Closes #873 

**Checklist**
- [x] Tests updated
- [ ] Documentation added (N/A)
- [ ] `CHANGELOG.md` updated (N/A)
2023-03-06 16:28:52 +00:00
Joey Orlando
ec9a4b2575
don't run changelog/public-docs CI checks on merge_group Github events (#1388)
They don't appear to work properly there:
![Screenshot 2023-02-22 at 16 00
39](https://user-images.githubusercontent.com/9406895/220663834-82b125fa-0a9e-4aff-9399-62563a312842.png)
![Screenshot 2023-02-22 at 16 00
53](https://user-images.githubusercontent.com/9406895/220663841-1af2d0a7-e910-4d84-94a8-0cdec4f0353d.png)
2023-02-22 16:18:25 +01:00
Joey Orlando
4c231e4a01
trigger github actions jobs on merge_group event (#1346)
Get the repo ready to support the [pull request merge
queue](https://github.blog/changelog/2021-10-27-pull-request-merge-queue-limited-beta/):
<img width="777" alt="Screenshot 2023-02-20 at 14 48 44"
src="https://user-images.githubusercontent.com/9406895/220125516-4b2f7245-fb6d-4517-933e-d9cf86308661.png">
2023-02-22 15:05:48 +01:00
Joey Orlando
b5f88cfc8f
bump dependabot schedule interval to monthly (#1372) 2023-02-21 10:37:26 +01:00
Joey Orlando
11531119d2
code-ify dependabot configuration (#1347)
# What this PR does

This PR is meant to code-ify our dependabot configuration. This is being
done mainly to override the default labels that dependabot adds to the
PRs it opens.

## Checklist

- [ ] Tests updated (N/A)
- [ ] Documentation added (N/A)
- [ ] `CHANGELOG.md` updated (N/A)
2023-02-21 10:21:05 +01:00
Jack Baldry
951416e3ad
Update publishing workflows to use organization secret (#1301)
The new tokens are managed centrally and have a longer expiry.
Administrators of the grafanabot account will be
notified of the pending expiry and the secret can be rotated centrally
without the need for a repository administrator to update their secrets.

The existing repository secrets can safely be removed. The tokens for
those secrets will be removed by the end of this week.

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
2023-02-21 10:19:19 +01:00
Michael Derynck
ca987efd55
Handle OnCall gateway connector delete 204 (#1313)
Deleting an oncall connector from the gateway returns a 204 so it should
not try to parse the response for json.
2023-02-17 11:04:02 -07:00
Matvey Kukuy
1eb6db023e
Update issue-template.md 2023-02-17 17:09:46 +01:00
Matvey Kukuy
d5b125f73e
Update issue templates 2023-02-17 17:07:20 +01:00
Matvey Kukuy
3b1f864366
Changing names for GitHub Labels (#1318)
# What this PR does

no changelog -> pr:no changelog
no public docs -> pr:no public docs

## Which issue(s) this PR fixes

## Checklist

- [ ] Tests updated
- [ ] Documentation added
- [ ] `CHANGELOG.md` updated
2023-02-10 13:29:20 +02:00
Ildar Iskhakov
1b7ada4315
Add database migrations linter (#1020)
# What this PR does

This PR adds
[django-migration-linter](https://github.com/3YOURMIND/django-migration-linter)
to keep database migrations
 backwards compatible

- we can automatically run migrations and they are zero-downtime, e.g.
old code can work with the migrated database
 - we can run and rollback migrations without worrying about data safety
- OnCall is deployed to the multiple environments core team is not able
to control

See [django-migration-linter
checklist](https://github.com/3YOURMIND/django-migration-linter/blob/main/docs/incompatibilities.md)
for the common mistakes and best practices


## Which issue(s) this PR fixes

## Checklist

- [ ] Tests updated
- [ ] Documentation added
- [ ] `CHANGELOG.md` updated

---------

Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
2023-02-06 16:01:37 +08:00
Jack Baldry
0fc43c5e26
Use organization ISSUE_COMMANDS_TOKEN with reduced scope (#1248)
The new token is set at an organization level so it does not require
repository administrators to rotate the token. It also has the minimal
classic PAT permissions to facilitate the workflow.

It has expiry but that expiry is reported via email to the engineering
organization and the IT Helpdesk have permissions to regenerate the
token when expiration is imminent.

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
2023-02-02 07:42:53 +01:00
Joey Orlando
3ce2173eff
tag @grafana/docs-oncall instead of oncall-backend for docs related changes (#1251)
Adding in reference to #1239.

@grafana/docs-oncall should be tagged as a PR reviewer for changes to
`/docs` rahter than @grafana/grafana-oncall-backend.
2023-01-31 09:34:29 +01:00
Joey Orlando
8609f415b3
don't tag oncall-backend when CHANGELOG is updated (#1250)
# What this PR does

There is no need to add `@grafana/grafana-oncall-backend` as a PR
reviewer when `CHANGELOG.md` is updated

## Which issue(s) this PR fixes

## Checklist

- [ ] Tests updated (N/A)
- [ ] Documentation added (N/A)
- [ ] `CHANGELOG.md` updated (N/A)
2023-01-30 12:36:21 +01:00
Jack Baldry
1c0144c0b7
Fix typo in snyk workflow file name (#1225)
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
2023-01-26 11:44:06 +01:00
Joey Orlando
d3a098d7bd
add small script + github action to check that public docs updated (#1177)
This PR adds a new GitHub Action which will run on PRs against `dev` and
`main`. The GitHub action will not run if the label of "no public docs"
has been applied to the PR in question:

Otherwise, it will check to see if any changes were made to either the
`engine` or `grafana-plugin` directories. If so, it will then check
whether changes were also made to the `docs` directory. If not, it will
fail the job and block the build.
2023-01-20 13:23:06 +01:00
Joey Orlando
f587134f66
add github action to verify that changelog has been updated (#1163)
# What this PR does

Add a GitHub Action to check that the `CHANGELOG.md` has been updated.
If no `CHANGELOG.md` change is required, simply add the "no changelog"
label to your PR, which will effectively skip this check.
2023-01-20 12:16:15 +01:00
Ildar Iskhakov
181c3487a7
Update helm_release_pr.yml 2023-01-20 16:41:51 +08:00
Ildar Iskhakov
ab3c163196
Update helm_release_pr.yml 2023-01-20 16:39:04 +08:00
Ildar Iskhakov
2bc88663c9
Update helm chart from ci (#1167)
# What this PR does

Add github action workflow to automatically bump oncall helm chart version on each release and create a PR with this change

## Which issue(s) this PR fixes

## Checklist

- [ ] Tests updated
- [ ] Documentation added
- [ ] `CHANGELOG.md` updated
2023-01-20 16:23:04 +08:00
Ed Welch
6231eff0c0
Remove helm chart signing (#1126)
# What this PR does

Please See https://github.com/grafana/helm-charts/pull/2107

## Which issue(s) this PR fixes

## Checklist

- [ ] Tests updated
- [ ] Documentation added
- [ ] `CHANGELOG.md` updated
2023-01-12 19:02:44 +08:00
Michael Derynck
78bbfe0c4c
Update tokens used by GH Actions (#1102)
Separate tokens for GH actions with minimal scope
2023-01-09 10:14:07 -07:00
Jack Baldry
b3d81646e6
Update publishing workflows to use PATs with fine-grained access control (#1100)
Secrets have already been created by @mderynck 

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
2023-01-09 09:58:08 +00:00
Vadim Stepanov
1b67a8ec68
Add PD migrator lint & test steps to CI (#1053)
# What this PR does

- Add PD migrator related hooks to `.pre-commit-config.yaml`
- Add Github Actions step for running PD migrator tests
2022-12-30 16:03:39 +00:00
Joey Orlando
7ebc9cbbf7
modify push notification settings + use fcm-django library (#998)
- swaps out `django-push-notifications` for
[`fcm-django`](https://github.com/grafana/fcm-django). Again.. this is a
fork of the parent repo for exactly the same reason.. the migrations
point to `auth_user` without letting us use our own user model, this has
been patched in the `grafana` fork. The reason why we are using
`fcm-django` vs `django-push-notifications` is that the latter does not
support the new FCM API, only the "legacy" API. The legacy FCM API does
not support certain push notification settings that we would like to
use.
- modifies the iOS/Android specific push notification settings
- adds a `flower` pod in the `docker-compose-developer.yml`, useful for
debugging tasks locally
- sets the mobile app verification token TTL to 5 minutes when
developing locally. The default of 1 minute makes working with device
emulators really tricky..

This PR also swaps out the base image in `engine/Dockerfile` from
`python:3.9-alpine3.16` to `python:3.9-slim-buster`.

As to why.. in short, with the introduction of the `fcm-django` library
there is now a peer-dependency on
[`grpcio`](https://github.com/grpc/grpc) (which is used by
`firebase_admin`.. which I am using in this PR to interact directly with
Firebase Cloud Messaging (FCM)). `grpcio` does not publish wheels (read:
compiled binaries) for the Alpine distro. It does publish wheels for
Debian and hence `pip install -r requirements.txt` does not need to
build this library from the source distribution.

This is a [known
"issue"](https://github.com/grpc/grpc/issues/22815#issuecomment-1107874367)
and the recommended solution in the community is to.. not use alpine.

These were the numbers, when building the image locally, in terms of
image size and build time:

| | Local image size (uncompressed | Build time (may differ based on
your network speed) |
| ------------------------- | -------------------------------------- |
---------- |
| `python:3.9-alpine3.16`   | 785MB  | 320s |
| `python:3.9-slim-buster` | 1.05GB  | 90s   |

Co-authored-by: Salvatore Giordano <salvatoregiordanoo@gmail.com>
2022-12-20 12:41:34 +01:00
Joey Orlando
c08eeb72a3
add precommit rules for markdown/json files (#915)
* add markdownlint precommit steps + fix existing errors

* prettier json linting
2022-12-01 14:26:54 +01:00
Joey Orlando
244a88d5cc
add CODEOWNERS file 2022-11-29 18:28:33 +01:00
Joey Orlando
9e598385f4
Add RBAC Support (#777)
* Modify plugin.json to support RBAC role registration

* defines 26 new custom roles in plugin.json. The main roles are:

- Admin: read/write access to everything in OnCall
- Reader: read access to everything in OnCall
- OnCaller : read access to everything in OnCall + edit access to Alert Groups and Schedules
- <object-type> Editor: read/write access to everything related to <object-type>
- <object-type> Reader: read access for <object-type>
- User Settings Admin: read/write access to all user's settings, not just own settings. This is in comparison to User Settings Editor which can only read/write own settings

* update changelog and documentation (#686)

* implement RBAC for OnCall backend

This commit refactors backend authorization. It trys to use RBAC authorization if the org's grafana instance supports it, otherwise it falls back to basic role authorization.

* update RBAC backend tests

* add tests for RBAC changes
- run backend tests as matrix where RBAC is enabled/disabled. When RBAC is enabled, the permissions granted are read from the role grants in the frontend's plugin.json file (instead of relying what we specify in RBACPermission.Permissions)
- remove --reuse-db --nomigrations flags from engine/tox.ini
- minor autoformatting changes to docker-compose-developer.yml

* remove --ds=settings.ci-test from pytest CI command

DJANGO_SETTINGS_MODULE is already specified as an env var so this is just unecessary duplication

* update gitignore

* update github action job name for "test"

* RBAC frontend changes

* refactors the use of basic roles (ex. Viewer, Editor, Admin) use RBAC permissions (when supported), or falling back to basic roles when RBAC is not supported.

- updates the UserAction enum in grafana-plugin/src/state/userAction.ts. Previously this was hardcoded to a list of strings that were being returned by the OnCall API. Now the values here correspond to the permissions in plugin.json (plus a fallback role)

* changes per Gabriel's comments:
- get rid of group attribute in rbac roles
- remove displayName role attribute
- remove hidden role attribute
- add back role to includes section

* don't try to update user timezone if they don't have permission
2022-11-29 09:41:56 +01:00
Ildar Iskhakov
d26f76fea0
Add new ci pipeline: helm chart end to end testing (#855) 2022-11-21 16:10:25 +01:00
Joey Orlando
5d3e98867f specify "prod" as the docker build target
locally, docker build works as expected. When not specifying a build target, it builds the last target specified in the Dockerfile (in this case "prod"). On GitHub actions this works properly as well.
However, there seems to be something about the version of docker used on Drone that causes it to build all of the stages (and hence failing on enterprise-dev).

Let's instead just be explicit about which build target to use for both drone and GitHub actions.
2022-11-09 11:30:05 +01:00
Rares Mardare
c23172dbde remove build from test, add cd path 2022-10-20 17:42:09 +03:00
Rares Mardare
6c80e0baab ci frontend unit tests 2022-10-20 17:34:45 +03:00
Michael Derynck
5d20c60895
Add step to check docker build (#673)
* Add step to check docker build
2022-10-19 17:08:37 +02:00
Michael Derynck
03ac10d064 Add simple pull request template 2022-10-12 09:36:58 -06:00
Vadim Stepanov
b84b174e20
Allow multiple database and celery broker types (#582)
* add libs for celery + redis

* move redis & cache config to settings/base.py

* move rmq & celery config to settings/base.py

* BROKER -> BROKER_TYPE

* allow multiple database types

* flake8

* add sqlite db creation to dockerfile

* fix ci

* fix ci

* debug

* remove some defaults

* remove prints

* use local memory as cache on ci

* debug

* add DATABASE_DEFAULTS

* add ci test for sqlite + redis

* add ci test for sqlite + redis

* add ci test for sqlite + redis

* debug

* add redis healthcheck

* fix sqlite

* fix dev settings

* refactor dev settings

* tweak ci settings

* clear cache properly between tests

* move db and broker types to constants

* add librabbitmq deps

* use amqp instead of librabbitmq
2022-10-04 09:25:53 +01:00
Vadim Stepanov
8f43cf238a
Bump node version to 14.17.0 on CI pipelines (#481) 2022-09-05 12:29:55 +01:00
Matias Bordese
3b3802870a Add postgresql support for development/testing 2022-08-08 15:33:40 -03:00
Matvey Kukuy
0b1b7df946
Merge pull request #124 from grafana/jdb/2022-06-warn-on-no-commit
Allow workflow to silently succeed if nothing is to be committed
2022-06-21 16:53:55 +03:00
Jack Baldry
8783a3aa6e
Allow workflow to silently succeed if nothing is to be committed
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
2022-06-21 13:46:56 +01:00
Ildar Iskhakov
d872a0e939 Add helm tests 2022-06-21 15:01:46 +03:00
Ildar Iskhakov
1fc68ec871 Release helm chart from grafana/oncall to grafana/helm-charts using common workflow 2022-06-21 13:13:42 +03:00