Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Leave a comment and add `migrations` on issues that have migrations reminding the author to rebase before merging (#822)

sarayourfriend399e5bbca781
diff --git a/.github/auto-label.json b/.github/auto-label.json
new file mode 100644
index 000000000..e85b03992
--- /dev/null
+++ b/.github/auto-label.json
@@ -0,0 +1,7 @@
+{
+ "rules": {
+ "migrations": [
+ "**/migrations/**/*"
+ ]
+ }
+}
diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml
index f45a34e79..ab3722b1d 100644
--- a/.github/workflows/ci_cd.yml
+++ b/.github/workflows/ci_cd.yml
@@ -1,4 +1,5 @@
name: CI + CD
+
on:
pull_request:
push:
@@ -15,16 +16,25 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
+
+ - name: Rebase
+ if: github.event.input.rebase
+ run: |
+ git fetch main
+ git rebase main
+
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
+
- name: Cache pre-commit envs
uses: actions/cache@v2
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
+
- name: Run pre-commit to lint files
run: |
pip install pre-commit
@@ -40,7 +50,7 @@ jobs:
- ingestion_server
steps:
- name: Checkout repository
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v1
@@ -71,7 +81,7 @@ jobs:
- build-images
steps:
- name: Checkout repository
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
- name: Setup just
uses: extractions/setup-just@v1
@@ -125,7 +135,8 @@ jobs:
- build-images
steps:
- name: Checkout repository
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
+
- name: Setup just
uses: extractions/setup-just@v1
@@ -169,7 +180,7 @@ jobs:
- build-images
steps:
- name: Checkout repository
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
- name: Setup just
uses: extractions/setup-just@v1
@@ -194,7 +205,7 @@ jobs:
- build-images
steps:
- name: Checkout repository
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
- name: Setup just
uses: extractions/setup-just@v1
@@ -210,7 +221,7 @@ jobs:
docker load --input /tmp/ingestion_server/ingestion_server.tar
- name: Run makemigrations
- run: just dj makemigrations --check --noinput
+ run: just dj makemigrations --check --noinput --merge
push:
name: Publish Docker images
@@ -262,7 +273,7 @@ jobs:
steps:
- name: Checkout repository
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
- name: Setup just
uses: extractions/setup-just@v1
@@ -335,7 +346,7 @@ jobs:
(This comment will be automatically updated with the preview URLs once it is ready)
- name: Checkout repository
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
- name: Setup just
uses: extractions/setup-just@v1
diff --git a/.github/workflows/migration_safety_warning.yml b/.github/workflows/migration_safety_warning.yml
new file mode 100644
index 000000000..bca485ff2
--- /dev/null
+++ b/.github/workflows/migration_safety_warning.yml
@@ -0,0 +1,41 @@
+name: "Migration Safety Check"
+
+on:
+ pull_request:
+ paths:
+ - "**/migrations/**/*"
+
+jobs:
+ check-and-apply-labels:
+ name: "Check and Apply Labels"
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v3
+
+ - uses: peter-evans/find-comment@v2
+ id: existing-warning
+ with:
+ issue-number: ${{ github.event.pull_request.number }}
+ body-includes: This PR has migrations
+
+ - uses: actions/github-script@v6
+ if: steps.existing-warning.outputs.comment-id != 0
+ with:
+ github-token: ${{ secrets.ACCESS_TOKEN }}
+ script: |
+ await github.rest.issues.deleteComment({
+ owner: 'WordPress',
+ repo: 'openverse-api',
+ comment_id: ${{ steps.existing-warning.outputs.comment-id }},
+ })
+
+ - uses: peter-evans/create-or-update-comment@v2
+ with:
+ issue-number: ${{ github.event.pull_request.number }}
+ body: |
+ This PR has migrations. Please rebase it before merging to ensure that conflicting migrations are not introduced.
+
+ - uses: banyan/[email protected]
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}