Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Fix meta-file sync workflow (#1224)
Dhruv Bhanushali4be0de6c6390
diff --git a/.github/sync.yml b/.github/sync.ymlindex e14b901ec..e1dd9f680 100644--- a/.github/sync.yml+++ b/.github/sync.yml@@ -3,9 +3,7 @@# Workflow: Meta file syncgroup:- # Openverse- repos: |- WordPress/openverse-catalogWordPress/openverse-infrastructurefiles:# Synced workflows@@ -39,46 +37,3 @@ group:component_spec.mddesign_changes.mdproject_thread.md-- # prettier.config.js- - repos: |- WordPress/openverse- files:- - source: templates/prettier.config.local.js.jinja- dest: prettier.config.js- template: true- - repos: |- WordPress/openverse-catalog- files:- - source: templates/prettier.config.js.jinja- dest: prettier.config.js- template: true-- # .pre-commit-config.yaml- - repos: |- WordPress/openverse- files:- - source: templates/.pre-commit-config.local.yaml.jinja- dest: .pre-commit-config.yaml- template: true- - repos: |- WordPress/openverse-catalog- files:- - source: templates/.pre-commit-config.yaml.jinja- dest: .pre-commit-config.yaml- template:- contains_js_code: false-- # pull_request_template.md- - repos: |- WordPress/openverse- files:- - source: templates/pull_request_template.md.jinja- dest: .github/PULL_REQUEST_TEMPLATE/pull_request_template.md- template: true- - repos: |- WordPress/openverse-catalog- files:- - source: templates/pull_request_template.catalog.md.jinja- dest: .github/PULL_REQUEST_TEMPLATE/pull_request_template.md- template: truediff --git a/.pre-commit-config.yaml b/.pre-commit-config.yamlindex cdef9f5de..5e39c541d 100644--- a/.pre-commit-config.yaml+++ b/.pre-commit-config.yaml@@ -150,24 +150,6 @@ repos:pass_filenames: falsestages:- push- - id: render-precommit- name: render-precommit- files: ^templates/.*$- entry: bash -c 'just automations/js/render-precommit'- language: system- pass_filenames: false- - id: render-prettier- name: render-prettier- files: ^templates/.*$- entry: bash -c 'just automations/js/render-prettier'- language: system- pass_filenames: false- - id: render-github- name: render-github- files: ^templates/.*$- entry: bash -c 'just automations/js/render-github'- language: system- pass_filenames: false- id: render-release-draftername: render-release-drafterfiles: ^templates/.*$diff --git a/README.md b/README.mdindex d493c3256..a1787afd8 100644--- a/README.md+++ b/README.md@@ -24,10 +24,8 @@ more. Openverse is live at [openverse.org](https://openverse.org).This repository contains most of the codebase, except for the Openverse catalog.Eventually the catalog will be merged into this repository as well.-- [Catalog](https://github.com/wordpress/openverse-catalog) | The Apache- Airflow-powered system for downloading and storing Openverse's metadata-- [Catalog](catalog/) | The methods used to identify and index over 1.4 billion- Creative Commons licensed works+- [Catalog](catalog/) | The Apache Airflow-powered system for downloading and+ storing Openverse's metadata- [Ingestion server](ingestion_server/) | The mechanism for refreshing the datafrom the catalog to the API- [API](api/) | The Django REST API for querying the database, used by the@@ -43,8 +41,8 @@ This repository also contains the following directories.- [Brand](brand/) | Brand assets for Openverse such as logo and icon andguidelines for using these assets-- [Templates](templates/) | Common scaffolding code that is rendered and synced- to the catalog repo+- [Templates](templates/) | Jinja templates that can be rendered into common+ scaffolding code for the project## Keep in touchdiff --git a/templates/.pre-commit-config.local.yaml.jinja b/templates/.pre-commit-config.local.yaml.jinjadeleted file mode 100644index 542f07610..000000000--- a/templates/.pre-commit-config.local.yaml.jinja+++ /dev/null@@ -1,83 +0,0 @@-{% set eslint_files = '\\.(js|ts|vue)$' %}-{% set eslint_exclude = '^utilities/load_testing/.*|frontend/(nuxt-template-overrides/.*|.remake/.*)$' %}--{% extends 'templates/.pre-commit-config.yaml.jinja' %}--{% block note %}-{{ super() }}-# - https://github.com/WordPress/openverse/blob/main/templates/.pre-commit-config.local.yaml.jinja-{%- endblock %}--{#=======================================-Repo blocks must be indented by 2 spaces.-=======================================#}--{% block repos_top %}- - repo: local # More local hooks are defined at the bottom.- hooks:- - id: i18n- name: i18n- files: ^frontend/.*$- # Check if the i18n files have been downloaded by checking if the Arabic translation exists- # Download the i18n files if they do not exist- entry: bash -c 'if [ ! -f "$(dirname "$dir")"/frontend/src/locales/ar.json ]; then just frontend/run i18n; fi'- language: system- pass_filenames: false-{# This comment adds a blank line. #}-{% endblock %}--{% block repos_bottom %}-{# This comment adds a blank line. #}- - repo: local # More local hooks are defined at the top.- hooks:- - id: types- name: types- files: ^frontend/.*$- entry: bash -c 'pnpm exec vue-tsc -p frontend --noEmit'- language: system- pass_filenames: false- - id: test:unit- name: test:unit- files: ^frontend/.*$- entry: bash -c 'just frontend/run test:unit'- language: system- pass_filenames: false- stages:- - push- {% set renders = ["precommit", "prettier", "github", "release-drafter"] %}- {% for render in renders %}- - id: render-{{ render }}- name: render-{{ render }}- files: ^templates/.*$- entry: bash -c 'just automations/js/render-{{ render }}'- language: system- pass_filenames: false- {% endfor %}-{% endblock %}--{#=========================================-Dependencies must be indented by 10 spaces.-=========================================#}--{% block eslint_dependencies %}-{{ super() }}- - "@babel/[email protected]"- - "@intlify/[email protected]"- - "@nuxtjs/[email protected]"- - "@typescript-eslint/[email protected]"- - "@typescript-eslint/[email protected]"-{%- endblock %}--{% block prettier_dependencies %}-{{ super() }}-{%- endblock %}diff --git a/templates/.pre-commit-config.yaml.jinja b/templates/.pre-commit-config.yaml.jinjadeleted file mode 100644index a19a50b94..000000000--- a/templates/.pre-commit-config.yaml.jinja+++ /dev/null@@ -1,129 +0,0 @@-{% block note %}-# This file is being synced from WordPress/openverse. Any changes made to it-# here will be overwritten. Please make any necessary edits to these files:-# - https://github.com/WordPress/openverse/blob/main/templates/.pre-commit-config.yaml.jinja-{%- endblock %}--{# This comment adds a blank line. #}-exclude: Pipfile\.lock|migrations|\.idea|node_modules|archive|retired--repos:- {% block repos_top %}- {% endblock %}- - repo: https://github.com/pre-commit/pre-commit-hooks- rev: v4.4.0- hooks:- - id: trailing-whitespace- args: [--markdown-linebreak-ext=md]- - id: check-executables-have-shebangs- - id: check-json- exclude: tsconfig.json # contains comments- - id: check-case-conflict- - id: check-toml- - id: check-merge-conflict- - id: check-xml- - id: check-yaml- - id: end-of-file-fixer- exclude: frontend/test/tapes/.+\.json5- - id: check-symlinks- - id: mixed-line-ending- - id: fix-encoding-pragma- args:- - --remove- {% if contains_python_code | default(true) %}- - id: check-docstring-first- - id: requirements-txt-fixer- {% endif %}-- {% if contains_python_code | default(true) %}- # Use the `.isort.cfg` file to configure additional project-specific requirements.- - repo: https://github.com/PyCQA/isort- rev: 5.12.0- hooks:- - id: isort- files: \.py$- exclude: ^build/.*$|^.tox/.*$|^venv/.*$- args:- - --profile=black- - --lines-after-imports=2-- - repo: https://github.com/asottile/pyupgrade- rev: v3.3.1- hooks:- - id: pyupgrade- args:- - --py310-plus-- - repo: https://github.com/charliermarsh/ruff-pre-commit- rev: "v0.0.261"- hooks:- - id: ruff-- - repo: https://github.com/ambv/black- rev: 23.3.0- hooks:- - id: black- args:- - --safe-- - repo: https://github.com/pycqa/pydocstyle- rev: 6.3.0- hooks:- - id: pydocstyle- args:- - --convention=pep257- # Additional ignore reasons:- # D1xx: we do not want to force contributors to write redundant or useless docstrings- # D202: additional whitespace helps with readability- # D205: we don't want to always require a single line summary- # D211: same as D202- # D400: first line doesn't need to end in a period- # See the following documentation for what each rule does:- # https://www.pydocstyle.org/en/6.2.3/error_codes.html#error-codes- - --add-ignore=D1,D202,D205,D211,D400-- {% endif %}- {% if contains_js_code | default(true) %}- - repo: https://github.com/pre-commit/mirrors-eslint- rev: v8.37.0- hooks:- - id: eslint- files: {{ eslint_files | default("^js/.*$") }}- {% if eslint_exclude %}- exclude: {{ eslint_exclude }} # ESLint raises warnings for ignored files.- {% endif %}- "types": [file] # ESLint only accepts [javascript] by default.- args:- - --ignore-path=.gitignore- - --ignore-path=.eslintignore- - --max-warnings=0- additional_dependencies:- {% block eslint_dependencies %}- {%- endblock %}--{# This comment adds a blank line. #}- {% endif %}- # Use the `.prettierignore` and `.prettier.config.js` files to configure project-specific requirements.- - repo: https://github.com/pre-commit/mirrors-prettier- rev: v2.6.0- hooks:- - id: prettier- additional_dependencies:- {% block prettier_dependencies %}- {%- endblock %}--{# This comment adds a blank line. #}- - repo: https://github.com/koalaman/shellcheck-precommit- rev: v0.9.0- hooks:- - id: shellcheck-- - repo: https://github.com/rhysd/actionlint- rev: v1.6.24- hooks:- - id: actionlint-docker- {% block repos_bottom %}- {% endblock %}diff --git a/templates/README.md b/templates/README.mddeleted file mode 100644index 4ee14d76e..000000000--- a/templates/README.md+++ /dev/null@@ -1,27 +0,0 @@-# Template workflow--Contributing to the linting templates can be unintuitive at first. If you follow-the process outlined below, it makes things a _lot_ easier to manage and-iterate.--## Process for editing jinja templates--1. Make changes to the jinja template-1. Run `just automations/js/render-templates` to re-render all templates. This- runs pretty quickly but if you need to go even faster, you can run the- `render-precommit`, `render-prettier`, or `render-github` recipes instead to- render only the specific files you're changing.-1. Confirm your rendered changes meet prettier's requirements by:- 1. Staging `.pre-commit-config.yaml` with `git add .pre-commit-config.yaml`- 1. Run `pre-commit run prettier`- 1. Run `git diff` to see any differences prettier may have made to the final- output- - This separate step is necessary because prettier does not lint the jinja- files. For the rendered output of the jinja files to pass prettier, the- templates themselves must be perfect, so you have to manually push changes- that prettier will make into the templates. Often this is stuff like- tedious whitespace, line-break, and indentation issues in the YAML or the- Markdown templates.-1. If you had to make changes to appease prettier, follow steps 2 and 3 again- and confirm there are no more changes from prettier.-1. You're done!diff --git a/templates/prettier.config.js.jinja b/templates/prettier.config.js.jinjadeleted file mode 100644index 9161d6c71..000000000--- a/templates/prettier.config.js.jinja+++ /dev/null@@ -1,26 +0,0 @@-{% block note %}-// This file is being synced from WordPress/openverse. Any changes made to it-// here will be overwritten. Please make any necessary edits to these files:-// - https://github.com/WordPress/openverse/blob/main/templates/prettier.config.js.jinja-{%- endblock %}--{# This comment adds a blank line. #}-module.exports = {- trailingComma: "es5",- tabWidth: 2,- semi: false,- singleQuote: false,- proseWrap: "always",- overrides: [- {- files: ["*.yml", "*.yaml"],- options: {- proseWrap: "preserve",- },- },- {% block additional_overrides %}- {% endblock %}- ],- {% block additional_config %}- {% endblock %}-}diff --git a/templates/prettier.config.local.js.jinja b/templates/prettier.config.local.js.jinjadeleted file mode 100644index a36935791..000000000--- a/templates/prettier.config.local.js.jinja+++ /dev/null@@ -1,17 +0,0 @@-{% extends 'templates/prettier.config.js.jinja' %}--{% block note %}-{{ super() }}-// - https://github.com/WordPress/openverse/blob/main/templates/prettier.config.local.js.jinja-{%- endblock %}--{% block additional_overrides %}- {- files: ["frontend/**/*"],- options: {- plugins: [require("prettier-plugin-tailwindcss")],- tailwindConfig: "frontend/tailwind.config.js",- vueIndentScriptAndStyle: false,- },- },-{% endblock %}diff --git a/templates/pull_request_template.md.jinja b/templates/pull_request_template.md.jinjadeleted file mode 100644index f4d2fb41b..000000000--- a/templates/pull_request_template.md.jinja+++ /dev/null@@ -1,88 +0,0 @@-## Fixes--<!-- If PR doesn't fully resolve the issue, replace 'Fixes' below with 'Related to'. -->-<!-- If there is no issue being resolved, please consider opening one before creating this pull request. -->--Fixes #[issue number] by @[issue author]--## Description--<!-- Concisely describe what the pull request does. -->-<!-- Add screenshots, videos, or other media to show the problem and the solution when appropriate. -->--## Testing Instructions--<!-- Give steps for the reviewer to verify that this PR fixes the problem; or delete this section entirely. -->--{% block additional_sections %}-{% endblock -%}--## Checklist--<!-- Replace the [ ] with [x] to check the boxes. -->--- [ ] My pull request has a descriptive title (not a vague title like- `Update index.md`).-- [ ] My pull request targets the _default_ branch of the repository (`main`) or- a parent feature branch.-- [ ] My commit messages follow [best practices][best_practices].-- [ ] My code follows the established code style of the repository.-- [ ] I added or updated tests for the changes I made (if applicable).-- [ ] I added or updated documentation (if applicable).-- [ ] I tried running the project locally and verified that there are no visible- errors.-- [ ] I ran the DAG documentation generator (only applicable for catalog PRs).-{% block additional_checks %}-{% endblock %}--[best_practices]:- https://git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-Project#_commit_guidelines--## Developer Certificate of Origin--<!-- You must read and understand the following attestation. -->--<details>-<summary>Developer Certificate of Origin</summary>--```-Developer Certificate of Origin-Version 1.1--Copyright (C) 2004, 2006 The Linux Foundation and its contributors.-1 Letterman Drive-Suite D4700-San Francisco, CA, 94129--Everyone is permitted to copy and distribute verbatim copies of this-license document, but changing it is not allowed.---Developer's Certificate of Origin 1.1--By making a contribution to this project, I certify that:--(a) The contribution was created in whole or in part by me and I- have the right to submit it under the open source license- indicated in the file; or--(b) The contribution is based upon previous work that, to the best- of my knowledge, is covered under an appropriate open source- license and I have the right under that license to submit that- work with modifications, whether created in whole or in part- by me, under the same open source license (unless I am- permitted to submit under a different license), as indicated- in the file; or--(c) The contribution was provided directly to me by some other- person who certified (a), (b) or (c) and I have not modified- it.--(d) I understand and agree that this project and the contribution- are public and that a record of the contribution (including all- personal information I submit with it, including my sign-off) is- maintained indefinitely and may be redistributed consistent with- this project or the open source license(s) involved.-```--</details>