diff --git a/.github/template-sync.yml b/.github/template-sync.yml new file mode 100644 index 0000000..ed405ae --- /dev/null +++ b/.github/template-sync.yml @@ -0,0 +1,30 @@ +# Note: SciTools/cartopy is managed by a separate development team so is not +# included in the templating. + +SciTools/cf-units: + - source: templates/.pre-commit-config.yaml + dest: .pre-commit-config.yaml +SciTools/iris: + - source: templates/.pre-commit-config.yaml + dest: .pre-commit-config.yaml +SciTools/iris-grib: + - source: templates/.pre-commit-config.yaml + dest: .pre-commit-config.yaml +SciTools/mo_pack: + - source: templates/.pre-commit-config.yaml + dest: .pre-commit-config.yaml +SciTools/nc-time-axis: + - source: templates/.pre-commit-config.yaml + dest: .pre-commit-config.yaml +SciTools/python-stratify: + - source: templates/.pre-commit-config.yaml + dest: .pre-commit-config.yaml +SciTools/tephi: + - source: templates/.pre-commit-config.yaml + dest: .pre-commit-config.yaml +SciTools/test-iris-imagehash: + - source: templates/.pre-commit-config.yaml + dest: .pre-commit-config.yaml +SciTools/workflows: + - source: templates/.pre-commit-config.yaml + dest: .pre-commit-config.yaml \ No newline at end of file diff --git a/.github/workflows/template-sync.yml b/.github/workflows/template-sync.yml new file mode 100644 index 0000000..5929f54 --- /dev/null +++ b/.github/workflows/template-sync.yml @@ -0,0 +1,30 @@ +name: Sync template files across repos +on: + schedule: + # "At 02:00 on day-of-month 1 in every 2nd month." + - cron: '0 2 1 */2 *' + workflow_dispatch: + +jobs: + sync: + if: "github.repository_owner == 'SciTools' || github.event_name == 'workflow_dispatch'" + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - id: generate-token + uses: tibdex/github-app-token@v2 + with: + app_id: ${{ secrets.AUTH_APP_ID }} + private_key: ${{ secrets.AUTH_APP_PRIVATE_KEY }} + + - uses: BetaHuhn/repo-file-sync-action@3023dac7ce66c18b119e2012348437eadeaea116 + with: + GH_INSTALLATION_TOKEN: ${{ steps.generate-token.outputs.token }} + CONFIG_PATH: .github/template-sync.yml + PR_LABELS: | + Bot + Type: Infrastructure + COMMIT_PREFIX: "👁 TEMPLATE DEVIATIONS:" + PR_BODY: "## Please read: https://github.com/SciTools/.github/tree/main/templates" diff --git a/templates/.pre-commit-config.yaml b/templates/.pre-commit-config.yaml new file mode 100644 index 0000000..3dcb66e --- /dev/null +++ b/templates/.pre-commit-config.yaml @@ -0,0 +1,68 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks + +files: | + (?x)( + noxfile\.py| + setup\.py| + docs\/.+\.py| + benchmarks\/.+\.py| + ) +minimum_pre_commit_version: 1.21.0 + +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + # Prevent giant files from being committed. + - id: check-added-large-files + # Check whether files parse as valid Python. + - id: check-ast + # Check for file name conflicts on case-insensitive filesytems. + - id: check-case-conflict + # Check for files that contain merge conflict strings. + - id: check-merge-conflict + # Check for debugger imports and py37+ `breakpoint()` calls in Python source. + - id: debug-statements + # Don't commit to main branch. + - id: no-commit-to-branch + +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: "v0.3.4" + hooks: + - id: ruff + types: [file, python] + args: [--fix, --show-fixes] + - id: ruff-format + types: [file, python] + +- repo: https://github.com/codespell-project/codespell + rev: "v2.2.6" + hooks: + - id: codespell + types_or: [asciidoc, python, markdown, rst] + additional_dependencies: [tomli] + +- repo: https://github.com/PyCQA/flake8 + rev: 7.0.0 + hooks: + - id: flake8 + types: [file, python] + +- repo: https://github.com/asottile/blacken-docs + rev: 1.16.0 + hooks: + - id: blacken-docs + types: [file, rst] + +- repo: https://github.com/aio-libs/sort-all + rev: v1.2.0 + hooks: + - id: sort-all + types: [file, python] + +- repo: https://github.com/numpy/numpydoc + rev: v1.7.0 + hooks: + - id: numpydoc-validation + types: [file, python] \ No newline at end of file diff --git a/templates/README.md b/templates/README.md new file mode 100644 index 0000000..4d5e2c6 --- /dev/null +++ b/templates/README.md @@ -0,0 +1,19 @@ +These files are templates defining the standard format across all SciTools +repos. Repo deviations from template are periodically identified in pull +requests by the repo-file-sync-action. + +### Possible actions on a deviation pull request + +- ✔️ **Merge** - all deviations are re-aligned with the template + (E.g. the repo is simply out of date and needs updating). +- ❌ **Close** - all deviations are kept + (E.g. all deviations are required repo-specific detail). +- ️️✏️ **Edit** - re-align some deviations, keep others. +- 🏃 **Close then action independently** + (E.g. the repo contains content that should be added to the template). + +### Further reading + +- https://github.com/marketplace/actions/repo-file-sync-action +- [../.github/workflows/template-sync.yml](../.github/workflows/template-sync.yml) +- [../.github/template-sync.yml](../.github/template-sync.yml) \ No newline at end of file