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.
157 lines
4.3 KiB
YAML
157 lines
4.3 KiB
YAML
name: ci
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- dev
|
|
pull_request:
|
|
|
|
jobs:
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
container: python:3.9
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 14.17.0
|
|
- name: Build
|
|
run: |
|
|
pip install $(grep "pre-commit" engine/requirements.txt)
|
|
npm install -g yarn
|
|
cd grafana-plugin/
|
|
yarn --network-timeout 500000
|
|
yarn build
|
|
- name: Lint All
|
|
run: |
|
|
pre-commit run --all-files
|
|
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
container: python:3.9
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 14.17.0
|
|
- name: Unit Testing Frontend
|
|
run: |
|
|
pip install $(grep "pre-commit" engine/requirements.txt)
|
|
npm install -g yarn
|
|
cd grafana-plugin/
|
|
yarn --network-timeout 500000
|
|
yarn test
|
|
|
|
test-technical-documentation:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: "Check out code"
|
|
uses: "actions/checkout@v3"
|
|
- name: "Build website"
|
|
# -e HUGO_REFLINKSERRORLEVEL=ERROR prevents merging broken refs with the downside
|
|
# that no refs to external content can be used as these refs will not resolve in the
|
|
# docs-base image.
|
|
run: |
|
|
docker run -v ${PWD}/docs/sources:/hugo/content/docs/oncall/latest -e HUGO_REFLINKSERRORLEVEL=ERROR --rm grafana/docs-base:latest /bin/bash -c 'make hugo'
|
|
|
|
unit-test-backend-mysql-rabbitmq:
|
|
runs-on: ubuntu-latest
|
|
container: python:3.9
|
|
env:
|
|
DJANGO_SETTINGS_MODULE: settings.ci-test
|
|
SLACK_CLIENT_OAUTH_ID: 1
|
|
services:
|
|
rabbit_test:
|
|
image: rabbitmq:3.7.19
|
|
env:
|
|
RABBITMQ_DEFAULT_USER: rabbitmq
|
|
RABBITMQ_DEFAULT_PASS: rabbitmq
|
|
mysql_test:
|
|
image: mysql:5.7.25
|
|
env:
|
|
MYSQL_DATABASE: oncall_local_dev
|
|
MYSQL_ROOT_PASSWORD: local_dev_pwd
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Unit Test Backend
|
|
run: |
|
|
apt-get update && apt-get install -y netcat
|
|
cd engine/
|
|
pip install -r requirements.txt
|
|
./wait_for_test_mysql_start.sh && pytest --ds=settings.ci-test -x
|
|
|
|
unit-test-backend-postgresql-rabbitmq:
|
|
runs-on: ubuntu-latest
|
|
container: python:3.9
|
|
env:
|
|
DATABASE_TYPE: postgresql
|
|
DJANGO_SETTINGS_MODULE: settings.ci-test
|
|
SLACK_CLIENT_OAUTH_ID: 1
|
|
services:
|
|
rabbit_test:
|
|
image: rabbitmq:3.7.19
|
|
env:
|
|
RABBITMQ_DEFAULT_USER: rabbitmq
|
|
RABBITMQ_DEFAULT_PASS: rabbitmq
|
|
postgresql_test:
|
|
image: postgres:14.4
|
|
env:
|
|
POSTGRES_DB: oncall_local_dev
|
|
POSTGRES_PASSWORD: local_dev_pwd
|
|
# Set health checks to wait until postgres has started
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Unit Test Backend
|
|
run: |
|
|
cd engine/
|
|
pip install -r requirements.txt
|
|
pytest --ds=settings.ci-test -x
|
|
|
|
unit-test-backend-sqlite-redis:
|
|
runs-on: ubuntu-latest
|
|
container: python:3.9
|
|
env:
|
|
DATABASE_TYPE: sqlite3
|
|
BROKER_TYPE: redis
|
|
REDIS_URI: redis://redis_test:6379
|
|
DJANGO_SETTINGS_MODULE: settings.ci-test
|
|
SLACK_CLIENT_OAUTH_ID: 1
|
|
services:
|
|
redis_test:
|
|
image: redis:7.0.5
|
|
options: >-
|
|
--health-cmd "redis-cli ping"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Unit Test Backend
|
|
run: |
|
|
apt-get update && apt-get install -y netcat
|
|
cd engine/
|
|
pip install -r requirements.txt
|
|
pytest --ds=settings.ci-test -x
|
|
|
|
docker-build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Test docker build (no push)
|
|
id: docker_build
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
context: ./engine
|
|
file: ./engine/Dockerfile
|
|
push: false
|
|
target: prod
|
|
- name: Image digest
|
|
run: echo ${{ steps.docker_build.outputs.digest }}
|