Skip to content

Modernize project layout #299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 4 additions & 3 deletions .ci/code_generation.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from ansys.dpf import core
import os
import glob
import os
from pathlib import Path
import time
import shutil
import time

from ansys.dpf import core

if os.name == "posix":
LIB_TO_GENERATE = [
Expand Down
12 changes: 6 additions & 6 deletions .ci/edit_ansys_version.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import sys
import pkgutil
import os
import pkgutil
import sys

if __name__ == "__main__":
directory = os.path.dirname(pkgutil.get_loader("ansys.dpf.core").path)
file_path = os.path.join(directory, "_version.py")
for i, arg in enumerate(sys.argv):
if arg == "--version":
print(sys.argv[i+1])
version = sys.argv[i+1]
file = open(file_path, 'r')
print(sys.argv[i + 1])
version = sys.argv[i + 1]
file = open(file_path, "r")
lines = file.readlines()
for i, line in enumerate(lines):
if "__ansys_version__" in line:
lines[i] = f'__ansys_version__ = "{version}"\n'
file.close()
with open(file_path, 'w') as file:
with open(file_path, "w") as file:
file.writelines(lines)
8 changes: 3 additions & 5 deletions .ci/run_examples.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import glob
import os
import pathlib

from ansys.dpf import core

core.settings.disable_off_screen_rendering()
Expand All @@ -14,7 +15,4 @@
print("\n\n--------------------------------------------------\n")
print(file)
print("--------------------------------------------------\n")
exec(
open(file, mode="r", encoding="utf8").read(),
globals(),
globals())
exec(open(file, mode="r", encoding="utf8").read(), globals(), globals())
256 changes: 130 additions & 126 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: GitHub Actions
name: CI

on:
pull_request:
Expand All @@ -16,161 +16,165 @@ concurrency:
cancel-in-progress: true

env:
MAIN_PYTHON_VERSION: "3.10"
PACKAGE_NAME: ansys-dpf-core
MODULE: core
ANSYS_VERSION: 221


jobs:
Build_and_Test:
name: Build and Test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.8"]
os: ["windows-latest"]

style:
name: Code style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v3

- name: "Build Package"
uses: pyansys/pydpf-actions/[email protected]
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
ANSYS_VERSION: ${{env.ANSYS_VERSION}}
PACKAGE_NAME: ${{env.PACKAGE_NAME}}
MODULE: ${{env.MODULE}}
dpf-standalone-TOKEN: ${{secrets.DPF_PIPELINE}}
install_extras: plotting

- name: "Test Package"
uses: pyansys/pydpf-actions/[email protected]
with:
MODULE: ${{env.MODULE}}
python-version: ${{ env.MAIN_PYTHON_VERSION }}

- name: 'Upload to PyPi'
if: contains(github.ref, 'refs/tags')
shell: cmd
- name: Install dependencies
run: |
pip install twine
python setup.py sdist
twine upload --skip-existing dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{secrets.PYPI_TOKEN}}
TWINE_REPOSITORY_URL: "https://upload.pypi.org/legacy/"
python -m pip install --upgrade pip tox

build_doc:
name: Documentation
runs-on: windows-2019

env:
ANSYS_VERSION: 221
- name: Test with tox
run: tox -e style

docs-style:
name: Documentation Style Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup Python
uses: actions/[email protected]
- name: Running Vale
uses: errata-ai/vale-action@reviewdog
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
python-version: 3.8
files: doc
reporter: github-pr-check
level: error
filter_mode: nofilter
fail_on_error: true
vale_flags: "--config=doc/.vale.ini"

doc:
name: Documentation
runs-on: ubuntu-latest
needs: docs-style
steps:
- name: Checkout repository
uses: actions/checkout@v3

- id: install-dpf
uses: pyansys/pydpf-actions/[email protected]
- name: Set up Python
uses: actions/setup-python@v4
with:
dpf-standalone-TOKEN: ${{secrets.DPF_PIPELINE}}
ANSYS_VERSION : ${{env.ANSYS_VERSION}}

- name: Set AWP_ROOT$env:ANSYS_VERSION
run: echo "AWP_ROOT$env:ANSYS_VERSION=${{ steps.install-dpf.outputs.SERVER }}" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
python-version: ${{ env.MAIN_PYTHON_VERSION }}

- name: Set SERVER
run: echo "SERVER=$env:AWP_ROOT221" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append

- name: Install ansys-dpf-core
shell: cmd
run: |
pip install -r requirements_build.txt
python setup.py bdist_wheel
FOR /F %%a in ('dir /s/b dist\*.whl') do SET WHEELPATH=%%a
ECHO %WHEELPATH%
cd tests
pip install %WHEELPATH%
python -c "from ansys.dpf import core; print(core.Report(gpu=False))"

