Repository: easy-graph/Easy-Graph (language: python)

Issue:
Add PyPI API key in repo settings for CI
## Who should do it?

The person controlling EasyGraph package on PyPI and the creator of GitHub org `easy-graph`, who's probably @ICYPOLE.

## Steps to take:

Go to https://pypi.org/manage/account/#api-tokens and create a new API token. If you have the project on PyPI already, limit the token scope to just that project. You can call it something like GitHub Actions CI/CD — project-org/project-repo in order for it to be easily distinguishable in the token list. Don’t close the page just yet — you won’t see that token again.

In a separate browser tab or window, go to the Settings tab of your target repository and then click on Secrets in the left sidebar.

Create a new secret called PYPI_API_TOKEN and copy-paste the token from the first step.


Discussion / hints:

Fix patch:
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
new file mode 100644
index 00000000..8d7eb7de
--- /dev/null
+++ b/.github/workflows/release.yaml
@@ -0,0 +1,41 @@
+name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
+
+on: push
+
+jobs:
+  build-n-publish:
+    name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        python-version: ["3.6", "3.7", "3.8", "3.9"]
+    steps:
+      - uses: actions/checkout@master
+      - name: Set up Python 3.9
+        uses: actions/setup-python@v1
+        with:
+          python-version: 3.9
+      - name: Install pypa/build
+        run: >-
+          python -m
+          pip install
+          build
+          --user
+      - name: Build a binary wheel and a source tarball
+        run: >-
+          python -m
+          build
+          --sdist
+          --wheel
+          --outdir dist/
+          .
+      # - name: Publish distribution 📦 to Test PyPI
+      #   uses: pypa/gh-action-pypi-publish@master
+      #   with:
+      #     password: ${{ secrets.TEST_PYPI_API_TOKEN }}
+      #     repository_url: https://test.pypi.org/legacy/
+      - name: Publish distribution 📦 to PyPI
+        # if: startsWith(github.ref, 'refs/tags')
+        uses: pypa/gh-action-pypi-publish@master
+        with:
+          password: ${{ secrets.PYPI_API_TOKEN }}
diff --git a/.gitignore b/.gitignore
index c9fc9674..505cdc18 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,163 @@
 .vscode
 __pycache__
 test/
-related-repos/
\ No newline at end of file
+related-repos/
+
+# Created by https://www.toptal.com/developers/gitignore/api/python
+# Edit at https://www.toptal.com/developers/gitignore?templates=python
+
+### Python ###
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+wheels/
+share/python-wheels/
+*.egg-info/
+.installed.cfg
+*.egg
+MANIFEST
+
+# PyInstaller
+#  Usually these files are written by a python script from a template
+#  before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.nox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*.cover
+*.py,cover
+.hypothesis/
+.pytest_cache/
+cover/
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+local_settings.py
+db.sqlite3
+db.sqlite3-journal
+
+# Flask stuff:
+instance/
+.webassets-cache
+
+# Scrapy stuff:
+.scrapy
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+.pybuilder/
+target/
+
+# Jupyter Notebook
+.ipynb_checkpoints
+
+# IPython
+profile_default/
+ipython_config.py
+
+# pyenv
+#   For a library or package, you might want to ignore these files since the code is
+#   intended to run in multiple environments; otherwise, check them in:
+# .python-version
+
+# pipenv
+#   According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
+#   However, in case of collaboration, if having platform-specific dependencies or dependencies
+#   having no cross-platform support, pipenv may install dependencies that don't work, or not
+#   install all needed dependencies.
+#Pipfile.lock
+
+# poetry
+#   Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
+#   This is especially recommended for binary packages to ensure reproducibility, and is more
+#   commonly ignored for libraries.
+#   https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
+#poetry.lock
+
+# PEP 582; used by e.g. github.com/David-OConnor/pyflow
+__pypackages__/
+
+# Celery stuff
+celerybeat-schedule
+celerybeat.pid
+
+# SageMath parsed files
+*.sage.py
+
+# Environments
+.env
+.venv
+env/
+venv/
+ENV/
+env.bak/
+venv.bak/
+
+# Spyder project settings
+.spyderproject
+.spyproject
+
+# Rope project settings
+.ropeproject
+
+# mkdocs documentation
+/site
+
+# mypy
+.mypy_cache/
+.dmypy.json
+dmypy.json
+
+# Pyre type checker
+.pyre/
+
+# pytype static type analyzer
+.pytype/
+
+# Cython debug symbols
+cython_debug/
+
+# PyCharm
+#  JetBrains specific template is maintained in a separate JetBrains.gitignore that can
+#  be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
+#  and can be added to the global gitignore or merged into this file.  For a more nuclear
+#  option (not recommended) you can uncomment the following to ignore the entire idea folder.
+#.idea/
+
+# End of https://www.toptal.com/developers/gitignore/api/python
diff --git a/setup.py b/setup.py
index 28ff4d3f..3ff4b9f2 100644
--- a/setup.py
+++ b/setup.py
@@ -21,38 +21,34 @@
 if uname[0] == "Darwin" or uname[0] == "Linux":
     compileArgs = ["-std=c++11"]
 
