Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ updates:
default-days: 7

- package-ecosystem: pip
directory: /CI
directory: /.github
schedule:
interval: daily
time: '12:00'
Expand Down
File renamed without changes.
12 changes: 5 additions & 7 deletions CI/requirements_ci.txt → .github/requirements_ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ cachetools==7.0.4 \
certifi==2024.7.4 \
--hash=sha256:5a1e7645bc0ec61a09e26c36f6106dd4cf40c6db3a1fb6352b0244e7fb057c7b \
--hash=sha256:c198e21b1289c2ab85ee4e67bb4b4ef3ead0892059901a8d5b622f24a1101e90
# via requests
# via
# httpcore
# httpx
# requests
charset-normalizer==3.3.2 \
--hash=sha256:06435b539f889b1f6f4ac1758871aae42dc3a8c0e24ac9e60c2384973ad73027 \
--hash=sha256:06a81e93cd441c56a9b65d8e1d043daeb97a3d0856d177d5c90ba85acb3db087 \
Expand Down Expand Up @@ -598,12 +601,7 @@ tomli==2.4.1 \
--hash=sha256:fd0409a3653af6c147209d267a0e4243f0ae46b011aa978b1080359fddc9b6cf \
--hash=sha256:ff18e6a727ee0ab0388507b89d1bc6a22b138d1e2fa56d1ad494586d61d2eae9 \
--hash=sha256:ff2983983d34813c1aeb0fa89091e76c3a22889ee83ab27c5eeb45100560c049
# via
# -r requirements_ci.in
# deptry
# pylint
# pyproject-api
# tox
# via requests
tomli-w==1.2.0 \
--hash=sha256:188306098d013b691fcadc011abd66727d3c414c571bb01b1a174ba8c983cf90 \
--hash=sha256:2dd14fac5a47c27be9cd4c976af5a12d87fb1f0b4512f81d69cce3b35ae25021
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ on:
- .cruft.json
- .editorconfig
- .github/**.yml
- .github/*.in
- .github/*.txt
- .gitignore
- .pre-commit-config.yaml
- .yamllint.yaml
- .zenodo.json
- AUTHORS.rst
- CHANGELOG.rst
- CI/**/*.in
- CI/**/*.txt
- CITATION.cff
- CODE_OF_CONDUCT.md
- CONTRIBUTING.rst
Expand All @@ -45,7 +45,6 @@ jobs:
runs-on: ubuntu-latest
environment: automation
permissions:
actions: read
contents: write
strategy:
matrix:
Expand Down Expand Up @@ -76,7 +75,7 @@ jobs:
git config --local user.name "bumpversion[bot]"
- name: Install CI libraries
run: |
python -m pip install --require-hashes -r CI/requirements_ci.txt
python -m pip install --require-hashes -r .github/requirements_ci.txt
- name: Conditional Bump Version
run: |
CURRENT_VERSION=$(bump-my-version show current_version)
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/first-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,5 @@ jobs:
we ask that you add your information to the \`AUTHORS.rst\` and \`.zenodo.json\`:
- [ ] The relevant author information has been added to \`AUTHORS.rst\` and \`.zenodo.json\`

Please make sure you've read our [contributing guide](CONTRIBUTING.rst).
We look forward to reviewing your Pull Request shortly ✨`
Please make sure you've read our [contributing guide](https://github.com/glamod/cdm_reader_mapper/blob/main/CONTRIBUTING.rst). We look forward to reviewing your Pull Request shortly ✨`
})
2 changes: 1 addition & 1 deletion .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install packaging libraries
run: |
python -m pip install -r CI/requirements_ci.txt
python -m pip install -r .github/requirements_ci.txt
- name: Build a binary wheel and a source tarball
run: |
python -m flit build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tag-testpypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:

- name: Install CI libraries
run: |
python -m pip install --require-hashes -r CI/requirements_ci.txt
python -m pip install --require-hashes -r .github/requirements_ci.txt
- name: Build a binary wheel and a source tarball
run: |
python -m flit build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testing-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
cache: pip
- name: Install CI libraries
run: |
python -m pip install --require-hashes -r CI/requirements_ci.txt
python -m pip install --require-hashes -r .github/requirements_ci.txt
- name: Environment Caching
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
Expand Down
92 changes: 47 additions & 45 deletions .github/workflows/workflow-warning.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ on:
permissions:
contents: read

