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

Adding Circle Ci to the template #306

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
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
3 changes: 3 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,8 @@ jobs:
- name: Install dependencies
run: poetry install

- name: Install dependencies with conda for circleci
run: conda install opensciencelabs::circleci-cli

- name: Run Smoke Test (${{ matrix.smoke_file }})
run: bash ./tests/smoke/${{ matrix.smoke_file }}
1 change: 1 addition & 0 deletions .makim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ groups:
run: |
./tests/smoke/auto-format-tools.sh
./tests/smoke/build-systems.sh
./tests/smoke/circleci.sh
./tests/smoke/cli.sh
./tests/smoke/containers.sh
./tests/smoke/docs-jupyter-book.sh
Expand Down
20 changes: 20 additions & 0 deletions docs/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -961,3 +961,23 @@ By providing this information, you can easily integrate your codebase with
GitHub and take advantage of its powerful version control features. These
functionalities in SciCookie make it easy to manage your project and collaborate
with others, while ensuring that your code is properly versioned and tracked.

## Continuos integration

Continuous Integration (CI) is a development practice where code changes are
frequently merged into a shared repository. Each change is automatically built
and tested to ensure it does not introduce defects or break existing
functionality. This process helps prevent integration issues and improves code
quality.

CI tools provide automated feedback on code changes, allowing developers to
quickly identify and fix problems. By automating repetitive tasks, CI also saves
time and effort. With SciCookie you can integrate tools like GitHub and/or
CircleCI into your project.

- GitHub Actions (**github_actions**): This option allows you to incorporate
GitHub Actions into your project. As a native CI/CD platform integrated with
GitHub, it offers flexible workflows and an easy setup process.
- CircleCI (**circleci**): This option enables you to integrate CircleCI into
your project. Known for its speed and reliability, CircleCI is a cloud-based
CI/CD platform that streamlines the development process.
4 changes: 3 additions & 1 deletion src/scicookie/cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,7 @@
"git_username": "zoro_roronoa",
"git_https_origin": "",
"git_https_upstream": "",
"git_main_branch": "main"
"git_main_branch": "main",
"use_github_actions": "no",
"use_circleci": "no"
}
10 changes: 10 additions & 0 deletions src/scicookie/hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
USE_PRE_COMMIT = {{ cookiecutter.use_pre_commit == "yes" }}
USE_PYTEST = {{ cookiecutter.use_pytest == "yes" }}
USE_HYPOTHESIS = {{ cookiecutter.use_hypothesis == "yes" }}
USE_GITHUB_ACTIONS = {{ cookiecutter.use_github_actions == "yes" }}
USE_CIRCLECI = {{ cookiecutter.use_circleci == "yes" }}
{% if cookiecutter.code_of_conduct == "contributor-covenant" -%}
COC_PATH = PROJECT_DIRECTORY / 'coc' / 'CONTRIBUTOR_COVENANT.md'
{%- elif cookiecutter.code_of_conduct == "citizen-code-of-conduct" -%}
Expand Down Expand Up @@ -96,6 +98,7 @@
{%- endif %}



def remove_dirs(dirs: list):
for dirs in dirs:
shutil.rmtree(dirs)
Expand Down Expand Up @@ -300,6 +303,12 @@ def clean_up_build_system():
remove_dir("build-system")


def clean_up_ci():
if not USE_CIRCLECI:
remove_dir(".circleci")
if not USE_GITHUB_ACTIONS:
remove_dir(".github")

def http2ssh(url):
url = url.replace("https://", "git@")
return url.replace("/", ":", 1)
Expand Down Expand Up @@ -401,6 +410,7 @@ def prepare_git() -> None:
def post_gen():
# keep this one first, because it changes the package folder
clean_up_project_layout()
clean_up_ci()
clean_up_automation()
clean_up_cli()
clean_up_code_of_conduct()
Expand Down
9 changes: 9 additions & 0 deletions src/scicookie/profiles/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,12 @@ git_main_branch:
type: "text"
default: main
visible: true

