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

Circleci #11

Merged
merged 8 commits into from
Sep 20, 2023
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
135 changes: 135 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
version: 2.1

orbs:
python: circleci/[email protected]

jobs:
black:
resource_class: small
parameters:
python-version:
type: string
docker:
- image: cimg/python:<< parameters.python-version >>

steps:
- checkout

- restore_cache:
name: Restore cached black venv
keys:
- v1-pypi-py-black-<< parameters.python-version >>

- run:
name: Update & Activate black venv
command: |
python -m venv env/
. env/bin/activate
python -m pip install --upgrade pip
pip install black

- save_cache:
name: Save cached black venv
paths:
- "env/"
key: v1-pypi-py-black-<< parameters.python-version >>

- run:
name: Black format check
command: |
. env/bin/activate
python -m black --exclude '(env|venv|.eggs)' --check .

build-and-test:
resource_class: medium
parallelism: 2
parameters:
python-version:
type: string
docker:
- image: cimg/python:<< parameters.python-version >>

steps:
- checkout

- restore_cache:
name: Restore cached venv
keys:
- v1-pypi-py<< parameters.python-version >>-{{ checksum "requirements.txt" }}
- v1-pypi-py<< parameters.python-version >>

- run:
name: Update & Activate venv
command: |
python -m venv env/
. env/bin/activate
python -m pip install --upgrade pip
pip install .

- save_cache:
name: Save cached venv
paths:
- "env/"
key: v1-pypi-py<< parameters.python-version >>-{{ checksum "requirements.txt" }}

- run:
name: Install subnet1
command: |
. env/bin/activate
pip install -e .

check-version-updated:
docker:
- image: cimg/python:3.10
steps:
- checkout

- run:
name: Version is updated
command: |
[[ $(git diff-tree --no-commit-id --name-only -r HEAD..main | grep openminers/__init__.py | wc -l) == 1 ]] && echo "openminers/__init__.py has changed"
[[ $(git diff-tree --no-commit-id --name-only -r HEAD..main | grep VERSION | wc -l) == 1 ]] && echo "VERSION has changed"

check-changelog-updated:
docker:
- image: cimg/python:3.10
steps:
- checkout
- run:
name: File CHANGELOG.md is updated
command: |
[[ $(git diff-tree --no-commit-id --name-only -r HEAD..main | grep CHANGELOG.md | wc -l) == 1 ]] && echo "CHANGELOG.md has changed"

check-version-not-released:
docker:
- image: cimg/python:3.10
steps:
- checkout
- run:
name: Git tag does not exist for the current version
command: |
[[ $(git tag | grep `cat VERSION` | wc -l) == 0 ]] && echo "VERSION is not a tag"


workflows:
pr-requirements:
jobs:
- black:
python-version: "3.8.12"
- build-and-test:
matrix:
parameters:
python-version: ["3.8.14", "3.9.13", "3.10.6"]

release-branches-requirements:
jobs:
- check-version-updated:
filters:
branches:
only:
- /^(release|hotfix)/.*/
- check-changelog-updated:
filters:
branches:
only:
- /^(release|hotfix)/.*/
Loading