Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Enable CI and setup all logistics #15

Merged
merged 35 commits into from
Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
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
278 changes: 258 additions & 20 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,264 @@
# Use the latest 2.1 version of CircleCI pipeline process engine.
# See: https://circleci.com/docs/2.0/configuration-reference
version: 2.1

# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
jobs:
say-hello:
# Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
# See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor
docker:
- image: cimg/base:stable
# Add steps to the job
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
steps:
- checkout
- run:
name: "Say hello"
command: "echo Hello, World!"
build_doc:
docker:
- image: cimg/base:stable-20.04
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/dodiscover.git
fi
git remote set-url upstream https://github.com/py-why/dodiscover.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: Set BASH_ENV
command: |
set -e
sudo apt install -qq graphviz optipng python3.8-venv python3-venv libxft2
python3.8 -m venv ~/python_env
echo "set -e" >> $BASH_ENV
echo "export OPENBLAS_NUM_THREADS=4" >> $BASH_ENV
echo "export XDG_RUNTIME_DIR=/tmp/runtime-circleci" >> $BASH_ENV
echo "export PATH=~/.local/bin/:$PATH" >> $BASH_ENV
echo "export DISPLAY=:99" >> $BASH_ENV
echo "source ~/python_env/bin/activate" >> $BASH_ENV
mkdir -p ~/.local/bin
ln -s ~/python_env/bin/python ~/.local/bin/python
echo "BASH_ENV:"
cat $BASH_ENV
- run:
name: Setup pandoc
command: sudo apt update && sudo apt install -y pandoc optipng
- restore_cache:
name: Restore pip cache
keys:
- pip-cache
- restore_cache:
name: Restore install-bin-cache
keys:
- user-install-bin-cache
- run:
name: Get Python running and install dependencies
command: |
python -m pip install --progress-bar off --upgrade pip setuptools wheel poetry
python -m poetry install --extras docs --quiet
- save_cache:
name: Save pip cache
key: pip-cache
paths:
- ~/.cache/pip
- save_cache:
name: Save install-bin-cache
key: user-install-bin-cache
paths:
- ~/.local/lib/python3.8/site-packages
- ~/.local/bin
- run:
name: Check poetry package versions
command: |
poetry --version
poetry show
- run:
name: Check installation
command: |
LIBGL_DEBUG=verbose python -c "import matplotlib.pyplot as plt; plt.figure()"
python -c "import dodiscover;"
python -c "import numpy; numpy.show_config()"
- run:
name: Build documentation
command: |
cd doc
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"
docker:
- image: cimg/python:3.9.2
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
- restore_cache:
keys:
- pip-cache
- run:
name: Get Python running
command: |
python -m pip install --progress-bar off --upgrade pip setuptools wheel
python -m pip install --progress-bar off .[doc]
- 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:
- "b5:1e:a1:6d:8d:48:f2:8f:dd:bd:2d:66:a9:30:fe:b9"
- 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;

# Invoke jobs via workflows
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
workflows:
say-hello-workflow:
default:
jobs:
- build_doc:
name: build_doc
- linkcheck:
name: linkcheck
- deploy:
requires:
- build_doc
filters:
branches:
only:
- main
- maint/0.2

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:
- say-hello
- 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
1 change: 1 addition & 0 deletions .codespellignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
raison
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
docs

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/dodiscover/blob/main/CONTRIBUTING.md#bug-reports-and-feature-requests) on reporting bugs.
- [ ] I have checked the [issues list](https://github.com/py-why/dodiscover/issues) for similar or identical bug reports.
- [ ] I have checked the [pull requests list](https://github.com/py-why/dodiscover/pulls) for existing proposed fixes.
- [ ] I have checked the [CHANGELOG](https://github.com/py-why/dodiscover/blob/main/CHANGELOG.md) and the [commit log](https://github.com/py-why/dodiscover/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>
Loading