continuos_integration:
message: Select one option for Continuous Integration
help: "For more information, check:\n https://osl-incubator.github.io/scicookie/guide/#continuous-integration"
type: multiple-choices
choices:
- github_actions
- circleci
visible: true
5 changes: 5 additions & 0 deletions src/scicookie/profiles/osl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,8 @@ git_https_upstream:

git_main_branch:
visible: true

continuos_integration:
choices:
- github_actions
visible: false
82 changes: 82 additions & 0 deletions src/scicookie/{{cookiecutter.project_slug}}/.circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
version: 2.1 # Adjust if needed based on CircleCI requirements
executors:
default_image:
docker:
{%- if cookiecutter.use_conda == "yes" %}
- image: continuumio/miniconda3
jobs:
check-branch:
executor: default_image
steps:
- checkout
test:
docker:
- image: continuumio/miniconda3
steps:
- checkout
- run:
name: Create environment
command: |
conda env create -f conda/dev.yaml
conda init bash
source ~/.bashrc
conda activate {{ cookiecutter.project_slug }}
{%- else %}
- image: circleci/python:3.9 # Adjust Python version if needed
jobs:
check-branch:
executor: python/default
steps:
- checkout
- python/install-packages:
pkg-manager: pip
test:
docker:
- image: circleci/python:3.9 # Adjust Python version if needed steps:
- checkout
- run:
name: Create environment and install dependencies
command: |
python -m pip install -r requirements.txt
{%- endif %}
{%- if cookiecutter.build_system == "poetry" %}
poetry install
{%- elif cookiecutter.build_system == "flit" %}
flit install
{%- elif cookiecutter.build_system == "pdm" %}
pdm install
{%- else %}
pip install .
{%- endif %}
{%- if cookiecutter.use_pre_commit == "yes" %}
pre-commit install
{%- endif %}
{%- if cookiecutter.use_makim == "yes" %}
makim tests.unit
makim tests.linter
{%- endif %}
{%- if cookiecutter.use_make == "yes" %}
make test
make lint
{%- endif %}
{%- if cookiecutter.use_conda == "yes" %}
- save_cache:
paths:
- ~/.conda/envs/{{ cookiecutter.project_slug }}
key: conda-{% raw %}{{ checksum "conda/dev.yaml" }}{% endraw %}
{%- endif %}
workflows:
main:
jobs:
- check-branch:
filters:
branches:
only:
- main
tags: {}
- test:
filters:
branches:
only:
- main
tags: {}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ version = "{{ cookiecutter.project_version }}"
{% else %}
dynamic = ["version"]
{% endif -%}
{% if cookiecutter.build_system != "pdm" %}
requires-python = ">=3.8.1,<4"
{% else %}
requires-python = ">=3.8.6,<4"
{% endif -%}
dependencies = [
# note: add your dependencies here
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ theme:
name: mkdocs
{% else %}
name: {{ cookiecutter.mkdocs_theme }}
{% endif%}
{% endif %}
features:
- content.code.annotate
- content.tabs.link
Expand Down
9 changes: 9 additions & 0 deletions tests/profiles/test-depends-on.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -298,3 +298,12 @@ git_main_branch:
type: "text"
default: main
visible: true

continuos_integration:
message: Select one option for Continuous Integration
help: "For more information, check:\n https://osl-incubator.github.io/scicookie/guide/#continuous-integration"
type: multiple-choices
choices:
- github_actions
- circleci
visible: true
9 changes: 9 additions & 0 deletions tests/profiles/test-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,12 @@ git_main_branch:
type: "text"
default: main
visible: true

continuos_integration:
message: Select one option for Continuous Integration
help: "For more information, check:\n https://osl-incubator.github.io/scicookie/guide/#continuous-integration"
type: multiple-choices
choices:
- github_actions
- circleci
visible: true
6 changes: 6 additions & 0 deletions tests/smoke/circleci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -e

SMOKE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

. ${SMOKE_DIR}/base.sh "use_circleci=yes"
Loading