Skip to content

Commit

Permalink
ci: add script that copies contributing into docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sujuka99 committed Oct 25, 2023
1 parent 9b81cfc commit 12616c0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ jobs:
- name: Generate pipeline definitions
run: poetry run pre-commit run gen-docs-components --all-files --show-diff-on-failure

- name: Copy contribution guide into docs
run: poetry run pre-commit gen-docs-contributing --all-files --show-diff-on-failure

- name: Test
run: poetry run pytest tests

Expand Down
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ repos:
types: [python]
require_serial: true
exclude: ^tests/.*snapshots/
pass_filenames: false
- id: gen-docs-env-vars
name: gen-docs-env-vars
entry: python hooks/gen_docs/gen_docs_env_vars.py
language: system
types: [python]
require_serial: true
exclude: ^tests/.*snapshots/
pass_filenames: false
- id: gen-docs-components
name: gen-docs-components
entry: python hooks/gen_docs/gen_docs_components.py
Expand All @@ -67,6 +69,13 @@ repos:
| kpops/components/.*\.py
)$
require_serial: true
- id: gen-docs-contributing
name: gen-docs-contributing
entry: python hooks/gen_docs/gen_docs_contributing.py
language: system
types: [python]
require_serial: true
pass_filenames: false
- id: dprint
name: dprint
entry: dprint fmt
Expand Down
19 changes: 19 additions & 0 deletions hooks/gen_docs/gen_docs_contributing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""Copies ``CONTROBUTING.md`` from root to the docs"""
import shutil
from pathlib import Path
from tempfile import TemporaryFile

KPOPS_ROOT = Path(__file__).parents[2].resolve()
SOURCE = KPOPS_ROOT / "CONTRIBUTING.md"
DEST = KPOPS_ROOT / "docs/docs/developer/contributing.md"
HEADER = f"<!-- This file is autogenerated by {Path(__file__)}. -->\n".encode()

# Copy `CONTRIBUTING.md` into the equivalent file in the docs,
# adding a comment at the top which notes that the file is generated
with TemporaryFile() as file_header:
file_header.write(HEADER)
file_header.seek(0)
with DEST.open("w+b") as file_dest:
with SOURCE.open("rb") as file_source:
shutil.copyfileobj(file_header, file_dest)
shutil.copyfileobj(file_source, file_dest)

0 comments on commit 12616c0

Please sign in to comment.