Skip to content

Commit

Permalink
feat: migrate to copier-numpy template
Browse files Browse the repository at this point in the history
  • Loading branch information
eckelsjd committed Aug 29, 2024
1 parent 1dee537 commit 993371d
Show file tree
Hide file tree
Showing 45 changed files with 1,930 additions and 1,049 deletions.
18 changes: 18 additions & 0 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Changes here will be overwritten by Copier (DO NOT EDIT MANUALLY)
_commit: v0.4.0-2-g5b15cde
_src_path: gh:eckelsjd/copier-numpy
author_email: eckelsjd@umich.edu
author_name: Joshua Eckels
copyright_license: GPL-3.0
distribution_name: amisc
import_name: amisc
include_cicd: true
include_docs: true
init_github: true
install_jupyter: false
is_distributable: true
project_description: Efficient framework for building surrogates of multidisciplinary
systems using the adaptive multi-index stochastic collocation (AMISC) technique.
project_name: amisc
repository_namespace: eckelsjd
requires_python: '>=3.11'
47 changes: 20 additions & 27 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
name: Release package
name: Build and publish
on:
push:
tags:
- 'v*'
permissions:
contents: write
- 'v*.*.*'

jobs:
build:
name: Build distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- uses: pdm-project/setup-pdm@v4
- run: pdm build
- uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-pypi:
pypi-release:
name: Publish to PyPI
needs:
- build
Expand All @@ -42,7 +37,7 @@ jobs:
github-release:
name: Github release
needs:
- publish-pypi
- build
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -52,22 +47,20 @@ jobs:
with:
name: python-package-distributions
path: dist/
- uses: sigstore/gh-action-sigstore-python@v2
- uses: actions/checkout@v4
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Create Github Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
- name: Upload artifacts
fetch-depth: 0
- uses: pdm-project/setup-pdm@v4
with:
python-version: 3.11
cache: true
- run: pdm sync -G dev --no-default
- name: Create release notes
run: pdm run cz changelog $(pdm run cz version --project) --dry-run > body.md
- uses: softprops/action-gh-release@v2
with:
body_path: body.md
tag_name: ${{ github.ref_name }}
files: dist/*
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release upload
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26 changes: 8 additions & 18 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build documentation
name: Docs
on:
push:
branches:
Expand All @@ -12,11 +12,16 @@ jobs:
steps:
# Checkout this repository and cd to project root, set up python/pdm and cache
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- uses: pdm-project/setup-pdm@v4
with:
python-version: 3.11
cache: true
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- uses: actions/cache@v4
with:
Expand All @@ -25,21 +30,6 @@ jobs:
restore-keys: |
mkdocs-material-
# Build and push docs to gh-pages branch (triggers doc site publish action)
- run: pdm sync
- run: pdm sync -G doc -G test
- run: pdm run test # to generate coverage report
- run: pdm run mkdocs gh-deploy --force

coverage-test:
name: Test coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up PDM
uses: pdm-project/setup-pdm@v4
- name: Install dependencies
run: pdm install
- name: Run tests
run: pdm run -v test
- name: Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
21 changes: 18 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
name: Run PR test matrix
name: Lint and test
on:
pull_request:
branches: [ main ]
permissions:
contents: write
jobs:
check-lint:
name: Lint check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pdm-project/setup-pdm@v4
with:
python-version: 3.11
cache: true
- run: pdm sync -G dev --no-default
- run: pdm run lint

pr-tests:
name: PR tests
runs-on: ${{ matrix.os }}
needs: check-lint
strategy:
matrix:
python-version: ['3.11', '3.12']
os: [ ubuntu-latest, macOS-latest, windows-latest ]
os: [ ubuntu-latest, windows-latest ]
steps:
- uses: actions/checkout@v4
- name: Set up PDM
uses: pdm-project/setup-pdm@v4
with:
cache: true
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: pdm install
run: pdm sync -G test
- name: Run tests
run: pdm run -v test
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ coverage.xml
.hypothesis/
.pytest_cache/
cover/
.pytest_status

# Translations
*.mo
Expand Down Expand Up @@ -163,7 +164,8 @@ cython_debug/
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
.idea/

# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

Expand Down
32 changes: 32 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
default_install_hook_types: [ pre-commit, commit-msg ]
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0 # Use the latest version available
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files
- id: check-merge-conflict

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.1 # Use the desired version of ruff
hooks:
- id: ruff
files: ^src/|^tests/
args: [ --exit-non-zero-on-fix ]

- repo: local
hooks:
- id: pytest-status
name: pytest-status
description: "Make sure all tests have passed since last source code change."
entry: pdm run python _pre_commit_checks.py
args: [ --pytest-status ]
language: system
pass_filenames: false
require_serial: true

- repo: https://github.com/commitizen-tools/commitizen
rev: v3.29.0
hooks:
- id: commitizen
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Changes should automatically show up here when using `cz bump`.
46 changes: 18 additions & 28 deletions docs/CONTRIBUTING.md → CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
## Contributing to `amisc`
## Contributing to amisc
You might be here if you want to:

- Report a bug
- Discuss the current state of the code
- Submit a fix
- Propose a new feature
- Write unit tests
- Add to the documentation
- Add to the documentation.

We use [Github](https://guides.github.com/introduction/flow/index.html) to host code and documentation, to track issues and feature requests, and to accept pull requests.

## Submitting pull requests
Pull requests are the best way to propose changes to the codebase (bug fixes, new features, docs, etc.)

1. Fork the repo and create your branch from `main`.
3. If you are adding a feature or making major changes, first create the [issue](https://github.com/eckelsjd/amisc/issues).
4. If you've added code that should be tested, add to `/tests`.
5. If you've made major changes, update the `/docs`.
6. Ensure the test suite passes (`pdm run test`).
7. Make sure your code passes lint checks (coming soon).
8. Follow [Conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) guidelines when adding a commit message.
9. Issue that pull request!
1. Fork the repo and create a branch from `main`.
1. If you are adding a feature or making major changes, first create the issue in Github.
1. If you've added code that should be tested, add to `/tests`.
1. If you've made major changes, update the `/docs`.
1. Ensure the test suite passes (`pdm run test`).
1. Follow [Conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) guidelines when adding a commit message.
1. Ensure all `pre-commit` checks pass. Pro tip: use `pdm lint` to help.
1. Issue the pull request!

We strongly recommend using [pdm](https://github.com/pdm-project/pdm) to set up your development environment. An example contribution workflow is shown here:
Use [pdm](https://github.com/pdm-project/pdm) to set up your development environment. An example contribution workflow is shown here:

```shell
pip install --user pdm

# Fork the repo on Github

git clone https://github.com/<your-user-name>/amisc.git
cd amisc
pdm install
Expand All @@ -38,38 +35,31 @@ git checkout -b <your-branch-name>

pdm run test # make sure tests pass
git add -A
git commit -m "Adding a bugfix or new feature"
git commit -m "fix: adding a bugfix"
git push -u origin <your-branch-name>

# Go to Github and "Compare & Pull Request" on your fork
# For your PR to be merged:
# squash all your commits on your branch (interactively in an IDE most likely)
# rebase to the top of origin/main to include new changes from others

git fetch
git rebase -i main your-branch # for example

# Resolve any conflicts
# Your history now looks something like this:
# o your-branch
# /
# ---o---o---o main
# You can delete the branch and fork when your PR has been merged

# You can delete the branch and fork when your PR has been merged!
```

You can also find a good tutorial [here](https://github.com/firstcontributions/first-contributions/tree/main).

## Report bugs using [issues](https://github.com/eckelsjd/amisc/issues)
## Report bugs using issues
Open a new issue and describe your problem using the template. Provide screenshots where possible and example log files.
Add labels to help categorize and describe your issue.

## Community
Start or take part in community [discussions](https://github.com/eckelsjd/amisc/discussions) for non-code related things.

## License
By contributing, you agree that your contributions will be licensed under its GNU GPLv3 License.

## Releases
The package version is tracked at `amisc.__init__.__version__`. You should not edit this value. The version will be
increased on a case-by-case basis and released depending on the changes being merged.
By contributing, you agree that your contributions will be licensed under the GPL-3.0 license.
Loading

0 comments on commit 993371d

Please sign in to comment.