diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml index b3489f2..0b86fd4 100644 --- a/.github/workflows/black.yml +++ b/.github/workflows/black.yml @@ -1,10 +1,9 @@ name: Black -on: [push, pull_request] +on: [workflow_call] jobs: black: - if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository runs-on: ubuntu-latest steps: diff --git a/.github/workflows/branch.yml b/.github/workflows/branch.yml new file mode 100644 index 0000000..1fa0ebc --- /dev/null +++ b/.github/workflows/branch.yml @@ -0,0 +1,15 @@ +name: Check branch commit + +on: + push: + branches: + - '**' # matches every branch ... + - '!main' # ... that is not main + +jobs: + isort: + uses: ./.github/workflows/isort.yml + black: + uses: ./.github/workflows/black.yml + build: + uses: ./.github/workflows/build.yml diff --git a/.github/workflows/main.yaml b/.github/workflows/build.yml similarity index 87% rename from .github/workflows/main.yaml rename to .github/workflows/build.yml index e779d50..0019605 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/build.yml @@ -1,13 +1,12 @@ name: Test BSB NEST adapter -on: [push, pull_request] +on: [workflow_call] env: NEST_VERSION: 3.6 jobs: build: - if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository runs-on: ubuntu-latest strategy: matrix: @@ -40,9 +39,10 @@ jobs: run: | pip install --upgrade pip # Install self, with test dependencies - pip install .[test,parallel] + pip install .[test] + - name: Run tests & coverage run: | source ${{ github.workspace }}/simulators/nest/bin/nest_vars.sh coverage run -p -m unittest discover -v -s ./tests - mpiexec -n 2 coverage run -p -m unittest discover -v -s ./tests \ No newline at end of file + mpiexec -n 2 coverage run -p -m unittest discover -v -s ./tests diff --git a/.github/workflows/isort.yml b/.github/workflows/isort.yml index ed77430..6e61454 100644 --- a/.github/workflows/isort.yml +++ b/.github/workflows/isort.yml @@ -1,6 +1,6 @@ name: Run isort -on: - - push + +on: [workflow_call] jobs: isort: @@ -17,4 +17,4 @@ jobs: sudo apt install openmpi-bin libopenmpi-dev # Install dependencies for proper 1st/2nd/3rd party import sorting - run: pip install -e .[parallel] - - uses: isort/isort-action@master \ No newline at end of file + - uses: isort/isort-action@v1.1.0 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..4d473bb --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,155 @@ +name: Bump version, create release and deploy + +on: + push: + branches: + - main + +jobs: + isort: + uses: ./.github/workflows/isort.yml + black: + uses: ./.github/workflows/black.yml + build: + uses: ./.github/workflows/build.yml + + tag_release: + needs: [isort, black, build] + runs-on: ubuntu-latest + outputs: + tag: ${{ steps.semver.outputs.next }} + old_tag: ${{ steps.semver.outputs.current }} + + steps: + - name: Create Github token + uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ vars.DBBS_APP_ID }} + private-key: ${{ secrets.DBBS_APP_PRIVATE_KEY }} + + - name: Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ steps.app-token.outputs.token }} + + - name: Get Next Version + id: semver + uses: ietf-tools/semver-action@v1 + with: + token: ${{ steps.app-token.outputs.token }} + branch: main + + - name: Set up Python 3.11 + uses: actions/setup-python@v1 + with: + python-version: 3.11 + + - name: Bump version in Python project + run: | + pip install --upgrade pip bump-my-version + oldv="${{ steps.semver.outputs.current }}" + newv="${{steps.semver.outputs.next}}" + # Bump the version, dropping the leading `v` with `${x:1}` + bump-my-version replace --current-version=${oldv:1} --new-version=${newv:1} pyproject.toml + + - name: Commit & Push version change + uses: stefanzweifel/git-auto-commit-action@v4 + with: + branch: main + commit_message: 'docs: bump version: ${{ steps.semver.outputs.current }} → ${{ steps.semver.outputs.next }} [skip ci]' + + - name: Create tag + uses: rickstaa/action-create-tag@v1 + with: + tag: ${{ steps.semver.outputs.next }} + github_token: ${{ steps.app-token.outputs.token }} + + release: + runs-on: ubuntu-latest + needs: tag_release + + steps: + - name: Create Github token + uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ vars.DBBS_APP_ID }} + private-key: ${{ secrets.DBBS_APP_PRIVATE_KEY }} + + - name: Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ steps.app-token.outputs.token }} + + - name: Pull commit of version change + run: | + git pull origin main + + - name: Update CHANGELOG + id: changelog + uses: requarks/changelog-action@v1 + with: + token: ${{ steps.app-token.outputs.token }} + fromTag: ${{ needs.tag_release.outputs.tag }} + toTag: ${{ needs.tag_release.outputs.old_tag }} + + - name: Create Release + uses: ncipollo/release-action@v1.12.0 + with: + allowUpdates: true + draft: false + makeLatest: true + tag: ${{ needs.tag_release.outputs.tag }} + name: ${{ needs.tag_release.outputs.tag }} + body: ${{ steps.changelog.outputs.changes }} + token: ${{ steps.app-token.outputs.token }} + + - name: Commit CHANGELOG.md + uses: stefanzweifel/git-auto-commit-action@v4 + with: + branch: main + commit_message: 'docs: update CHANGELOG.md for ${{ github.ref_name }} [skip ci]' + file_pattern: CHANGELOG.md + + pypi-publish: + runs-on: ubuntu-latest + needs: release + environment: + name: pypi + url: https://pypi.org/p/bsb-nest + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + steps: + - name: Create Github token + uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ vars.DBBS_APP_ID }} + private-key: ${{ secrets.DBBS_APP_PRIVATE_KEY }} + + - name: Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ steps.app-token.outputs.token }} + + - name: Pull commits of version bump + run: | + git pull origin main + + - name: Set up Python 3.11 + uses: actions/setup-python@v5 + with: + python-version: 3.11 + + - name: Install dependencies and build dist + run: | + python -m pip install --upgrade pip + pip install build + python -m build + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 0000000..9668a6a --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,14 @@ +name: Validate Pull Request + +on: + pull_request: + types: [opened, synchronize, reopened, edited] + +jobs: + validate-pr-title: + runs-on: ubuntu-latest + steps: + - name: PR Conventional Commit Validation + uses: ytanikin/PRConventionalCommits@1.2.0 + with: + task_types: '["feat","fix","docs","test","ci","refactor","perf","revert"]' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 748ece2..33153b1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,6 @@ +default_install_hook_types: + - pre-commit + - commit-msg repos: - repo: https://github.com/psf/black-pre-commit-mirror rev: 24.1.1 @@ -7,4 +10,11 @@ repos: rev: 5.12.0 hooks: - id: isort - name: isort (python) \ No newline at end of file + name: isort (python) + - repo: https://github.com/compilerla/conventional-pre-commit + rev: v3.3.0 + hooks: + - id: conventional-pre-commit + name: conventional-commit + stages: [ commit-msg ] + args: [ ] diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..0781e08 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,10 @@ +## v4.1.0 + +### What's Changed +* Feature/randomness by @drodarie in https://github.com/dbbs-lab/bsb-nest/pull/7 +* Feature/devices by @drodarie in https://github.com/dbbs-lab/bsb-nest/pull/5 + +### New Contributors +* @drodarie made their first contribution in https://github.com/dbbs-lab/bsb-nest/pull/7 + +**Full Changelog**: https://github.com/dbbs-lab/bsb-nest/compare/v4.0.0...v4.1.0 diff --git a/README.md b/README.md index 44584c9..d2a4922 100644 --- a/README.md +++ b/README.md @@ -1 +1,9 @@ +[![Build Status](https://github.com/dbbs-lab/bsb-nest/actions/workflows/build.yml/badge.svg)](https://github.com/dbbs-lab/bsb-nest/actions/workflows/build.yml) +[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) + # bsb-nest + +bsb-nest is a pluggin of [BSB](https://github.com/dbbs-lab/bsb) (see also +[bsb-core](https://github.com/dbbs-lab/bsb-core)). +It contains the interfaces and tools to simulate BSB circuit with the +[NEST simulator](https://www.nest-simulator.org/). diff --git a/pyproject.toml b/pyproject.toml index e5557fa..2273db8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,6 +20,7 @@ nest = "bsb_nest" [project.optional-dependencies] parallel = ["bsb-core[parallel]"] test = [ + "bsb-core[parallel]", "bsb-test~=4.0", "bsb-hdf5~=4.0", # Required to load the Brunel config file @@ -27,10 +28,14 @@ test = [ "coverage~=7.0" ] dev = [ + "bsb-nest[test]", + "build~=1.0", + "twine~=4.0", "pre-commit~=3.5", - "black~=24.0", + "black~=24.1.1", "isort~=5.12", - "bump-my-version~=0.18" + "snakeviz~=2.1", + "bump-my-version~=0.24" ] [tool.black]