diff --git a/.github/workflows/actions.yaml b/.github/workflows/actions.yaml index e9edeff..2c9e8de 100644 --- a/.github/workflows/actions.yaml +++ b/.github/workflows/actions.yaml @@ -12,10 +12,17 @@ jobs: - name: Install dependencies run: | pip install --upgrade pip - pip install -r requirements.txt --index-url https://gitlab.mpcdf.mpg.de/api/v4/projects/2187/packages/pypi/simple + pip install '.[dev]' --index-url https://gitlab.mpcdf.mpg.de/api/v4/projects/2187/packages/pypi/simple + pip install coverage coveralls - name: Test with pytest run: | - python -m pytest -sv tests + python -m coverage run -m pytest -sv + - name: Submit to coveralls + continue-on-error: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + coveralls --service=github - name: Test with nomad run: | python -m nomad.cli parse tests/data/test.archive.yaml @@ -38,3 +45,17 @@ jobs: - name: Test with nomad run: | python -m nomad.cli parse tests/data/test.archive.yaml + ruff-linting: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: chartboost/ruff-action@v1 + with: + args: "check ." + # ruff-formatting: + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v3 + # - uses: chartboost/ruff-action@v1 + # with: + # args: "format ." diff --git a/.github/workflows/mkdocs-deploy.yml b/.github/workflows/mkdocs-deploy.yml new file mode 100644 index 0000000..a6c4d41 --- /dev/null +++ b/.github/workflows/mkdocs-deploy.yml @@ -0,0 +1,28 @@ +name: Deploy MkDocs Site + +on: + push: + branches: + - main # Triggers deployment on push to the main branch + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install mkdocs mkdocs-material==8.1.1 pymdown-extensions mkdocs-click + + - name: Build and Deploy + run: | + mkdocs gh-deploy --force --remote-branch gh-pages diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..f7fcff6 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,84 @@ +# Upload python package to pypi server and github release. +# Reference: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ + +name: Upload Python Package + +on: + release: + types: [published] + +jobs: + # publish-to-pypi: + # name: >- + # Publish distribution to PyPI + # runs-on: ubuntu-latest + # environment: + # name: pypi + # url: https://pypi.org/p/nomad-schema-plugin-example + # permissions: + # id-token: write # IMPORTANT: mandatory for trusted publishing + # + # steps: + # - uses: actions/checkout@v4 + # - name: Set up Python + # uses: actions/setup-python@v4 + # with: + # python-version: "3.9" + # - name: Install pypa/build + # run: >- + # python3 -m + # pip install + # build + # --user + # - name: Build a binary wheel and a source tarball + # run: python3 -m build + # - name: Publish distribution to PyPI + # uses: pypa/gh-action-pypi-publish@release/v1 + + github-release: + name: >- + Sign the Python distribution with Sigstore + and upload them to GitHub Release + runs-on: ubuntu-latest + permissions: + contents: write # IMPORTANT: mandatory for making GitHub Releases + id-token: write # IMPORTANT: mandatory for sigstore + + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.9" + - name: Install pypa/build + run: >- + python3 -m + pip install + build + --user + - name: Build a binary wheel and a source tarball + run: python3 -m build + - name: Sign the dists with Sigstore + uses: sigstore/gh-action-sigstore-python@v1.2.3 + with: + inputs: >- + ./dist/*.tar.gz + ./dist/*.whl + - name: Create GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + run: >- + gh release create + '${{ github.ref_name }}' + --repo '${{ github.repository }}' + --notes "" + - name: Upload artifact signatures to GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + # Upload to GitHub Release using the `gh` CLI. + # `dist/` contains the built packages, and the + # sigstore-produced signatures and certificates. + run: >- + gh release upload + '${{ github.ref_name }}' dist/** + --repo '${{ github.repository }}' diff --git a/README.md b/README.md index ad96bc4..a711deb 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ + + + # NOMAD's schema example plugin ## Getting started @@ -25,13 +28,13 @@ You need at least Python 3.9. ```sh python3 -m venv .pyenv source .pyenv/bin/activate -pip install -r requirements.txt --index-url https://gitlab.mpcdf.mpg.de/api/v4/projects/2187/packages/pypi/simple +pip install --upgrade pip +pip install '.[dev]' --index-url https://gitlab.mpcdf.mpg.de/api/v4/projects/2187/packages/pypi/simple ``` **Note!** Until we have an official pypi NOMAD release with the plugins functionality. Make -sure to include NOMAD's internal package registry (e.g. via `--index-url`). Follow the instructions -in `requirements.txt`. +sure to include NOMAD's internal package registry (e.g. via `--index-url`). ### Run the tests @@ -47,6 +50,20 @@ You can run automated tests with `pytest`: pytest -svx tests ``` +### Run linting + +```sh +ruff check . +``` + +### Run auto-formatting + +This is entirely optional. To add this as a check in github actions pipeline, uncomment the `ruff-formatting` step in `./github/workflows/actions.yaml`. + +```sh +ruff format . +``` + You can parse an example archive that uses the schema with `nomad` (installed via `nomad-lab` Python package): @@ -63,7 +80,6 @@ You can now start to develop you schema. Here are a few things that you might wa - The name of the example section `ExampleSection`. You will also want to define more than one section. - When you change module and class names, make sure to update the `nomad_plugin.yaml` accordingly. - ## Build the python package The `pyproject.toml` file contains everything that is necessary to turn the project @@ -83,8 +99,7 @@ pip install dist/nomad-schema-plugin-example-1.0.tar.gz Read more about python packages, `pyproject.toml`, and how to upload packages to PyPI on the [PyPI documentation](https://packaging.python.org/en/latest/tutorials/packaging-projects/). - ## Next steps To learn more about plugins, how to add them to an Oasis, how to publish them, read our -documentation on plugins: https://nomad-lab.eu/docs/plugins/plugins.html. \ No newline at end of file +documentation on plugins: https://nomad-lab.eu/docs/plugins/plugins.html. diff --git a/docs/assets/.gitignore b/docs/assets/.gitignore new file mode 100644 index 0000000..3881e38 --- /dev/null +++ b/docs/assets/.gitignore @@ -0,0 +1 @@ +nomad-oasis*.zip \ No newline at end of file diff --git a/docs/assets/favicon.png b/docs/assets/favicon.png new file mode 100644 index 0000000..f84c78f Binary files /dev/null and b/docs/assets/favicon.png differ diff --git a/docs/assets/nomad-plugin-logo.png b/docs/assets/nomad-plugin-logo.png new file mode 100644 index 0000000..149856c Binary files /dev/null and b/docs/assets/nomad-plugin-logo.png differ diff --git a/docs/explanation/explanation.md b/docs/explanation/explanation.md new file mode 100644 index 0000000..d4f6235 --- /dev/null +++ b/docs/explanation/explanation.md @@ -0,0 +1,4 @@ +# Explanation + +!!! note "Attention" + Please update the document with relevant information specific to your plugin. diff --git a/docs/how_to/contribute_to_the_documentation.md b/docs/how_to/contribute_to_the_documentation.md new file mode 100644 index 0000000..1234cb7 --- /dev/null +++ b/docs/how_to/contribute_to_the_documentation.md @@ -0,0 +1,4 @@ +# Contribute to the documentation + +!!! note "Attention" + Please update the document with relevant information specific to your plugin. diff --git a/docs/how_to/contribute_to_this_plugin.md b/docs/how_to/contribute_to_this_plugin.md new file mode 100644 index 0000000..4e67d7a --- /dev/null +++ b/docs/how_to/contribute_to_this_plugin.md @@ -0,0 +1,5 @@ +# Contribute to This Plugin + +!!! note "Attention" + Please update the document with relevant information specific to your plugin. + diff --git a/docs/how_to/install_this_plugin.md b/docs/how_to/install_this_plugin.md new file mode 100644 index 0000000..7d0c2ca --- /dev/null +++ b/docs/how_to/install_this_plugin.md @@ -0,0 +1,4 @@ +# Install This Plugin + +!!! note "Attention" + Please update the document with relevant information specific to your plugin. diff --git a/docs/how_to/use_this_plugin.md b/docs/how_to/use_this_plugin.md new file mode 100644 index 0000000..4adc378 --- /dev/null +++ b/docs/how_to/use_this_plugin.md @@ -0,0 +1,10 @@ +# How to Use This Plugin + +This plugin can be used in a NOMAD Oasis instalation.. + +## Add This Plugin to Your NOMAD instalation + +Read the [NOMAD plugin documentation](https://nomad-lab.eu/prod/v1/staging/docs/plugins/plugins.html#add-a-plugin-to-your-nomad) for all details on how to deploy the plugin on your NOMAD instance. + +!!! note "Attention" + Please update the document with relevant information specific to your plugin. diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..314cf62 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,50 @@ +# Welcome to the `nomad-schema-plugin-example` documentation + +Short summary about your plugin + +## Introduction + +This is a example plugin. + +!!! note "Attention" + Please update the document with relevant information specific to your plugin. + +