Skip to content

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

Add tag app release action (#987)

sarayourfriend5dc8176f79ce
diff --git a/.github/release-drafter-api.yml b/.github/release-drafter-api.yml
index 181c6ce48..2e6e2961b 100644
--- a/.github/release-drafter-api.yml
+++ b/.github/release-drafter-api.yml
@@ -1,7 +1,7 @@
# This file is generated from templates/release-drafter.yml.jinja
# Changes to this file must be made in the template first
-name-template: "API $RESOLVED_VERSION"
+tag-prefix: api-
categories:
- title: New Features
label: "🌟 goal: addition"
diff --git a/.github/release-drafter-frontend.yml b/.github/release-drafter-frontend.yml
new file mode 100644
index 000000000..251b3f925
--- /dev/null
+++ b/.github/release-drafter-frontend.yml
@@ -0,0 +1,27 @@
+# This file is generated from templates/release-drafter.yml.jinja
+# Changes to this file must be made in the template first
+
+tag-prefix: frontend-
+categories:
+ - title: New Features
+ label: "🌟 goal: addition"
+ - title: Improvements
+ label: "✨ goal: improvement"
+ - title: Internal Improvements
+ labels:
+ - "πŸ€– aspect: dx"
+ - "🧰 goal: internal improvement"
+ - title: Bug Fixes
+ label: "πŸ›  goal: fix"
+# Identical to the default except it uses `-` instead of `*` to match our Markdown linter
+change-template: "- $TITLE (#$NUMBER) @$AUTHOR"
+exclude-labels:
+ - "skip-changelog"
+include-labels:
+ - "🧱 stack: frontend"
+template: |
+ $CHANGES
+
+ ## Credits
+
+ Thanks to $CONTRIBUTORS for their contributions!
diff --git a/.github/release-drafter-ingestion_server.yml b/.github/release-drafter-ingestion_server.yml
new file mode 100644
index 000000000..576fc63b1
--- /dev/null
+++ b/.github/release-drafter-ingestion_server.yml
@@ -0,0 +1,27 @@
+# This file is generated from templates/release-drafter.yml.jinja
+# Changes to this file must be made in the template first
+
+tag-prefix: ingestion_server-
+categories:
+ - title: New Features
+ label: "🌟 goal: addition"
+ - title: Improvements
+ label: "✨ goal: improvement"
+ - title: Internal Improvements
+ labels:
+ - "πŸ€– aspect: dx"
+ - "🧰 goal: internal improvement"
+ - title: Bug Fixes
+ label: "πŸ›  goal: fix"
+# Identical to the default except it uses `-` instead of `*` to match our Markdown linter
+change-template: "- $TITLE (#$NUMBER) @$AUTHOR"
+exclude-labels:
+ - "skip-changelog"
+include-labels:
+ - "🧱 stack: ingestion server"
+template: |
+ $CHANGES
+
+ ## Credits
+
+ Thanks to $CONTRIBUTORS for their contributions!
diff --git a/.github/release_drafter.yml b/.github/release_drafter.yml
deleted file mode 100644
index 1925e58a2..000000000
--- a/.github/release_drafter.yml
+++ /dev/null
@@ -1,39 +0,0 @@
-# yaml-language-server: $schema=https://raw.githubusercontent.com/release-drafter/release-drafter/master/schema.json
-#
-# Configuration for the action `release-drafter/release-drafter`
-# Docs: https://github.com/release-drafter/release-drafter
-# Workflow: Draft release
-
-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
- labels:
- - "πŸ€– aspect: dx"
- - "🧰 goal: internal improvement"
- - title: Bug Fixes
- label: "πŸ›  goal: fix"
-change-template: "- $TITLE (#$NUMBER) @$AUTHOR"
-exclude-labels:
- - "skip-changelog"
-version-resolver:
- major:
- labels:
- - "πŸ’₯ versioning: major"
- minor:
- labels:
- - "πŸŽ‰ versioning: minor"
- patch:
- labels:
- - "πŸ› versioning: patch"
- default: patch
-template: |
- $CHANGES
-
- ## Credits
-
- Thanks to $CONTRIBUTORS for their contributions!
diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml
index 86e563831..841dc8604 100644
--- a/.github/workflows/ci_cd.yml
+++ b/.github/workflows/ci_cd.yml
@@ -5,9 +5,6 @@ on:
push:
branches:
- main
- release:
- types:
- - published
workflow_dispatch:
inputs:
image-tag:
diff --git a/.github/workflows/draft_release.yml b/.github/workflows/draft_release.yml
deleted file mode 100644
index 4312caf83..000000000
--- a/.github/workflows/draft_release.yml
+++ /dev/null
@@ -1,19 +0,0 @@
-name: Draft release
-# ℹ️ https://github.com/WordPress/openverse/blob/main/.github/GITHUB.md#draft-release
-
-on:
- push:
- branches:
- - main
-
-jobs:
- update_draft_release:
- name: Update draft release
- runs-on: ubuntu-latest
- steps:
- - name: Update draft release
- uses: release-drafter/release-drafter@v5
- with:
- config-name: release_drafter.yml
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/release-app.yml b/.github/workflows/release-app.yml
new file mode 100644
index 000000000..b46ba9c21
--- /dev/null
+++ b/.github/workflows/release-app.yml
@@ -0,0 +1,165 @@
+name: Release app
+
+on:
+ workflow_dispatch:
+ inputs:
+ app:
+ type: choice
+ options:
+ - api
+ - ingestion_server
+ - frontend
+ required: true
+ description: Application to release. If `api` or `frontend`, the deployment workflow will automatically be dispatched for you.
+ image-sha:
+ type: string
+ required: true
+ description: The SHA of the staging image to tag.
+
+concurrency: ${{ github.workflow }}-${{ inputs.app }}
+
+jobs:
+ release-app:
+ name: Release app
+ runs-on: ubuntu-latest
+ permissions:
+ # Needed for pushing the new docker image tag
+ packages: write
+ # Needed to open the changelog PR
+ pull-requests: write
+ steps:
+ - uses: actions/checkout@v3
+ with:
+ # Creating the tag requires having the whole history of `main`
+ fetch-depth: 0
+
+ - name: Validate `sha-tag` input
+ uses: actions/github-script@v6
+ with:
+ script: |
+ let exists = undefined,
+ page = 0
+ while (!exists) {
+ page += 1
+ const { data: versions } =
+ await github.rest.packages.getAllPackageVersionsForPackageOwnedByOrg({
+ package_type: 'container',
+ // We do not have to validate that auxiliary images also exist as they're built at the same time
+ // as the "main" image. e.g., `api_nginx` is always built when `api` is built and they'll have
+ // the same set of tags.
+ package_name: 'openverse-${{ inputs.app }}',
+ org: 'WordPress',
+ page,
+ // max of `per_page`
+ per_page: 100,
+ })
+ if (!versions.length) {
+ break
+ }
+ exists = versions.some((v) => v.metadata.container.tags.includes('${{ inputs.image-sha }}'))
+ }
+ if (!exists) {
+ throw new Error(
+ `'${{ inputs.image-sha }}' does not appear to be a valid SHA tag for ${{ inputs.app }}.`
+ )
+ }
+
+ - name: Calculate tag name
+ id: tag
+ run: |
+ # Format example: 2023.03.22.04.56.29
+ # `-u` forces UTC
+ formatted_date="$(date -u +%Y.%m.%d.%H.%M.%S)"
+
+ # Split image and git tag to avoid app name duplicated in the fully qualified image name
+ {
+ echo "date=$formatted_date";
+ echo "git-tag=${{ inputs.app }}-$formatted_date";
+ echo "image-tag=rel-$formatted_date";
+ } >> "$GITHUB_OUTPUT"
+
+ - name: Log in to GitHub Docker Registry
+ uses: docker/login-action@v2
+ with:
+ registry: https://ghcr.io
+ username: ${{ github.repository_owner }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Add new tag to existing docker image
+ run: |
+ docker buildx imagetools create ghcr.io/wordpress/openverse-${{ inputs.app }}:${{ inputs.image-sha }} --tag ghcr.io/wordpress/openverse-${{ inputs.app }}:${{ steps.tag.outputs.image-tag }}
+
+ if [ "${{ inputs.app }}" = "api" ]; then
+ docker buildx imagetools create ghcr.io/wordpress/openverse-api_nginx:${{ inputs.image-sha }} --tag ghcr.io/wordpress/openverse-api_nginx:${{ steps.tag.outputs.image-tag }}
+ fi
+
+ - name: Create and publish release
+ uses: release-drafter/release-drafter@v5
+ id: release-drafter
+ with:
+ config-name: release-drafter-${{ inputs.app }}.yml
+ version: ${{ steps.tag.outputs.date }}
+ tag: ${{ steps.tag.outputs.git-tag }}
+ name: ${{ steps.tag.outputs.git-tag }}
+ publish: true
+ commitish: main
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Add new changelog file to documentation
+ run: |
+ cat << EOF > documentation/changelogs/${{ inputs.app }}/${{ steps.tag.outputs.date }}.md
+ # ${{ steps.tag.outputs.date }}
+
+ ${{ steps.release-drafter.outputs.body }}
+ EOF
+
+ - name: Setup CI env
+ uses: ./.github/actions/setup-env
+ with:
+ github_token: ${{ secrets.GITHUB_TOKEN }}
+ # Python is not needed to run pre-commit.
+ setup_python: false
+ # Node.js is needed by lint actions.
+ install_recipe: "node-install"
+
+ - name: Cache pre-commit envs
+ uses: actions/cache@v3
+ with:
+ path: ~/.cache/pre-commit
+ key: ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
+
+ - name: Lint the changelog file so that it passes CI
+ run: |
+ just precommit
+ just lint
+
+ - name: Open changelog PR
+ uses: peter-evans/create-pull-request@v4
+ with:
+ # Access token necessary for PRs to run with CI
+ token: ${{ secrets.ACCESS_TOKEN }}
+ base: main
+ branch: changelog/${{ steps.tag.outputs.git-tag }}
+ commit-message: Publish changelog for ${{ steps.tag.outputs.git-tag }}
+ title: Publish changelog for ${{ steps.tag.outputs.git-tag }}
+ # Add labels to pass CI
+ labels: |
+ 🧱 stack: ${{ inputs.app == 'ingestion_server' && 'ingestion server' || inputs.app }}
+ 🌟 goal: addition
+ πŸ“„ aspect: text
+ 🟩 priority: low
+ body: |
+ This changelog PR was automatically generated for @${{ github.actor }} as a result of the ${{ github.workflow }} workflow.
+
+ - name: Deploy production api
+ if: inputs.app == 'api'
+ uses: ./.github/workflows/deploy-production-api.yml
+ with:
+ tag: ${{ steps.tag.outputs.image-tag }}
+
+ - name: Deploy production frontend
+ if: inputs.app == 'frontend'
+ uses: ./.github/workflows/deploy-production-nuxt.yml
+ with:
+ tag: ${{ steps.tag.outputs.image-tag }}
diff --git a/.github/workflows_downstream/draft_release.yml b/.github/workflows_downstream/draft_release.yml
deleted file mode 100644
index 4312caf83..000000000
--- a/.github/workflows_downstream/draft_release.yml
+++ /dev/null
@@ -1,19 +0,0 @@
-name: Draft release
-# ℹ️ https://github.com/WordPress/openverse/blob/main/.github/GITHUB.md#draft-release
-
-on:
- push:
- branches:
- - main
-
-jobs:
- update_draft_release:
- name: Update draft release
- runs-on: ubuntu-latest
- steps:
- - name: Update draft release
- uses: release-drafter/release-drafter@v5
- with:
- config-name: release_drafter.yml
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 5327974f9..575f62212 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -163,3 +163,9 @@ repos:
entry: bash -c 'just automations/js/render-github'
language: system
pass_filenames: false
+ - id: render-release-drafter
+ name: render-release-drafter
+ files: ^templates/.*$
+ entry: bash -c 'just automations/js/render-release-drafter'
+ language: system
+ pass_filenames: false
diff --git a/automations/js/justfile b/automations/js/justfile
index 3b97a4887..56f71915b 100644
--- a/automations/js/justfile
+++ b/automations/js/justfile
@@ -24,7 +24,7 @@ report:
# Run `render-jinja.js` with given input file, output file and context
render in_file out_file ctx="{}":
- node src/render-jinja.js {{ in_file }} {{ out_file }} {{ ctx }}
+ node src/render-jinja.js {{ in_file }} {{ out_file }} '{{ ctx }}'
# Render `.pre-commit-config.yaml`
render-precommit:
@@ -38,8 +38,14 @@ render-prettier:
render-github:
just render templates/pull_request_template.md.jinja .github/PULL_REQUEST_TEMPLATE/pull_request_template.md
+render-release-drafter:
+ just render templates/release-drafter.yml.jinja .github/release-drafter-api.yml '{ "app": "API" }'
+ just render templates/release-drafter.yml.jinja .github/release-drafter-ingestion_server.yml '{ "app": "Ingestion server" }'
+ just render templates/release-drafter.yml.jinja .github/release-drafter-frontend.yml '{ "app": "Frontend" }'
+
# Render all templates (shortcut for easy iteration)
render-templates:
just render-precommit
just render-prettier
just render-github
+ just render-release-drafter
diff --git a/documentation/_ext/link_issues.py b/documentation/_ext/link_issues.py
new file mode 100644
index 000000000..b2e7958bc
--- /dev/null
+++ b/documentation/_ext/link_issues.py
@@ -0,0 +1,370 @@
+"""Issue linking w/ plain-text autolinking, e.g. #42
+
+Credit: https://github.com/ignatenkobrain/sphinxcontrib-issuetracker
+License: BSD
+
+Changes by Tony Narlock (2022-08-21):
+- Type annotations
+
+ mypy --strict, requires types-requests, types-docutils
+
+ Python < 3.10 require typing-extensions
+- TrackerConfig: Use dataclasses instead of typing.NamedTuple and hacking __new__
+- app.warn (removed in 5.0) -> Use Sphinx Logging API
+
+ https://www.sphinx-doc.org/en/master/extdev/logging.html#logging-api
+- Add PendingIssueXRef
+
+ Typing for tracker_config and precision
+- Add IssueTrackerBuildEnvironment
+
+ Subclassed / typed BuildEnvironment with .tracker_config
+- Just GitHub (for demonstration)
+"""
+import dataclasses
+import re
+import time
+import typing as t
+
+import requests
+from docutils import nodes
+from sphinx.addnodes import pending_xref
+from sphinx.application import Sphinx
+from sphinx.config import Config
+from sphinx.environment import BuildEnvironment
+from sphinx.transforms import SphinxTransform
+from sphinx.util import logging
+
+
+if t.TYPE_CHECKING:
+ from typing import TypeGuard
+
+logger = logging.getLogger(__name__)
+
+GITHUB_API_URL = "https://api.github.com/repos/{0.project}/issues/{1}"
+
+
+class IssueTrackerBuildEnvironment(BuildEnvironment):
+ tracker_config: "TrackerConfig"
+ issuetracker_cache: "IssueTrackerCache"
+ github_rate_limit: t.Tuple[float, bool]
+
+
+class Issue(t.NamedTuple):
+ id: str
+ title: str
+ url: str
+ closed: bool
+
+
+IssueTrackerCache = t.Dict[str, Issue]
+
+
+class TrackerConfig:
+ project: str
+ url: str
+
+ """
+ Issue tracker configuration.
+ This class provides configuration for trackers, and is passed as
+ ``tracker_config`` arguments to callbacks of
+ :event:`issuetracker-lookup-issue`.
+ """
+
+ def __post_init__(self) -> None:
+ if self.url is not None:
+ self.url = self.url.rstrip("/")
+
+ @classmethod
+ def from_sphinx_config(cls, config: Config) -> "TrackerConfig":
+ """Get tracker configuration from ``config``."""
+ project = config.issuetracker_project or config.project
+ url = config.issuetracker_url
+ return cls(project=project, url=url)
+
+
+class PendingIssueXRef(pending_xref):
+ tracker_config: TrackerConfig
+
+
+class IssueReferences(SphinxTransform):
+
+ default_priority = 999
+
+ def apply(self) -> None:
+ config = self.document.settings.env.config
+ tracker_config = TrackerConfig.from_sphinx_config(config)
+ issue_pattern = config.issuetracker_issue_pattern
+ title_template = None
+ if isinstance(issue_pattern, str):
+ issue_pattern = re.compile(issue_pattern)
+ for node in self.document.traverse(nodes.Text):
+ parent = node.parent
+ if isinstance(parent, (nodes.literal, nodes.FixedTextElement)):
+ # ignore inline and block literal text
+ continue
+ if isinstance(parent, nodes.reference):
+ continue
+ text = str(node)
+ new_nodes = []
+ last_issue_ref_end = 0
+ for match in issue_pattern.finditer(text):
+ # catch invalid pattern with too many groups
+ if len(match.groups()) != 1:
+ raise ValueError(
+ "issuetracker_issue_pattern must have "
+ "exactly one group: {!r}".format(match.groups())
+ )
+ # extract the text between the last issue reference and the
+ # current issue reference and put it into a new text node
+ head = text[last_issue_ref_end : match.start()]
+ if head:
+ new_nodes.append(nodes.Text(head))
+ # adjust the position of the last issue reference in the
+ # text
+ last_issue_ref_end = match.end()
+ # extract the issue text (including the leading dash)
+ issuetext = match.group(0)
+ # extract the issue number (excluding the leading dash)
+ issue_id = match.group(1)
+ # turn the issue reference into a reference node
+ refnode = PendingIssueXRef()
+
+ refnode["refdomain"] = None
+ refnode["reftarget"] = issue_id
+ refnode["reftype"] = "issue"
+ refnode["trackerconfig"] = tracker_config
+ reftitle = title_template or issuetext
+ refnode.append(
+ nodes.inline(issuetext, reftitle, classes=["xref", "issue"])
+ )
+ new_nodes.append(refnode)
+ if not new_nodes:
+ # no issue references were found, move on to the next node
+ continue
+ # extract the remaining text after the last issue reference, and
+ # put it into a text node
+ tail = text[last_issue_ref_end:]
+ if tail:
+ new_nodes.append(nodes.Text(tail))
+ # find and remove the original node, and insert all new nodes
+ # instead
+ parent.replace(node, new_nodes)
+
+
+def is_issuetracker_env(
+ env: t.Any,
+) -> "TypeGuard['IssueTrackerBuildEnvironment']":
+ return hasattr(env, "issuetracker_cache") and env.issuetracker_cache is not None
+
+
+def lookup_issue(
+ app: Sphinx, tracker_config: TrackerConfig, issue_id: str
+) -> t.Optional[Issue]:
+ """
+ Lookup the given issue.
+ The issue is first looked up in an internal cache. If it is not found, the
+ event ``issuetracker-lookup-issue`` is emitted. The result of this
+ invocation is then cached and returned.
+ ``app`` is the sphinx application object. ``tracker_config`` is the
+ :class:`TrackerConfig` object representing the issue tracker configuration.
+ ``issue_id`` is a string containing the issue id.
+ Return a :class:`Issue` object for the issue with the given ``issue_id``,
+ or ``None`` if the issue wasn't found.
+ """
+ env = app.env
+ if is_issuetracker_env(env):
+ cache: IssueTrackerCache = env.issuetracker_cache
+ if issue_id not in cache:
+ issue = app.emit_firstresult(
+ "issuetracker-lookup-issue", tracker_config, issue_id
+ )
+ cache[issue_id] = issue
+ return cache[issue_id]
+ return None
+
+
+def lookup_issues(app: Sphinx, doctree: nodes.document) -> None:
+ """
+ Lookup issues found in the given ``doctree``.
+ Each issue reference in the given ``doctree`` is looked up. Each lookup
+ result is cached by mapping the referenced issue id to the looked up
+ :class:`Issue` object (an existing issue) or ``None`` (a missing issue).
+ The cache is available at ``app.env.issuetracker_cache`` and is pickled
+ along with the environment.
+ """
+ for node in doctree.traverse(PendingIssueXRef):
+ if node["reftype"] == "issue":
+ lookup_issue(app, node["trackerconfig"], node["reftarget"])
+
+
+def make_issue_reference(issue: Issue, content_node: nodes.inline) -> nodes.reference:
+ """
+ Create a reference node for the given issue.
+ ``content_node`` is a docutils node which is supposed to be added as
+ content of the created reference. ``issue`` is the :class:`Issue` which
+ the reference shall point to.
+ Return a :class:`docutils.nodes.reference` for the issue.
+ """
+ reference = nodes.reference()
+ reference["refuri"] = issue.url
+ if issue.title:
+ reference["reftitle"] = issue.title
+ if issue.closed:
+ content_node["classes"].append("closed")
+ reference.append(content_node)
+ return reference
+
+
+def resolve_issue_reference(
+ app: Sphinx, env: BuildEnvironment, node: PendingIssueXRef, contnode: nodes.inline
+) -> t.Optional[nodes.reference]:
+ """
+ Resolve an issue reference and turn it into a real reference to the
+ corresponding issue.
+ ``app`` and ``env`` are the Sphinx application and environment
+ respectively. ``node`` is a ``pending_xref`` node representing the missing
+ reference. It is expected to have the following attributes:
+ - ``reftype``: The reference type
+ - ``trackerconfig``: The :class:`TrackerConfig`` to use for this node
+ - ``reftarget``: The issue id
+ - ``classes``: The node classes
+ References with a ``reftype`` other than ``'issue'`` are skipped by
+ returning ``None``. Otherwise the new node is returned.
+ If the referenced issue was found, a real reference to this issue is
+ returned. The text of this reference is formatted with the :class:`Issue`
+ object available in the ``issue`` key. The reference title is set to the
+ issue title. If the issue is closed, the class ``closed`` is added to the
+ new content node.
+ Otherwise, if the issue was not found, the content node is returned.
+ """
+ if node["reftype"] != "issue":
+ return None
+
+ issue = lookup_issue(app, node["trackerconfig"], node["reftarget"])
+ if issue is None:
+ return contnode
+ else:
+ classes = contnode["classes"]
+ conttext = str(contnode[0])
+ formatted_conttext = nodes.Text(conttext.format(issue=issue))
+ formatted_contnode = nodes.inline(conttext, formatted_conttext, classes=classes)
+ assert issue is not None
+ return make_issue_reference(issue, formatted_contnode)
+ return None
+
+
+def init_cache(app: Sphinx) -> None:
+ if not hasattr(app.env, "issuetracker_cache"):
+ app.env.issuetracker_cache: "IssueTrackerCache" = {} # type: ignore
+ return None
+
+
+def check_project_with_username(tracker_config: TrackerConfig) -> None:
+ if "/" not in tracker_config.project:
+ raise ValueError(f"username missing in project name: {tracker_config.project}")
+
+
+HEADERS = {"User-Agent": "sphinxcontrib-issuetracker v{}".format("1.0")}
+
+
+def get(app: Sphinx, url: str) -> t.Optional[requests.Response]:
+ """
+ Get a response from the given ``url``.
+ ``url`` is a string containing the URL to request via GET. ``app`` is the
+ Sphinx application object.
+ Return the :class:`~requests.Response` object on status code 200, or
+ ``None`` otherwise. If the status code is not 200 or 404, a warning is
+ emitted via ``app``.
+ """
+ response = requests.get(url, headers=HEADERS)
+ if response.status_code == requests.codes.ok:
+ return response
+ elif response.status_code != requests.codes.not_found:
+ msg = "GET {0.url} failed with code {0.status_code}"
+ logger.warning(msg.format(response))
+
+ return None
+
+
+def lookup_github_issue(
+ app: Sphinx, tracker_config: TrackerConfig, issue_id: str
+) -> t.Optional[Issue]:
+ check_project_with_username(tracker_config)
+
+ env = app.env
+ if is_issuetracker_env(env):
+ # Get rate limit information from the environment
+ timestamp, limit_hit = getattr(env, "github_rate_limit", (0, False))
+
+ if limit_hit and time.time() - timestamp > 3600:
+ # Github limits applications hourly
+ limit_hit = False
+
+ if not limit_hit:
+ url = GITHUB_API_URL.format(tracker_config, issue_id)
+ response = get(app, url)
+ if response:
+ rate_remaining = response.headers.get("X-RateLimit-Remaining")
+ assert rate_remaining is not None
+ if rate_remaining.isdigit() and int(rate_remaining) == 0:
+ logger.warning("Github rate limit hit")
+ env.github_rate_limit = (time.time(), True)
+ issue = response.json()
+ closed = issue["state"] == "closed"
+ return Issue(
+ id=issue_id,
+ title=issue["title"],
+ closed=closed,
+ url=issue["html_url"],
+ )
+ else:
+ logger.warning(
+ f"Github rate limit exceeded, not resolving issue {issue_id}"
+ )
+ return None
+
+
+BUILTIN_ISSUE_TRACKERS: t.Dict[str, t.Any] = {
+ "github": lookup_github_issue,
+}
+
+
+def init_transformer(app: Sphinx) -> None:
+ if app.config.issuetracker_plaintext_issues:
+ app.add_transform(IssueReferences)
+
+
+def connect_builtin_tracker(app: Sphinx) -> None:
+ if app.config.issuetracker:
+ tracker = BUILTIN_ISSUE_TRACKERS[app.config.issuetracker.lower()]
+ app.connect("issuetracker-lookup-issue", tracker)
+
+
+def setup(app: Sphinx) -> t.Dict[str, t.Any]:
+ app.add_config_value("mybase", "https://github.com/cihai/unihan-etl", "env")
+ app.add_event("issuetracker-lookup-issue")
+ app.connect("builder-inited", connect_builtin_tracker)
+ app.add_config_value("issuetracker", None, "env")
+ app.add_config_value("issuetracker_project", None, "env")
+ app.add_config_value("issuetracker_url", None, "env")
+ # configuration specific to plaintext issue references
+ app.add_config_value("issuetracker_plaintext_issues", True, "env")
+ app.add_config_value(
+ "issuetracker_issue_pattern",
+ re.compile(
+ r"#(\d+)",
+ ),
+ "env",
+ )
+ app.add_config_value("issuetracker_title_template", None, "env")
+ app.connect("builder-inited", init_cache)
+ app.connect("builder-inited", init_transformer)
+ app.connect("doctree-read", lookup_issues)
+ app.connect("missing-reference", resolve_issue_reference)
+ return {
+ "version": "1.0",
+ "parallel_read_safe": True,
+ "parallel_write_safe": True,
+ }
diff --git a/documentation/changelogs/api/index.md b/documentation/changelogs/api/index.md
new file mode 100644
index 000000000..cb43a9b91
--- /dev/null
+++ b/documentation/changelogs/api/index.md
@@ -0,0 +1,10 @@
+# API changelogs
+
+Changelogs for <https://api.openverse.engineering/>.
+
+```{toctree}
+:glob:
+:reverse:
+:titlesonly:
+*
+```
diff --git a/documentation/changelogs/frontend/index.md b/documentation/changelogs/frontend/index.md
new file mode 100644
index 000000000..620ca2431
--- /dev/null
+++ b/documentation/changelogs/frontend/index.md
@@ -0,0 +1,11 @@
+# Frontend changelogs
+
+Changelogs for <https://openverse.org/>.
+
+```{toctree}
+:glob:
+:reverse:
+:titlesonly:
+
+*
+```
diff --git a/documentation/changelogs/index.md b/documentation/changelogs/index.md
new file mode 100644
index 000000000..061d54d34
--- /dev/null
+++ b/documentation/changelogs/index.md
@@ -0,0 +1,18 @@
+# Changelogs
+
+These changelog files are automatically generated when maintainers run the
+"Release app" workflow.
+
+The lists of changes are derived using the "stack" labels and are organised by
+type of change. The documents are generated using the
+[`release-drafter`](https://github.com/release-drafter/release-drafter)
+workflow.
+
+```{toctree}
+:maxdepth: 1
+:glob:
+
+api/index
+frontend/index
+ingestion_server/index
+```
diff --git a/documentation/changelogs/ingestion_server/index.md b/documentation/changelogs/ingestion_server/index.md
new file mode 100644
index 000000000..35e3ac69c
--- /dev/null
+++ b/documentation/changelogs/ingestion_server/index.md
@@ -0,0 +1,11 @@
+# Ingestion server changelogs
+
+Changelogs for the internal ingestion server service.
+
+```{toctree}
+:glob:
+:reverse:
+:titlesonly:
+
+*
+```
diff --git a/documentation/conf.py b/documentation/conf.py
index 6fa093d70..6dfa216b0 100644
--- a/documentation/conf.py
+++ b/documentation/conf.py
@@ -1,3 +1,18 @@
+import sys
+from pathlib import Path
+
+
+def add_ext_to_path():
+ """Add the ``_ext`` directory to the module path"""
+ cwd = Path(__file__).parent
+ project_root = cwd.parent
+
+ sys.path.insert(0, str(project_root))
+ sys.path.insert(0, str(cwd / "_ext"))
+
+
+add_ext_to_path()
+
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
@@ -12,7 +27,7 @@ author = "Openverse <[email protected]>"
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
-extensions = ["myst_parser"]
+extensions = ["myst_parser", "link_issues"]
myst_heading_anchors = 6 # Add anchors to all headers, this is disabled by default.
source_suffix = {".rst": "restructuredtext", ".md": "markdown"}
@@ -37,3 +52,6 @@ html_favicon = (
html_static_path = ["_static"]
html_show_copyright = False
+
+issuetracker = "github"
+issuetracker_project = "WordPress/openverse"
diff --git a/documentation/index.md b/documentation/index.md
index 95ee87e6d..5fc56893b 100644
--- a/documentation/index.md
+++ b/documentation/index.md
@@ -29,6 +29,7 @@ use the Openverse API, you should instead refer to the
guides/index
reference/index
+changelogs/index
```
```{toctree}
diff --git a/frontend/justfile b/frontend/justfile
index 644531958..d6a790f6e 100644
--- a/frontend/justfile
+++ b/frontend/justfile
@@ -29,3 +29,6 @@ init: wait-up
# Run a package.json script via pnpm
run *args:
pnpm run {{ args }}
+
+types:
+ cd .. && pnpm exec vue-tsc -p frontend --noEmit
diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json
index ebda486aa..2034cefa1 100644
--- a/frontend/tsconfig.json
+++ b/frontend/tsconfig.json
@@ -78,6 +78,7 @@
"src/components/VFilters/VLicenseExplanation.vue",
"src/components/VHeader/VFilterButton.vue",
"src/components/VHeader/VPageLinks.vue",
+ "src/components/VHeader/VFilterIconOrCounter.vue",
"src/components/VHeader/VSearchBar/**.vue",
"src/components/VImageDetails/VRelatedImages.vue",
"src/components/VSearchResultsGrid/VImageCell.vue",
diff --git a/templates/.pre-commit-config.local.yaml.jinja b/templates/.pre-commit-config.local.yaml.jinja
index 59f2eb9d1..542f07610 100644
--- a/templates/.pre-commit-config.local.yaml.jinja
+++ b/templates/.pre-commit-config.local.yaml.jinja
@@ -44,7 +44,7 @@ Repo blocks must be indented by 2 spaces.
pass_filenames: false
stages:
- push
- {% set renders = ["precommit", "prettier", "github"] %}
+ {% set renders = ["precommit", "prettier", "github", "release-drafter"] %}
{% for render in renders %}
- id: render-{{ render }}
name: render-{{ render }}
diff --git a/templates/release-drafter.yml.jinja b/templates/release-drafter.yml.jinja
new file mode 100644
index 000000000..1fbffa353
--- /dev/null
+++ b/templates/release-drafter.yml.jinja
@@ -0,0 +1,27 @@
+# This file is generated from templates/release-drafter.yml.jinja
+# Changes to this file must be made in the template first
+
+tag-prefix: {{ app|lower|replace(" ", "_") }}-
+categories:
+ - title: New Features
+ label: "🌟 goal: addition"
+ - title: Improvements
+ label: "✨ goal: improvement"
+ - title: Internal Improvements
+ labels:
+ - "πŸ€– aspect: dx"
+ - "🧰 goal: internal improvement"
+ - title: Bug Fixes
+ label: "πŸ›  goal: fix"
+# Identical to the default except it uses `-` instead of `*` to match our Markdown linter
+change-template: "- $TITLE (#$NUMBER) @$AUTHOR"
+exclude-labels:
+ - "skip-changelog"
+include-labels:
+ - "🧱 stack: {{ app|lower }}"
+template: |
+ $CHANGES
+
+ ## Credits
+
+ Thanks to $CONTRIBUTORS for their contributions!