concurrency:
group: workflow-warning-${{ github.event.pull_request.number }}
cancel-in-progress: true


jobs:
comment-concerning-workflow-changes:
name: Comment Concerning Workflow Changes
runs-on: ubuntu-latest
if: |
(github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name)
if: github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
permissions:
contents: read
pull-requests: write
Expand All @@ -33,60 +37,58 @@ jobs:
allowed-endpoints: >
api.github.com:443

- name: Manage Warning / Note Comments
- name: Create or Update Warning Comment
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
APPROVED: ${{ contains(github.event.pull_request.labels.*.name, 'approved') }}
PR_NUMBER: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
WARNING_TEXT="This Pull Request modifies GitHub workflows and is coming from a fork."
NOTE_TEXT="Workflow changes in this Pull Request have been approved!"
set -euo pipefail

# Fetch existing comments
COMMENTS=$(gh api repos/$REPO/issues/$PR_NUMBER/comments)
MARKER="<!-- workflow-changes-warning -->"

# Find warning comment ID
WARNING_COMMENT_ID=$(echo "$COMMENTS" | jq -r \
'.[] | select(.user.login=="github-actions[bot]") | select(.body | contains("'"$WARNING_TEXT"'")) | .id' | head -n 1)
BODY=$(cat <<EOF
$MARKER

# Find note comment ID
NOTE_COMMENT_ID=$(echo "$COMMENTS" | jq -r \
'.[] | select(.user.login=="github-actions[bot]") | select(.body | contains("'"$NOTE_TEXT"'")) | .id' | head -n 1)
> [!WARNING]
> This pull request modifies GitHub Actions workflows and originates from a fork.
>
> Review the workflow changes carefully before approving or merging.
EOF
)

if [ "$APPROVED" = "true" ]; then
BODY="> [!NOTE]
> Workflow changes in this Pull Request have been approved!"
COMMENTS=$(gh api repos/$REPO/issues/$PR_NUMBER/comments)

if [ -n "$NOTE_COMMENT_ID" ] && [ "$NOTE_COMMENT_ID" != "null" ]; then
# Append to existing note comment
EXISTING=$(gh api repos/$REPO/issues/comments/$NOTE_COMMENT_ID --jq .body)
gh api \
--method PATCH \
repos/$REPO/issues/comments/$NOTE_COMMENT_ID \
-f body="$EXISTING
mapfile -t IDS < <(
echo "$COMMENTS" |
jq -r '
.[]
| select(.body | contains("<!-- workflow-changes-warning -->"))
| .id
'
)

COMMENT_ID=""

$BODY"
else
# Create new note comment
gh pr comment "$PR_NUMBER" --body "$BODY"
fi
if [ "${#IDS[@]}" -gt 0 ]; then
COMMENT_ID="${IDS[0]}"

# Add reaction (hooray)
if [ -n "$NOTE_COMMENT_ID" ] && [ "$NOTE_COMMENT_ID" != "null" ]; then
# Remove duplicate managed comments if they exist.
for id in "${IDS[@]:1}"; do
gh api \
--method POST \
repos/$REPO/issues/comments/$NOTE_COMMENT_ID/reactions \
-f content='hooray' \
-H "Accept: application/vnd.github+json"
fi
--method DELETE \
repos/$REPO/issues/comments/$id
done
fi

if [ -n "$COMMENT_ID" ]; then
gh api \
--method PATCH \
repos/$REPO/issues/comments/$COMMENT_ID \
-f body="$BODY"
else
BODY="> [!WARNING]
> This Pull Request modifies GitHub Workflows and is coming from a fork.
**It is very important for the reviewer to ensure that the workflow changes are appropriate.**"