- name: Install OpenGL
- name: Install dependencies
run: |
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$PSDefaultParameterValues['*:ErrorAction']='Stop'
git clone --depth 1 https://github.com/pyvista/gl-ci-helpers.git
powershell gl-ci-helpers/appveyor/install_opengl.ps1
python -m pip install --upgrade pip tox

- name: Install test offscreen rendering
- name: Build documentation
run: |
.ci/setup_headless_display.sh
pip install -r .ci/requirements_test_xvfb.txt
python .ci/display_test.py
tox -e doc
touch .tox/doc_out/.nojekyll
echo "dpfdocs.pyansys.com" > .tox/doc_out/CNAME

- name: Install documentation packages for Python
run: |
pip install -r requirements_docs.txt
- name: Upload Documentation
uses: actions/upload-artifact@v3
with:
name: HTML-Documentation
path: .tox/doc_out/
retention-days: 7

- name: Build Documentation
shell: cmd
run: |
cd .ci
build_doc.bat > ..\docs\log.txt 2>&1
timeout-minutes: 20
- name: Deploy to gh-pages
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
uses: JamesIves/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: .tox/doc_out/
CLEAN: true
SINGLE_COMMIT: true

tests:
name: Tests
needs: style
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
cfg:
- {python-version: "3.7", toxenv: "py37"}
- {python-version: "3.8", toxenv: "py38"}
- {python-version: "3.9", toxenv: "py39"}
- {python-version: "3.10", toxenv: "py310-cov"}
fail-fast: false

- name: DOCUMENTATION zip artifacts
run: |
7z a -tzip ./docs/archive/doc-ansys-dpf-core.zip ./docs/build
if: always()
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.cfg.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.cfg.python-version }}

- name: Kill all servers
shell: cmd
run: |
tasklist /FI "IMAGENAME eq Ans.Dpf.Grpc.exe" 2>NUL | find /I /N "Ans.Dpf.Grpc.exe">NUL
ECHO %ERRORLEVEL%
if "%ERRORLEVEL%"=="0"(taskkill /f /im Ans.Dpf.Grpc.exe)
continue-on-error: true
if: always()
- name: Install dependencies
run: python -m pip install --upgrade pip tox

- name: Publish Documentation artifact
uses: actions/upload-artifact@v3
with:
name: doc-ansys-dpf-core
path: ./docs/archive/doc-ansys-dpf-core.zip
if: always()
- name: Run Tox
run: tox -e ${{ matrix.cfg.toxenv }}

- name: Publish Documentation log
uses: actions/upload-artifact@v3
with:
name: doc-ansys-dpf-core-log
path: ./docs/*.txt
if: always()
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
if: matrix.cfg.python-version == ${{ env.MAIN_PYTHON_VERSION }} && matrix.os == ubuntu-latest

- name: Init git and add docs
if: contains(github.ref, 'refs/tags')
build:
name: Build library
runs-on: ubuntu-latest
needs: [tests, doc]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
- name: Install dependencies and build the library
run: |
cd docs/build/html
git init
git checkout -b $env:GH_DOC_BRANCH
git config --global user.name "pyansys-ci-bot"
git config --global user.email "$env:GH_EMAIL"
New-Item -ItemType file .nojekyll
git add .
git commit -m "Documentation generated"
env:
GH_DOC_BRANCH: gh-pages
GH_EMAIL: [email protected]

- name: Publish GitHub Pages merge commit
if: contains(github.ref, 'refs/tags')
python -m pip install --upgrade pip
python -m pip install -r requirements/requirements_build.txt
python -m build && python -m twin check dist/*

release:
name: Release
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
needs: build
runs-on: ubuntu-latest

steps:
- uses: actions/download-artifact@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
- name: Display structure of downloaded files
run: ls -R
- name: Install dependencies
run: |
cd docs/build/html
git remote add origin https://${{secrets.PYANSYS_CI_BOT_TOKEN}}@github.com/pyansys/DPF-Core-docs
git push -u origin $env:GH_DOC_BRANCH --force
python -m pip install --upgrade pip twine
- name: Publish to PyPI
env:
GH_DOC_BRANCH: gh-pages
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
python -m twine upload --skip-existing ./**/*.whl
python -m twine upload --skip-existing ./**/*.tar.gz
- name: Publish to GitHub
uses: softprops/action-gh-release@v1
with:
files: |
./**/*.whl
./**/*.tar.gz
Loading