-
-setuptools.setup(
-    name="Python-EasyGraph",                                     
-    version="0.2a36",
-    author="Fudan MSN Group",                                       
-    author_email="easygraph@163.com",                      
-    description="Easy Graph",                            
-    long_description=long_description,                      
-    long_description_content_type="text/x-rst",          
-    url="https://github.com/easy-graph/Easy-Graph",                              
-    packages=setuptools.find_packages(),                    
-    classifiers=[
-        "Programming Language :: Python :: 3.6", 
-        "Programming Language :: Python :: 3.7",
-	    "Programming Language :: Python :: 3.8",
-        "Programming Language :: Python :: 3.9",                           
-        "License :: OSI Approved :: BSD License",           
-        "Operating System :: OS Independent",               
-    ],
-    python_requires=">=3.6, <3.10",
-    install_requires=['numpy>=1.18.5',
-                    'tqdm>=4.49.0',
-                    'tensorflow>=2.0.0',
-                    'joblib>=0.16.0',
-                    'six>=1.15.0',
-                    'gensim>=4.1.2',
-                    'progressbar33>=2.4',
-                    'scikit-learn>=0.24.0',
-                    'scipy>=1.5.2',
-                    'matplotlib>=3.3.0',
-                    'statsmodels>=0.12.0',
-                    'progressbar>=2.5'
-    ],
-    ext_modules=[setuptools.Extension('cpp_easygraph', sources, optional=True, extra_compile_args=compileArgs)]
-)
\ No newline at end of file
+setuptools.setup(name="Python-EasyGraph",
+                 version="0.2a37",
+                 author="Fudan MSN Group",
+                 author_email="easygraph@163.com",
+                 description="Easy Graph",
+                 long_description=long_description,
+                 long_description_content_type="text/x-rst",
+                 url="https://github.com/easy-graph/Easy-Graph",
+                 packages=setuptools.find_packages(),
+                 classifiers=[
+                     "Programming Language :: Python :: 3.6",
+                     "Programming Language :: Python :: 3.7",
+                     "Programming Language :: Python :: 3.8",
+                     "Programming Language :: Python :: 3.9",
+                     "License :: OSI Approved :: BSD License",
+                     "Operating System :: OS Independent",
+                 ],
+                 python_requires=">=3.6, <3.10",
+                 install_requires=[
+                     'numpy>=1.18.5', 'tqdm>=4.49.0', 'tensorflow>=2.0.0',
+                     'joblib>=0.16.0', 'six>=1.15.0', 'gensim>=4.1.2',
+                     'progressbar33>=2.4', 'scikit-learn>=0.24.0',
+                     'scipy>=1.5.2', 'matplotlib>=3.3.0',
+                     'statsmodels>=0.12.0', 'progressbar>=2.5'
+                 ],
+                 ext_modules=[
+                     setuptools.Extension('cpp_easygraph',
+                                          sources,
+                                          optional=True,
+                                          extra_compile_args=compileArgs)
+                 ])


Test patch:
diff --git a/.github/workflows/dummy_test.yaml b/.github/workflows/dummy_test.yaml
new file mode 100644
index 00000000..40337fba
--- /dev/null
+++ b/.github/workflows/dummy_test.yaml
@@ -0,0 +1,36 @@
+name: Python package
+
+# on: [push]
+on: workflow_dispatch
+
+jobs:
+  build:
+    # runs-on: [ubuntu-latest, windows, macos]
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        python-version: ["3.6", "3.7", "3.8", "3.9"]
+
+    steps:
+      - uses: actions/checkout@v2
+      - name: Set up Python ${{ matrix.python-version }}
+        uses: actions/setup-python@v2
+        with:
+          python-version: ${{ matrix.python-version }}
+      - name: Install dependencies
+        run: |
+          python -m pip install --upgrade pip
+          # pip install flake8 pytest
+          pip install yapf pytest python-easygraph
+          if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
+      # - name: Lint with flake8
+      #   run: |
+      #     # stop the build if there are Python syntax errors or undefined names
+      #     flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
+      #     # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
+      #     flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
+      - name: Lint with yapf
+        run: yapf -i **/*.py
+      - name: Test with pytest
+        run: |
+          pytest