Skip to content

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

Add hook to clean up YAML files (#435)

Dhruv Bhanushali0f6aed821bdc
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index d863ec07a..1a358eb73 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -7,56 +7,56 @@ version: 2
updates:
# Enable version updates for Docker containers in Openverse API
- - package-ecosystem: 'docker'
+ - package-ecosystem: docker
# Look for a `Dockerfile` in the `/openverse_api` directory
- directory: '/openverse_api'
+ directory: /openverse_api
# Check for updates once a week
schedule:
- interval: 'weekly'
+ interval: weekly
labels:
- "πŸ’» aspect: code"
- "🧰 goal: internal improvement"
- "🟩 priority: low"
- - "dependencies"
+ - dependencies
# Enable version updates for Python libs in Openverse API
- - package-ecosystem: 'pip'
+ - package-ecosystem: pip
# Look for a `Pipfile` in the `/openverse_api` directory
- directory: '/openverse_api'
+ directory: /openverse_api
# Check for updates once a week
schedule:
- interval: 'weekly'
+ interval: weekly
labels:
- "πŸ’» aspect: code"
- "🧰 goal: internal improvement"
- "🟩 priority: low"
- - "dependencies"
- - "python"
+ - dependencies
+ - python
# Enable version updates for Python libs in ingestion server
- - package-ecosystem: 'pip'
+ - package-ecosystem: pip
# Look for a `Pipfile` in the `/ingestion_server` directory
- directory: '/ingestion_server'
+ directory: /ingestion_server
# Check for updates once a week
schedule:
- interval: 'weekly'
+ interval: weekly
labels:
- "πŸ’» aspect: code"
- "🧰 goal: internal improvement"
- "🟩 priority: low"
- - "dependencies"
- - "python"
+ - dependencies
+ - python
# Enable version updates for Python libs in analytics
- - package-ecosystem: 'pip'
+ - package-ecosystem: pip
# Look for a `Pipfile` in the `/analytics` directory
- directory: '/analytics'
+ directory: /analytics
# Check for updates once a week
schedule:
- interval: 'weekly'
+ interval: weekly
labels:
- "πŸ’» aspect: code"
- "🧰 goal: internal improvement"
- "🟩 priority: low"
- - "dependencies"
- - "python"
+ - dependencies
+ - python
diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml
index 822dcf40c..32346e4ef 100644
--- a/.github/release-drafter.yml
+++ b/.github/release-drafter.yml
@@ -1,27 +1,27 @@
# Configuration for the release-drafter action
# See docs here: https://github.com/marketplace/actions/release-drafter
-name-template: 'v$RESOLVED_VERSION'
-tag-template: 'v$RESOLVED_VERSION'
+name-template: "v$RESOLVED_VERSION"
+tag-template: "v$RESOLVED_VERSION"
categories:
- - title: 'New Features'
- label: '🌟 goal: addition'
- - title: 'Improvements'
- label: '✨ goal: improvement'
- - title: 'Internal Improvements'
- label: 'πŸ€– aspect: dx'
- - title: 'Bug Fixes'
- label: 'πŸ›  goal: fix'
-change-template: '- $TITLE: #$NUMBER by @$AUTHOR'
+ - title: New Features
+ label: "🌟 goal: addition"
+ - title: Improvements
+ label: "✨ goal: improvement"
+ - title: Internal Improvements
+ label: "πŸ€– aspect: dx"
+ - title: Bug Fixes
+ label: "πŸ›  goal: fix"
+change-template: "- $TITLE: #$NUMBER by @$AUTHOR"
version-resolver:
major:
labels:
- - 'major'
+ - major
minor:
labels:
- - 'minor'
+ - minor
patch:
labels:
- - 'patch'
+ - patch
default: patch
template: |
$CHANGES
diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml
index dd4b61481..e7fc49f84 100644
--- a/.github/workflows/integration_tests.yml
+++ b/.github/workflows/integration_tests.yml
@@ -2,10 +2,10 @@ name: Automated tests
on:
pull_request:
branches:
- - main
+ - main
push:
branches:
- - main
+ - main
workflow_dispatch:
jobs:
@@ -13,115 +13,115 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- - name: Checkout repository
- uses: actions/checkout@v2
- - name: Setup Python
- uses: actions/setup-python@v2
- - 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
- pre-commit run --all-files
+ - name: Checkout repository
+ uses: actions/checkout@v2
+ - name: Setup Python
+ uses: actions/setup-python@v2
+ - 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
+ pre-commit run --all-files
test-ing:
name: Run tests for ingestion-server
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- - name: Checkout repository
- uses: actions/checkout@v2
- - name: Setup just
- uses: extractions/setup-just@v1
- - name: Setup Python
- uses: actions/setup-python@v2
- with:
- python-version: "3.9"
- - name: Cache Python dependencies
- uses: actions/cache@v2
- with:
- path: ~/.cache/pip
- key: ${{ runner.os }}-pip-${{ hashFiles('**/Pipfile.lock') }}
- restore-keys: |
- ${{ runner.os }}-pip-
- - name: Setup Docker Buildx
- uses: docker/setup-buildx-action@v1
- with:
- install: true
- - name: Install Python deps for ingestion-server
- run: |
- pip install -U pip
- pip install pipenv
- just _ing-install
- - name: Build image `ingestion_server`
- uses: docker/build-push-action@v2
- with:
- context: ./ingestion_server/
- push: false
- load: true
- tags: ingestion_server
- cache-from: type=gha,scope=ingestion_server
- cache-to: type=gha,scope=ingestion_server
- - name: Run ingestion-server tests
- run: just ing-testlocal
+ - name: Checkout repository
+ uses: actions/checkout@v2
+ - name: Setup just
+ uses: extractions/setup-just@v1
+ - name: Setup Python
+ uses: actions/setup-python@v2
+ with:
+ python-version: "3.9"
+ - name: Cache Python dependencies
+ uses: actions/cache@v2
+ with:
+ path: ~/.cache/pip
+ key: ${{ runner.os }}-pip-${{ hashFiles('**/Pipfile.lock') }}
+ restore-keys: |
+ ${{ runner.os }}-pip-
+ - name: Setup Docker Buildx
+ uses: docker/setup-buildx-action@v1
+ with:
+ install: true
+ - name: Install Python deps for ingestion-server
+ run: |
+ pip install -U pip
+ pip install pipenv
+ just _ing-install
+ - name: Build image `ingestion_server`
+ uses: docker/build-push-action@v2
+ with:
+ context: ./ingestion_server/
+ push: false
+ load: true
+ tags: ingestion_server
+ cache-from: type=gha,scope=ingestion_server
+ cache-to: type=gha,scope=ingestion_server
+ - name: Run ingestion-server tests
+ run: just ing-testlocal
test-api:
name: Run tests for the API
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- - name: Checkout repository
- uses: actions/checkout@v2
- - name: Setup just
- uses: extractions/setup-just@v1
- - name: Setup Docker Buildx
- uses: docker/setup-buildx-action@v1
- with:
- install: true
- - name: Build image `openverse_api`
- uses: docker/build-push-action@v2
- with:
- context: ./openverse_api/
- push: false
- load: true
- target: api
- tags: openverse_api
- cache-from: type=gha,scope=openverse_api
- cache-to: type=gha,scope=openverse_api,mode=max
- - name: Build image `ingestion_server`
- uses: docker/build-push-action@v2
- with:
- context: ./ingestion_server/
- push: false
- load: true
- tags: ingestion_server
- cache-from: type=gha,scope=ingestion_server
- cache-to: type=gha,scope=ingestion_server
- - name: Build image `indexer_worker`
- uses: docker/build-push-action@v2
- with:
- context: ./ingestion_server/
- file: ./ingestion_server/Dockerfile_worker
- push: false
- load: true
- tags: indexer_worker
- cache-from: type=gha,scope=indexer_worker
- cache-to: type=gha,scope=indexer_worker
- - name: Build image `analytics`
- uses: docker/build-push-action@v2
- with:
- context: ./analytics/
- push: false
- load: true
- tags: analytics
- cache-from: type=gha,scope=analytics
- cache-to: type=gha,scope=analytics
- - name: Start API, ingest and index test data
- run: just init
- - name: Run API tests
- run: just api-test -T
- - name: Run analytics tests
- run: just nl-test -T
+ - name: Checkout repository
+ uses: actions/checkout@v2
+ - name: Setup just
+ uses: extractions/setup-just@v1
+ - name: Setup Docker Buildx
+ uses: docker/setup-buildx-action@v1
+ with:
+ install: true
+ - name: Build image `openverse_api`
+ uses: docker/build-push-action@v2
+ with:
+ context: ./openverse_api/
+ push: false
+ load: true
+ target: api
+ tags: openverse_api
+ cache-from: type=gha,scope=openverse_api
+ cache-to: type=gha,scope=openverse_api,mode=max
+ - name: Build image `ingestion_server`
+ uses: docker/build-push-action@v2
+ with:
+ context: ./ingestion_server/
+ push: false
+ load: true
+ tags: ingestion_server
+ cache-from: type=gha,scope=ingestion_server
+ cache-to: type=gha,scope=ingestion_server
+ - name: Build image `indexer_worker`
+ uses: docker/build-push-action@v2
+ with:
+ context: ./ingestion_server/
+ file: ./ingestion_server/Dockerfile_worker
+ push: false
+ load: true
+ tags: indexer_worker
+ cache-from: type=gha,scope=indexer_worker
+ cache-to: type=gha,scope=indexer_worker
+ - name: Build image `analytics`
+ uses: docker/build-push-action@v2
+ with:
+ context: ./analytics/
+ push: false
+ load: true
+ tags: analytics
+ cache-from: type=gha,scope=analytics
+ cache-to: type=gha,scope=analytics
+ - name: Start API, ingest and index test data
+ run: just init
+ - name: Run API tests
+ run: just api-test -T
+ - name: Run analytics tests
+ run: just nl-test -T
diff --git a/.github/workflows/new_issues.yml b/.github/workflows/new_issues.yml
index 0b0deb30c..ddeaae3b5 100644
--- a/.github/workflows/new_issues.yml
+++ b/.github/workflows/new_issues.yml
@@ -4,16 +4,16 @@ name: New issue automation
on:
issues:
types:
- - opened
+ - opened
jobs:
add_issue:
name: Add new issue
runs-on: ubuntu-latest
steps:
- - name: Add issue to "Backlog"
- uses: alex-page/[email protected]
- with:
- project: Openverse
- column: Backlog
- repo-token: ${{ secrets.ACCESS_TOKEN }}
+ - name: Add issue to "Backlog"
+ uses: alex-page/[email protected]
+ with:
+ project: Openverse
+ column: Backlog
+ repo-token: ${{ secrets.ACCESS_TOKEN }}
diff --git a/.github/workflows/new_prs.yml b/.github/workflows/new_prs.yml
index b1d32d0d1..98e27ceb9 100644
--- a/.github/workflows/new_prs.yml
+++ b/.github/workflows/new_prs.yml
@@ -4,9 +4,9 @@ name: New PR automation
on:
pull_request_target:
types:
- - opened
- - converted_to_draft
- - ready_for_review
+ - opened
+ - converted_to_draft
+ - ready_for_review
jobs:
add_draft:
@@ -14,21 +14,21 @@ jobs:
if: ${{ github.event.pull_request.draft }}
runs-on: ubuntu-latest
steps:
- - name: Add PR to "In progress"
- uses: alex-page/[email protected]
- with:
- project: Openverse PRs
- column: In progress
- repo-token: ${{ secrets.ACCESS_TOKEN }}
+ - name: Add PR to "In progress"
+ uses: alex-page/[email protected]
+ with:
+ project: Openverse PRs
+ column: In progress
+ repo-token: ${{ secrets.ACCESS_TOKEN }}
add_ready:
name: Add ready PR
if: ${{ !github.event.pull_request.draft }}
runs-on: ubuntu-latest
steps:
- - name: Add PR to "Needs review"
- uses: alex-page/[email protected]
- with:
- project: Openverse PRs
- column: Needs review
- repo-token: ${{ secrets.ACCESS_TOKEN }}
+ - name: Add PR to "Needs review"
+ uses: alex-page/[email protected]
+ with:
+ project: Openverse PRs
+ column: Needs review
+ repo-token: ${{ secrets.ACCESS_TOKEN }}
diff --git a/.github/workflows/pr_label_check.yml b/.github/workflows/pr_label_check.yml
index a01b96e69..9951bae5b 100644
--- a/.github/workflows/pr_label_check.yml
+++ b/.github/workflows/pr_label_check.yml
@@ -4,36 +4,36 @@ name: PR label check
on:
pull_request:
types:
- - opened
- - edited
- - labeled
- - unlabeled
- - synchronize
+ - opened
+ - edited
+ - labeled
+ - unlabeled
+ - synchronize
jobs:
check_aspect_label:
name: Check aspect label
runs-on: ubuntu-latest
steps:
- - name: Check aspect label
- uses: sugarshin/[email protected]
- with:
- required_oneof: 'πŸ’» aspect: code,πŸ“„ aspect: text,πŸ€– aspect: dx,πŸ•Ή aspect: interface,♿️ aspect: a11y'
+ - name: Check aspect label
+ uses: sugarshin/[email protected]
+ with:
+ required_oneof: "πŸ’» aspect: code,πŸ“„ aspect: text,πŸ€– aspect: dx,πŸ•Ή aspect: interface,♿️ aspect: a11y"
check_goal_label:
name: Check goal label
runs-on: ubuntu-latest
steps:
- - name: Check goal label
- uses: sugarshin/[email protected]
- with:
- required_oneof: '🌟 goal: addition,πŸ›  goal: fix,✨ goal: improvement,🧰 goal: internal improvement'
+ - name: Check goal label
+ uses: sugarshin/[email protected]
+ with:
+ required_oneof: "🌟 goal: addition,πŸ›  goal: fix,✨ goal: improvement,🧰 goal: internal improvement"
check_priority_label:
name: Check priority label
runs-on: ubuntu-latest
steps:
- - name: Check priority label
- uses: sugarshin/[email protected]
- with:
- required_oneof: '🟩 priority: low,🟨 priority: medium,🟧 priority: high,πŸŸ₯ priority: critical'
+ - name: Check priority label
+ uses: sugarshin/[email protected]
+ with:
+ required_oneof: "🟩 priority: low,🟨 priority: medium,🟧 priority: high,πŸŸ₯ priority: critical"
diff --git a/.github/workflows/pr_ping.yml b/.github/workflows/pr_ping.yml
index e34a1d6d7..500dfecd3 100644
--- a/.github/workflows/pr_ping.yml
+++ b/.github/workflows/pr_ping.yml
@@ -4,8 +4,8 @@ name: New PR notification
on:
pull_request_target:
types:
- - opened
- - ready_for_review
+ - opened
+ - ready_for_review
jobs:
send_message:
@@ -22,23 +22,23 @@ jobs:
pr_author: ${{ github.event.pull_request.user.login }}
pr_repo: ${{ github.event.pull_request.base.repo.full_name }}
steps:
- - name: Send notification for new PR
- if: github.event.action == 'opened'
- env:
- pr_status: ${{ github.event.pull_request.draft && ' draft ' || ' ' }}
- pr_icon: ${{ github.event.pull_request.draft && ':pr-draft:' || ':pull-request:' }}
- run: |
- curl \
- $slack_url \
- -X POST \
- -H 'Content-Type: application/json' \
- -d '{"text":"New'"$pr_status"'PR opened by '"$pr_author"' in '"$pr_repo"': #'"$pr_number"' - '"$pr_title"'","blocks":[{"type":"section","text":{"type":"mrkdwn","text":"'"$pr_icon"' New'"$pr_status"'PR opened by *'"$pr_author"'* in `'"$pr_repo"'`:\n<'"$pr_url"'|#'"$pr_number"' - '"$pr_title"'>"}}]}'
+ - name: Send notification for new PR
+ if: github.event.action == 'opened'
+ env:
+ pr_status: ${{ github.event.pull_request.draft && ' draft ' || ' ' }}
+ pr_icon: ${{ github.event.pull_request.draft && ':pr-draft:' || ':pull-request:' }}
+ run: |
+ curl \
+ $slack_url \
+ -X POST \
+ -H 'Content-Type: application/json' \
+ -d '{"text":"New'"$pr_status"'PR opened by '"$pr_author"' in '"$pr_repo"': #'"$pr_number"' - '"$pr_title"'","blocks":[{"type":"section","text":{"type":"mrkdwn","text":"'"$pr_icon"' New'"$pr_status"'PR opened by *'"$pr_author"'* in `'"$pr_repo"'`:\n<'"$pr_url"'|#'"$pr_number"' - '"$pr_title"'>"}}]}'
- - name: Send notification for PR marked ready
- if: github.event.action == 'ready_for_review'
- run: |
- curl \
- $slack_url \
- -X POST \
- -H 'Content-Type: application/json' \
- -d '{"text":"PR by '"$pr_author"' in '"$pr_repo"' marked ready for review: #'"$pr_number"' - '"$pr_title"'","blocks":[{"type":"section","text":{"type":"mrkdwn","text":":pull-request: PR by *'"$pr_author"'* in `'"$pr_repo"'` marked ready for review:\n<'"$pr_url"'|#'"$pr_number"' - '"$pr_title"'>"}}]}'
+ - name: Send notification for PR marked ready
+ if: github.event.action == 'ready_for_review'
+ run: |
+ curl \
+ $slack_url \
+ -X POST \
+ -H 'Content-Type: application/json' \
+ -d '{"text":"PR by '"$pr_author"' in '"$pr_repo"' marked ready for review: #'"$pr_number"' - '"$pr_title"'","blocks":[{"type":"section","text":{"type":"mrkdwn","text":":pull-request: PR by *'"$pr_author"'* in `'"$pr_repo"'` marked ready for review:\n<'"$pr_url"'|#'"$pr_number"' - '"$pr_title"'>"}}]}'
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 6edf4fde2..8fcb9c07e 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -49,3 +49,9 @@ repos:
- id: black
args:
- --safe
+
+ - repo: https://github.com/pre-commit/mirrors-prettier
+ rev: v2.5.0
+ hooks:
+ - id: prettier
+ types: [yaml]
diff --git a/analytics/docs/swagger.yaml b/analytics/docs/swagger.yaml
index ddfdd8e96..3e7313f66 100644
--- a/analytics/docs/swagger.yaml
+++ b/analytics/docs/swagger.yaml
@@ -22,29 +22,29 @@ host: "api.openverse.engineering"
basePath: "/analytics"
tags:
-- name: "Register events"
- description: "Send events to the analytics server."
+ - name: "Register events"
+ description: "Send events to the analytics server."
schemes:
-- "https"
+ - "https"
paths:
/search_event:
post:
tags:
- - "Register events"
+ - "Register events"
summary: "Register a search query event."
description: ""
operationId: "addSearch"
consumes:
- - "application/json"
+ - "application/json"
produces:
- - "application/json"
+ - "application/json"
parameters:
- - in: "body"
- name: "body"
- description: "The user's search query and unique session UUID."
- required: true
- schema:
- $ref: "#/definitions/CreateSearchEvent"
+ - in: "body"
+ name: "body"
+ description: "The user's search query and unique session UUID."
+ required: true
+ schema:
+ $ref: "#/definitions/CreateSearchEvent"
responses:
400:
@@ -52,20 +52,20 @@ paths:
/search_rating_event:
post:
tags:
- - "Register events"
+ - "Register events"
summary: "Submit a user's rating of a search."
description: ""
operationId: "addSearchRating"
consumes:
- - "application/json"
+ - "application/json"
produces:
- - "application/json"
+ - "application/json"
parameters:
- - in: "body"
- name: "body"
- required: true
- schema:
- $ref: "#/definitions/CreateSearchRatingEvent"
+ - in: "body"
+ name: "body"
+ required: true
+ schema:
+ $ref: "#/definitions/CreateSearchRatingEvent"
responses:
201:
@@ -75,20 +75,20 @@ paths:
/result_click_event:
post:
tags:
- - "Register events"
+ - "Register events"
summary: "Submit an event indicating which result was clicked for a given search query."
description: ""
operationId: "addResultClick"
consumes:
- - "application/json"
+ - "application/json"
produces:
- - "application/json"
+ - "application/json"
parameters:
- - in: "body"
- name: "body"
- required: true
- schema:
- $ref: "#/definitions/CreateResultClickEvent"
+ - in: "body"
+ name: "body"
+ required: true
+ schema:
+ $ref: "#/definitions/CreateResultClickEvent"
responses:
201:
description: "Created"
@@ -97,20 +97,20 @@ paths:
/detail_page_event:
post:
tags:
- - "Register events"
+ - "Register events"
summary: "Record events occurring on detail pages, such as sharing an image to social media or clicking through to its source."
description: ""
operationId: "addDetailPageEvent"
consumes:
- - "application/json"
+ - "application/json"
produces:
- - "application/json"
+ - "application/json"
parameters:
- - in: "body"
- name: "body"
- required: true
- schema:
- $ref: "#/definitions/CreateDetailPageEvent"
+ - in: "body"
+ name: "body"
+ required: true
+ schema:
+ $ref: "#/definitions/CreateDetailPageEvent"
responses:
201:
description: "Created"
diff --git a/docker-compose.yml b/docker-compose.yml
index 853bdc733..605c62a12 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -44,7 +44,11 @@ services:
- xpack.security.enabled=false
- discovery.type=single-node
healthcheck:
- test: ["CMD-SHELL", "curl -si -XGET 'localhost:9200/_cluster/health?pretty' | grep -qE 'yellow|green'"]
+ test:
+ [
+ "CMD-SHELL",
+ "curl -si -XGET 'localhost:9200/_cluster/health?pretty' | grep -qE 'yellow|green'",
+ ]
interval: 10s
timeout: 60s
retries: 10
@@ -55,9 +59,9 @@ services:
# Memory limit for ES, as it tends to be a memory hoarder
# Set this value to an empty string to remove the limit
# https://docs.docker.com/compose/compose-file/compose-file-v2/#cpu-and-other-resources
- mem_limit: ${ES_MEM_LIMIT:-4294967296} # 4 GiB in bytes
+ mem_limit: ${ES_MEM_LIMIT:-4294967296} # 4 GiB in bytes
volumes:
- - es-data:/usr/share/elasticsearch/data
+ - es-data:/usr/share/elasticsearch/data
web:
build: ./openverse_api/
@@ -117,7 +121,7 @@ services:
volumes:
- ./analytics:/analytics
env_file:
- - ./analytics/env.docker
+ - ./analytics/env.docker
volumes:
api-postgres:
diff --git a/ingestion_server/docker-compose.yml b/ingestion_server/docker-compose.yml
index 9b4ff5fbe..de535ff8c 100644
--- a/ingestion_server/docker-compose.yml
+++ b/ingestion_server/docker-compose.yml
@@ -1,13 +1,13 @@
version: "2.4"
services:
- ingestion_server:
- image: openverse/ingestion_server:1.4.0
- ports:
- - "8001:8001"
- env_file:
- - .env
- dns:
- # Related to DNS management on the production box.
- # Not sure if this is strictly necessary, but it exists
- # in the current, running system so we are retaining it here.
- - 172.31.0.2
+ ingestion_server:
+ image: openverse/ingestion_server:1.4.0
+ ports:
+ - "8001:8001"
+ env_file:
+ - .env
+ dns:
+ # Related to DNS management on the production box.
+ # Not sure if this is strictly necessary, but it exists
+ # in the current, running system so we are retaining it here.
+ - 172.31.0.2