Skip to content

Commit

Permalink
Initial setup of repository (#6)
Browse files Browse the repository at this point in the history
- Adds all the CI stuff
- Adds the developer workflow copied and pasted
- Changes the name of directory to `pywhy_stats` to keep in line w/ the
Python convention that `-` is turned to `_` in package names -> import
names

---------

Signed-off-by: Adam Li <[email protected]>
  • Loading branch information
adam2392 authored Apr 10, 2023
1 parent 6090285 commit d2667af
Show file tree
Hide file tree
Showing 47 changed files with 7,092 additions and 93 deletions.
247 changes: 247 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
version: 2.1

orbs:
python: circleci/[email protected]

jobs:
build_doc:
executor: python/default
steps:
- restore_cache:
name: Restore .git
keys:
- source-cache-graphs
- checkout
- run:
name: Complete checkout
command: |
if ! git remote -v | grep upstream; then
git remote add upstream https://github.com/py-why/pywhy-stats.git
fi
git remote set-url upstream https://github.com/py-why/pywhy-stats.git
git fetch upstream
- save_cache:
name: Save .git
key: source-cache-graphs
paths:
- ".git"
- run:
name: Check-skip
command: |
set -e
export COMMIT_MESSAGE=$(git log --format=oneline -n 1);
if [[ -v CIRCLE_PULL_REQUEST ]] && ([[ "$COMMIT_MESSAGE" == *"[skip circle]"* ]] || [[ "$COMMIT_MESSAGE" == *"[circle skip]"* ]]); then
echo "Skip detected, exiting job ${CIRCLE_JOB} for PR ${CIRCLE_PULL_REQUEST}."
circleci-agent step halt;
fi
- run:
name: Merge with upstream
command: |
echo $(git log -1 --pretty=%B) | tee gitlog.txt
echo ${CI_PULL_REQUEST//*pull\//} | tee merge.txt
if [[ $(cat merge.txt) != "" ]]; then
echo "Merging $(cat merge.txt)";
git pull --ff-only upstream "refs/pull/$(cat merge.txt)/merge";
fi
- run:
name: Install the latest version of Poetry
command: |
curl -sSL https://install.python-poetry.org | python3 - --version 1.3.0
poetry --version
- run:
name: Set BASH_ENV
command: |
set -e
sudo apt update
sudo apt-get update
echo "export OPENBLAS_NUM_THREADS=4" >> $BASH_ENV
echo "BASH_ENV:"
cat $BASH_ENV
- run:
name: Install pysal dependencies
command: |
sudo apt install libspatialindex-dev xdg-utils
- python/install-packages:
pkg-manager: poetry
args: "-E graph_func -E viz --with docs"
cache-version: "v1" # change to clear cache
- run:
name: Check poetry package versions
command: |
poetry --version
poetry show
- run:
name: Setup pandoc
command: sudo apt update && sudo apt install -y pandoc optipng
- run:
name: Check installation
command: |
poetry run python -c "import pywhy_stats;"
poetry run python -c "import numpy; numpy.show_config()"
LIBGL_DEBUG=verbose poetry run python -c "import matplotlib.pyplot as plt; plt.figure()"
- run:
name: Build documentation
command: |
cd doc
poetry run make html
# Save the example test results
- store_test_results:
path: doc/_build/test-results
- store_artifacts:
path: doc/_build/test-results
destination: test-results
# Save the SG RST
- store_artifacts:
path: doc/auto_examples.zip
- store_artifacts:
path: doc/generated.zip
# Save the outputs
- store_artifacts:
path: doc/_build/html/
destination: dev
- store_artifacts:
path: doc/_build/html_stable/
destination: stable
- persist_to_workspace:
root: doc/_build
paths:
- html
- html_stable

linkcheck:
parameters:
scheduled:
type: string
default: "false"
executor: python/default
steps:
- restore_cache:
keys:
- source-cache-graphs
- checkout
- run:
name: Check-skip
command: |
export COMMIT_MESSAGE=$(git log --format=oneline -n 1);
if [[ "$COMMIT_MESSAGE" != *"[circle linkcheck]"* ]] && [ "<< parameters.scheduled >>" != "true" ]; then
echo "Skip detected, exiting job ${CIRCLE_JOB}."
circleci-agent step halt;
fi
- run:
name: Set BASH_ENV
command: |
set -e
echo "set -e" >> $BASH_ENV
echo "export PATH=~/.local/bin/:$PATH" >> $BASH_ENV
- python/install-packages:
pkg-manager: poetry
cache-version: "v1" # change to clear cache
args: "--with docs"
- run:
name: Check poetry package versions
command: |
poetry --version
poetry show
- run:
name: make linkcheck
command: |
make -C doc linkcheck
- run:
name: make linkcheck-grep
when: always
command: |
make -C doc linkcheck-grep
- store_artifacts:
path: doc/_build/linkcheck
destination: linkcheck

deploy:
docker:
- image: cimg/node:lts
steps:
- checkout

- attach_workspace:
at: doc/_build
- run:
name: Set BASH_ENV
command: |
set -e
echo "set -e" >> $BASH_ENV
# Don't try to deploy if nothing is there or not on the right branch
- run:
name: Check docs
command: |
if [ ! -f doc/_build/html/index.html ] && [ ! -f doc/_build/html_stable/index.html ]; then
echo "No files found to upload (build: ${CIRCLE_BRANCH}).";
circleci-agent step halt;
fi;
- run:
name: Install and configure dependencies
# do not update gh-pages above 3.0.0
# see: https://github.com/tschaub/gh-pages/issues/354
command: |
npm install [email protected]
git config --global user.email "[email protected]"
git config --global user.name "Circle Ci"
- add_ssh_keys:
fingerprints:
- "2d:4e:14:8e:32:00:68:e5:f9:dd:64:17:07:3e:2c:9e"
- run:
# push built doc into the `dev` directory on the `gh-pages` branch
name: Deploy doc to gh-pages branch
command: |
if [ "${CIRCLE_BRANCH}" == "main" ]; then
echo "Deploying dev doc for ${CIRCLE_BRANCH}.";
node_modules/gh-pages/bin/gh-pages.js --dotfiles --message "doc updates [skip ci]" --dist doc/_build/html --dest ./dev
else
echo "Deploying stable doc for ${CIRCLE_BRANCH}.";
node_modules/gh-pages/bin/gh-pages.js --dotfiles --message "doc updates [skip ci]" --dist doc/_build/html_stable --dest ./stable
fi;
workflows:
default:
jobs:
- build_doc:
name: build_doc
- linkcheck:
name: linkcheck
- deploy:
requires:
- build_doc
filters:
branches:
only:
- main

main:
jobs:
- build_doc:
name: build_doc_main
- deploy:
name: deploy_main
requires:
- build_doc_main
triggers:
- schedule:
# "At 00:00" (once a day) should be enough "0 0 * * *",
# But for testing at first, let's do once an hour (6 AM GMT)
cron: "0 6 * * *"
filters:
branches:
only:
- main

weekly:
jobs:
- linkcheck:
name: linkcheck_weekly
scheduled: "true"
triggers:
- schedule:
# "At 00:00 on Sunday" should be often enough
cron: "0 0 * * 0"
filters:
branches:
only:
- main
2 changes: 2 additions & 0 deletions .codespellignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
raison
wee
26 changes: 26 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[flake8]
max-line-length = 100

ignore =
# these rules don't play well with black
# whitespace before ':'
E203
# line break before binary operator
W503
E241,E305,W504,W605,E731

exclude =
.git
.github
.venv
.mypy_cache
.pytest_cache
.circleci
paper
setup.py
doc

per-file-ignores =
# __init__.py files are allowed to have unused imports
*/__init__.py:F401
*/**/__init__.py:F401
84 changes: 84 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: 'bug'
assignees: ''

---

<!--
Please fill this template entirely and do not erase any of it.
We reserve the right to close without a response bug reports which are incomplete.
-->

## Checklist

<!-- To check an item on the list replace [ ] with [x]. -->

- [ ] I have verified that the issue exists against the `main` branch.
- [ ] I have read the relevant section in the [contribution guide](https://github.com/py-why/pywhy-stats/blob/main/CONTRIBUTING.md#bug-reports-and-feature-requests) on reporting bugs.
- [ ] I have checked the [issues list](https://github.com/py-why/pywhy-stats/issues) for similar or identical bug reports.
- [ ] I have checked the [pull requests list](https://github.com/py-why/pywhy-stats/pulls) for existing proposed fixes.
- [ ] I have checked the [CHANGELOG](https://github.com/py-why/pywhy-stats/blob/main/CHANGELOG.md) and the [commit log](https://github.com/py-why/pywhy-stats/commits/main) to find out if the bug was already fixed in the main branch.
- [ ] I have included in the "Description" section below a traceback from any exceptions related to this bug.
- [ ] I have included in the "Related issues or possible duplicates" section beloew all related issues and possible duplicate issues (If there are none, check this box anyway).
- [ ] I have included in the "Environment" section below the name of the operating system and Python version that I was using when I discovered this bug.
- [ ] I have included in the "Environment" section below the output of `pip freeze`.
- [ ] I have included in the "Steps to reproduce" section below a minimally reproducible example.


## Description

<!-- Please provide a clear and concise description of what the bug is here. -->

<details>
<summary><b>Python traceback:</b></summary>
<p>

<!-- Paste the traceback from any exception (if there was one) in between the next two lines below -->
```
```

</p>
</details>


## Related issues or possible duplicates

- None


## Environment

<!-- Provide the name of operating system below (e.g. OS X, Linux) -->
OS:

<!-- Provide the Python version you were using (e.g. 3.7.1) -->
Python version:

<details>
<summary><b>Output of <code>pip freeze</code>:</b></summary>
<p>

<!-- Paste the output of `pip freeze` in between the next two lines below -->
```
```

</p>
</details>


## Steps to reproduce


<details>
<summary><b>Example source:</b></summary>
<p>

<!-- Add a fully runnable example in between the next two lines below that will reproduce the bug -->
```
```

</p>
</details>
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: 'Feature request'
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
Loading

0 comments on commit d2667af

Please sign in to comment.