Skip to content

Commit

Permalink
Improving setup (#15)
Browse files Browse the repository at this point in the history
* Deleted launch.json

* Restructure project and changed setup configuration

Added steps in README

* Improved pipeline

* Deleted requirements

* Ruff formatted python modules

* Fixed mypy

* Fixed imports with new src/pyssmf structure

Added missing dev dependencies

* Deleted work_dir
  • Loading branch information
JosePizarro3 authored May 28, 2024
1 parent 63e3653 commit 20e4a6a
Show file tree
Hide file tree
Showing 30 changed files with 511 additions and 532 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: install-and-test
on: [push]
jobs:
install-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
pip install --upgrade pip
pip install '.[dev]'
- name: mypy
run: |
python -m mypy --ignore-missing-imports --follow-imports=silent --no-strict-optional src/pyssmf tests
- name: Test with pytest
run: |
python -m pytest -sv tests
build-and-install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Build the package
run: |
pip install --upgrade pip
pip install build
python -m build --sdist
- name: Install the package
run: |
pip install dist/*.tar.gz
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 . --check --verbose"
63 changes: 0 additions & 63 deletions .github/workflows/build.yml

This file was deleted.

41 changes: 41 additions & 0 deletions .github/workflows/mkdocs-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: deploy-mkdocs
on:
push:
branches:
- develop # Triggers deployment on push to the main branch
jobs:
deploy:
runs-on: ubuntu-latest
needs: build # This ensures that the deployment job runs after the build job
if: github.ref == 'refs/heads/develop' # Only deployed for the develop branch
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- uses: actions/cache@v3
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-
mkdocs-bibtex-
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install mkdocs mkdocs-material==8.1.1 pymdown-extensions mkdocs-click
- name: Build MKDocs Documentation
run: mkdocs build --verbose
- name: Deploy MKDocs to GitHub Pages
run: |
if [ -n "$GITHUB_TOKEN" ]; then
mkdocs gh-deploy --force
else
echo "Set the GH_PAGES_TOKEN secret in your repository for deploying to GitHub Pages."
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GH_PAGES_TOKEN }}
82 changes: 82 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# 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-to-pypi
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/[email protected]
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 }}'
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Debugging python script
debug.py
work_dir/
work_dir/*
work_dir*

# VSCode debugger
.vscode/launch.json

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
66 changes: 0 additions & 66 deletions .vscode/launch.json

This file was deleted.

34 changes: 22 additions & 12 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
{
"python.defaultInterpreterPath": "${workspaceFolder}/.pyenv/bin/python",
"python.defaultInterpreterPath": ".pyenv/bin/python",
"python.terminal.activateEnvInCurrentTerminal": true,
"[python]": {
"editor.rulers": [
90
],
"editor.renderWhitespace": "all",
"editor.tabSize": 4,
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true,
"editor.rulers": [90],
"editor.renderWhitespace": "all",
"editor.tabSize": 4,
"[javascript]": {
"editor.tabSize": 2
},
"ruff.lint.args": ["--select=E,W,F,PL", "--ignore=E501,E701,E731,E402,PLR0911,PLR0912,PLR0913,PLR0915,PLR2004,PLW0603,PLW2901,PLR1714,PLR5501", "--exclude=__init__.py"]
}

"files.trimTrailingWhitespace": true,
"files.watcherExclude": {
"${workspaceFolder}/.pyenv/**": true
},
"files.exclude": {
"\"**/*.pyc\": {\"when\": \"$(basename).py\"}": true,
"**/__pycache__": true,
"**/node_modules": true
},
"python.testing.pytestPath": "pytest",
"python.testing.pytestArgs": ["tests"],
"python.testing.unittestEnabled": false,
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true
}

26 changes: 0 additions & 26 deletions Makefile

This file was deleted.

Loading

0 comments on commit 20e4a6a

Please sign in to comment.