Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/SMTG-UCL/ShakeNBreak int…
Browse files Browse the repository at this point in the history
…o develop
  • Loading branch information
ireaml committed Sep 25, 2023
2 parents a2b32ba + dae2d0a commit 4901906
Show file tree
Hide file tree
Showing 138 changed files with 298,616 additions and 299,816 deletions.
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: pip
directory: "/"
schedule:
interval: daily
groups:
python-packages:
patterns:
- "*"
open-pull-requests-limit: 2
allow:
- dependency-type: direct
- dependency-type: indirect
67 changes: 0 additions & 67 deletions .github/workflows/build_and_test.yml

This file was deleted.

11 changes: 3 additions & 8 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install setuptools setuptools_scm wheel
pip install numpy
pip install pydocstyle
pip install black
pip install flake8
pip install isort
pip install -e .
pip install pydocstyle black flake8 isort
pip install -e .[tests]
- name: sort imports
Expand All @@ -51,8 +46,8 @@ jobs:
- name: black
run: |
black --version
black --line-length 88 --color shakenbreak
black --line-length 88 --check --diff --color shakenbreak
black --color shakenbreak
black --check --diff --color shakenbreak
- name: flake8
run: |
Expand Down
35 changes: 22 additions & 13 deletions .github/workflows/pip_install_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@ on:
branches: [main]
types:
- completed # only test when new release has been deployed to PyPI
workflow_dispatch:

jobs:
build-linux:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') }}
# only run when tests have passed (or manually triggered)

strategy:
max-parallel: 5

matrix:
python-version: ['3.8', '3.9', '3.10']
python-version: ['3.8', '3.9', '3.10', '3.11']

name: Python ${{ matrix.python-version }} pip install

Expand All @@ -30,17 +33,23 @@ jobs:
run: |
sleep 10m # wait 10 minutes for PyPI to update with the new release
python -m pip install --upgrade pip
pip install shakenbreak # install only from PyPI
pip install shakenbreak[tests]
pip install shakenbreak[tests] # install only from PyPI
- name: Test
run: |
for test in tests/test_*py
do if [[ "$test" != *"test_local"* ]]
then pytest $test
fi
done # Ignore local tests file, which tests INCAR and POTCAR file writing but not possible on GitHub Actions
pytest --mpl tests/test_shakenbreak.py # test output plots
pytest --mpl tests/test_plotting.py # test output plots
# pytest --mpl-generate-path=tests/remote_baseline tests/test_plotting.py # generate output plots
# pytest --mpl-generate-path=tests/remote_baseline tests/test_shakenbreak.py # generate output plots
pytest --mpl -vv tests # test everything
- name: Generate GH Actions test plots
if: always() # always generate the plots, even if the tests fail
run: |
# Generate the test plots in case there were any failures:
pytest --mpl-generate-path=tests/remote_baseline tests/test_plotting.py
pytest --mpl-generate-path=tests/remote_baseline tests/test_shakenbreak.py
# Upload test plots
- name: Archive test plots
if: always() # always upload the plots, even if the tests fail
uses: actions/upload-artifact@v3
with:
name: output-plots
path: tests/remote_baseline
39 changes: 14 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
name: Release and publish

on:
push:
branches:
- main
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
workflow_run:
workflows: [ "Tests" ]
branches: [ main ]
types:
- completed # only release when tests have passed

workflow_dispatch:

jobs:
release:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') }}
# only run when tests have passed (or manually triggered)

steps:
- uses: actions/checkout@v1
Expand All @@ -22,46 +26,31 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install setuptools setuptools_scm wheel
pip install numpy
pip install -e .
pip install -e .[tests]
- name: Test
run: |
for test in tests/test_*py
do if [[ "$test" != *"test_local"* ]]
then pytest $test
fi
done # Ignore local tests file, which tests INCAR and POTCAR file writing but not possible on GitHub Actions
pytest --mpl tests/test_shakenbreak.py # test output plots
pytest --mpl tests/test_plotting.py # test output plots
- name: Build packages
run: |
python setup.py sdist bdist_wheel
- name: Generate release tag
uses: amitsingh-007/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Publish
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.TWINE_PASSWORD }}

- name: Write release info
- name: Generate release info
run: |
awk 'BEGIN {p = 0} {a = 0 }; /^v\d*.\d*.\d*./ { p += 1; a = 1}; p + a == 1 { print } ' CHANGELOG.rst | sed -e '1,1d' | sed -e '/./,$!d' -e :a -e '/^\n*$/{$d;N;ba' -e '}' > release_info.txt
echo "version=$(grep version setup.py | awk -F\" '{print $2}')" >> $GITHUB_ENV
- name: Release
uses: actions/create-release@v1
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.release_tag }}
release_name: ${{ env.release_tag }}
tag_name: v${{ env.version }}
release_name: ${{ env.version }}
body_path: release_info.txt
draft: false
prerelease: false
65 changes: 65 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Tests

on:
pull_request:
branches:
- main
- develop
push:
branches:
- main
- develop
workflow_dispatch:

jobs:
build-linux:
runs-on: ubuntu-latest
strategy:
max-parallel: 5

matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']

name: Python ${{ matrix.python-version }} Test Pop

steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[tests]
- name: Check package versions
run: |
pip show -V pymatgen-analysis-defects
pip show -V pymatgen
pip show -V pytest
- name: Test
run: |
pytest --mpl -vv tests # test everything
- name: Generate GH Actions test plots
if: always() # always generate the plots, even if the tests fail
run: |
# Generate the test plots in case there were any failures:
pytest --mpl-generate-path=tests/remote_baseline tests/test_plotting.py
pytest --mpl-generate-path=tests/remote_baseline tests/test_shakenbreak.py
# Upload test plots
- name: Archive test plots
if: always() # always upload the plots, even if the tests fail
uses: actions/upload-artifact@v3
with:
name: output-plots
path: tests/remote_baseline

# - name: Download a single artifact
# uses: actions/download-artifact@v3
# with:
# name: output-plots
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
exclude: ^(docs|tests|SnB_input_files|.github|shakenbreak/bash_scripts|CITATION*|MANIFEST*)
exclude: ^(docs|tests|SnB_input_files|.github|shakenbreak/scripts|CITATION*|MANIFEST*)
repos:


Expand All @@ -19,7 +19,7 @@ repos:

# Sort/format imports
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
args: [--profile, black]
Expand All @@ -36,7 +36,7 @@ repos:
rev: 22.6.0
hooks:
- id: black
args: [--line-length, "88", --color]
args: [--color]

# Check code formatting
- repo: https://github.com/PyCQA/flake8
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ sphinx:
# Explicitly set the version of Python and its requirements
python:
install:
- requirements: docs/requirements.txt
- requirements: docs/docs_requirements.txt
Loading

0 comments on commit 4901906

Please sign in to comment.