Skip to content

Commit

Permalink
Render per-repo pull request template (#356)
Browse files Browse the repository at this point in the history
* Move templates into template folder

* Add pull request templates

* Add render-github to justfile, make local pre-commit dynamic

* Update sync configuration for pull request template

* Update README
  • Loading branch information
AetherUnbound committed Jan 3, 2023
1 parent 86cff2c commit d0f068f
Show file tree
Hide file tree
Showing 12 changed files with 150 additions and 38 deletions.
27 changes: 20 additions & 7 deletions .github/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,38 +38,51 @@ group:
dest: .github/release_drafter.yml
- source: .github/ISSUE_TEMPLATE/
dest: .github/ISSUE_TEMPLATE/
- source: .github/PULL_REQUEST_TEMPLATE.md
dest: .github/PULL_REQUEST_TEMPLATE.md
# Unified lint rules
- repos: |
WordPress/openverse
WordPress/openverse-catalog
WordPress/openverse-api
files:
- source: prettier.config.js.jinja
- source: templates/prettier.config.js.jinja
dest: prettier.config.js
template: true
- repos: |
WordPress/openverse
files:
- source: .pre-commit-config.local.yaml.jinja
- source: templates/.pre-commit-config.local.yaml.jinja
dest: .pre-commit-config.yaml
template: true
- repos: |
WordPress/openverse-catalog
WordPress/openverse-api
files:
- source: .pre-commit-config.yaml.jinja
- source: templates/.pre-commit-config.yaml.jinja
dest: .pre-commit-config.yaml
template:
contains_js_code: false
- repos: |
WordPress/openverse-frontend
files:
- source: .pre-commit-config.frontend.yaml.jinja
- source: templates/.pre-commit-config.frontend.yaml.jinja
dest: .pre-commit-config.yaml
template:
contains_python_code: false
- source: prettier.config.frontend.js.jinja
- source: templates/prettier.config.frontend.js.jinja
dest: prettier.config.js
template: true
# Pull request configuration
- repos: |
WordPress/openverse
WordPress/openverse-frontend
WordPress/openverse-api
files:
- source: templates/PULL_REQUEST_TEMPLATE.md.jinja
dest: .github/PULL_REQUEST_TEMPLATE.md
template: true
- repos: |
WordPress/openverse-catalog
files:
- source: templates/PULL_REQUEST_TEMPLATE.catalog.md.jinja
dest: .github/PULL_REQUEST_TEMPLATE.md
template: true
23 changes: 0 additions & 23 deletions .pre-commit-config.local.yaml.jinja

This file was deleted.

8 changes: 6 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 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/.pre-commit-config.yaml.jinja
# - https://github.com/WordPress/openverse/blob/main/.pre-commit-config.local.yaml.jinja
# - https://github.com/WordPress/openverse/blob/main/templates/.pre-commit-config.local.yaml.jinja

exclude: Pipfile\.lock|migrations|\.idea|node_modules|archive

Expand Down Expand Up @@ -97,9 +97,13 @@ repos:
entry: bash -c 'just render-precommit'
language: system
pass_filenames: false

- id: render-prettier
name: render-prettier
entry: bash -c 'just render-prettier'
language: system
pass_filenames: false
- id: render-github
name: render-github
entry: bash -c 'just render-github'
language: system
pass_filenames: false
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,5 @@ felt it best to keep them distinct.
- Requires [npm](https://www.npmjs.com) as the package manager.
- **`brand/`:** This directory contains brand assets for the project.
- **`rfcs/`:** This directory contains proposals for changes to Openverse.
- **`templates/`:** This directory contains templates which are rendered by
GitHub and synced across the other repositories.
8 changes: 6 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ render in_file out_file ctx="{}":

# Render `.pre-commit-config.yaml`
render-precommit:
just render .pre-commit-config.local.yaml.jinja .pre-commit-config.yaml
just render templates/.pre-commit-config.local.yaml.jinja .pre-commit-config.yaml

# Render `prettier.config.js`
render-prettier:
just render prettier.config.js.jinja prettier.config.js
just render templates/prettier.config.js.jinja prettier.config.js

# Render GitHub issue & PR templates
render-github:
just render templates/PULL_REQUEST_TEMPLATE.md.jinja .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{% set eslint_files = '\\.(js|ts|vue)$' %}
{% set eslint_exclude = '^nuxt-template-overrides/.*$' %}

{% extends '.pre-commit-config.yaml.jinja' %}
{% extends 'templates/.pre-commit-config.yaml.jinja' %}

{% block note %}
{{ super() }}
# - https://github.com/WordPress/openverse/blob/main/.pre-commit-config.frontend.yaml.jinja
# - https://github.com/WordPress/openverse/blob/main/templates/.pre-commit-config.frontend.yaml.jinja
{%- endblock %}

{#=======================================
Expand Down
20 changes: 20 additions & 0 deletions templates/.pre-commit-config.local.yaml.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% 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 %}

{% block repos_bottom %}
{# This comment adds a blank line. #}
- repo: local
hooks:
{% set renders = ["precommit", "prettier", "github"] %}
{% for render in renders %}
- id: render-{{ render }}
name: render-{{ render }}
entry: bash -c 'just render-{{ render }}'
language: system
pass_filenames: false
{% endfor %}
{% endblock %}
File renamed without changes.
5 changes: 5 additions & 0 deletions templates/PULL_REQUEST_TEMPLATE.catalog.md.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% extends 'templates/PULL_REQUEST_TEMPLATE.md.jinja' %}

{% block additional_checks %}
- [ ] I ran the DAG documentation generator (if applicable).
{% endblock %}
87 changes: 87 additions & 0 deletions templates/PULL_REQUEST_TEMPLATE.md.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
## 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.
{% 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>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{% extends 'prettier.config.js.jinja' %}
{% extends 'templates/prettier.config.js.jinja' %}

{% block note %}
{{ super() }}
// - https://github.com/WordPress/openverse/blob/main/prettier.config.frontend.js.jinja
// - https://github.com/WordPress/openverse/blob/main/templates/prettier.config.frontend.js.jinja
{%- endblock %}

{% block additional_config %}
Expand Down
File renamed without changes.

0 comments on commit d0f068f

Please sign in to comment.