if [ -z "$WARNING_COMMENT_ID" ] || [ "$WARNING_COMMENT_ID" = "null" ]; then
gh pr comment "$PR_NUMBER" --body "$BODY"
fi
fi
gh api \
--method POST \
repos/$REPO/issues/$PR_NUMBER/comments \
-f body="$BODY"
fi
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ repos:
- id: check-github-workflows
- id: check-readthedocs
- repo: https://github.com/woodruffw/zizmor-pre-commit
rev: v1.23.1
rev: v1.24.1
hooks:
- id: zizmor
args: [ '--config=.zizmor.yml' ]
Expand Down
62 changes: 62 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Agents

Rules for AI coding agents working in this repository.

## General

- Follow existing code conventions and patterns
- Do not modify files outside the scope of the current task
- Prefer editing existing files over creating new ones
- Do not add dependencies without explicit approval
- Keep changes atomic -- one concern per commit
- Ask for clarification when requirements are ambiguous
- Do not generate PR descriptions or review comments on others' code

## Code Style

- Follow the linting patterns provided via `$ make lint` in the `Makefile` alongside the configurations found in the top-level `pyproject.toml` and `.pre-commit-config.yaml` files.
- All functions should be typed and new functions must have `numpydoc`-like docstrings.

## Setup

The package can be installed in developer mode in Python using the `$ make develop` recipe.

## Testing

- Write tests for new functionality.
- Any `pytest` fixtures common to tests across multiple `test_*.py` files should be found within `conftest.py`.
- Run the full suite before submitting.
- Test coverage must not significantly drop between PRs and main.

## Restricted Paths

Do not modify:

- `.*`
- `.github`
- `docs`
- `tox.toml`

## Changelog

- Changes must be summarized in one or two sentences within the `CHANGELOG.rst` file.
- New additions must be placed under the section labelled "(unreleased)".
- Acceptable category types are all previously categories found in `CHANGELOG.rst`
- Entries must end with the issue number and PR number appended to the end: "(:issue:`#`, :pull:`#`)".

## Commits

- Use clear, descriptive commit messages
- One logical change per commit
- Do not bundle unrelated changes
- Reference relevant issues when applicable
- Never push directly to main
- Always use a PR branch and get human approval before merging
- Include `Assisted-by: <tool name>` trailer on AI-assisted commits

## Review

All changes to code require human review.

---
*Generated by [aipolicy.1mb.dev](https://aipolicy.1mb.dev) · v1.0*
63 changes: 63 additions & 0 deletions AI_POLICY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# AI Policy

## Accountability

You are responsible for every line of code you submit, regardless of how it was produced. If you use AI tools, review and verify all output before committing.

## Pull Requests

Pull Requests descriptions must be drafted by a human and adhere to the template selected on creation.
Summaries of changes posted by AI are not accepted in Pull Requests.

## AI Tool Usage

AI tools are permitted. Standard review process applies to all contributions.

## AI-Generated Code

AI-generated code must be reviewed by a human maintainer before merging. Keep changes atomic -- you must be able to explain any line on request.

## Disclosure

Mark AI involvement in commit messages with a trailer:

```text
Assisted-by: <tool name>
```

Code changes from less sophisticated phrase-completion tools do not require an AI disclosure.

## Prohibited Uses

- Submitting AI output you have not read and understood
- Using AI to generate code that circumvents tests or CI checks
- Feeding reviewer feedback back into AI without understanding it first
- AI-generated PR descriptions -- describe your own work
- AI-generated reviews on other contributors' PRs

## AI in CI/CD

AI tools may be used in CI/CD pipelines for code analysis, test generation, and deployment.

## Training Data

This project requests that its code not be used for AI model training. We ask that AI tool providers honor this preference.

## Low Effort Contributions

AI-generated low-effort contributions are unacceptable; Human and AI contributors must be capable of explaining their changes, responding to review comments, and precisely adapting their contributions as requested.

## Licensing

AI-generated contributions must be compatible with this project's license. Contributors must be able to certify their submissions under the project's contribution terms.

## Enforcement

Maintainers may close AI-generated PRs that do not meet these standards without detailed feedback.

## Policy Evolution

This policy will evolve as tooling and conventions change. Contributions to the policy itself are welcome.

---
*Generated by [aipolicy.1mb.dev](https://aipolicy.1mb.dev) · v1.0*
Loading
Loading