From ab144db68bb3deaf9b33f13e461e212ae7f61a7d Mon Sep 17 00:00:00 2001 From: Nikola Sibalic Date: Sun, 19 May 2024 22:36:35 +0200 Subject: [PATCH 1/2] test new build system --- .github/workflows/codeql.yml | 28 +++---- .github/workflows/linux.yaml | 34 -------- .github/workflows/mac.yaml | 34 -------- .github/workflows/pypi_linux.yaml | 26 ------ .github/workflows/pypi_macos.yaml | 29 ------- .github/workflows/pypi_windows.yaml | 29 ------- .github/workflows/wheels.yaml | 120 ++++++++++++++++++++++++++++ .github/workflows/windows.yaml | 34 -------- pyproject.toml | 3 + test/test_import.py | 50 ++++++++++++ 10 files changed, 184 insertions(+), 203 deletions(-) delete mode 100644 .github/workflows/linux.yaml delete mode 100644 .github/workflows/mac.yaml delete mode 100644 .github/workflows/pypi_linux.yaml delete mode 100644 .github/workflows/pypi_macos.yaml delete mode 100644 .github/workflows/pypi_windows.yaml create mode 100644 .github/workflows/wheels.yaml delete mode 100644 .github/workflows/windows.yaml create mode 100644 test/test_import.py diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index def3564..e10b4a2 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -13,12 +13,10 @@ name: "CodeQL" on: push: - branches: [ "master" ] + branches: [ "master", "new-build-workflow" ] pull_request: # The branches below must be a subset of the branches above branches: [ "master" ] - schedule: - - cron: '33 10 * * 4' jobs: analyze: @@ -32,7 +30,7 @@ jobs: strategy: fail-fast: false matrix: - language: [ 'cpp', 'python' ] + language: [ 'c', 'python' ] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support @@ -51,24 +49,20 @@ jobs: # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs # queries: security-extended,security-and-quality - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.12 + - name: Build + run: | + pip install build + python -m build - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 with: category: "/language:${{matrix.language}}" diff --git a/.github/workflows/linux.yaml b/.github/workflows/linux.yaml deleted file mode 100644 index 7792890..0000000 --- a/.github/workflows/linux.yaml +++ /dev/null @@ -1,34 +0,0 @@ -name: ARC build for Linux - -on: [push] - -jobs: - build: - - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] - - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest black "black[jupyter]" - pip install build - - name: Check - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 --version - flake8 . --count --show-source --statistics - black --version - black -l 80 . --check - python -m compileall -f arc/*.py - - name: Build - run: | - python -m build diff --git a/.github/workflows/mac.yaml b/.github/workflows/mac.yaml deleted file mode 100644 index 270481d..0000000 --- a/.github/workflows/mac.yaml +++ /dev/null @@ -1,34 +0,0 @@ -name: ARC build for Mac - -on: [push] - -jobs: - build: - - runs-on: macos-latest - strategy: - matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] - - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest black "black[jupyter]" - pip install build - - name: Check - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 --version - flake8 . --count --show-source --statistics - black --version - black -l 80 . --check - python -m compileall -f arc/*.py - - name: Build - run: | - python -m build diff --git a/.github/workflows/pypi_linux.yaml b/.github/workflows/pypi_linux.yaml deleted file mode 100644 index 1d02015..0000000 --- a/.github/workflows/pypi_linux.yaml +++ /dev/null @@ -1,26 +0,0 @@ -name: PyPI Linux - -on: - release: - types: [created] - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install build twine - - name: Build and publish - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} - run: | - python -m build --sdist - twine upload dist/*.tar.gz diff --git a/.github/workflows/pypi_macos.yaml b/.github/workflows/pypi_macos.yaml deleted file mode 100644 index 033f177..0000000 --- a/.github/workflows/pypi_macos.yaml +++ /dev/null @@ -1,29 +0,0 @@ -name: PyPI macos - -on: - release: - types: [created] - -jobs: - deploy: - runs-on: macos-latest - strategy: - matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install build twine - - name: Build and publish - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} - run: | - python -m build --wheel - twine upload dist/*.whl diff --git a/.github/workflows/pypi_windows.yaml b/.github/workflows/pypi_windows.yaml deleted file mode 100644 index 36d5fc9..0000000 --- a/.github/workflows/pypi_windows.yaml +++ /dev/null @@ -1,29 +0,0 @@ -name: PyPI Windows - -on: - release: - types: [created] - -jobs: - deploy: - runs-on: windows-latest - strategy: - matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install build twine - - name: Build and publish - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} - run: | - python -m build --wheel - twine upload dist/*.whl diff --git a/.github/workflows/wheels.yaml b/.github/workflows/wheels.yaml new file mode 100644 index 0000000..7ce00a6 --- /dev/null +++ b/.github/workflows/wheels.yaml @@ -0,0 +1,120 @@ +name: Build wheels + +on: [push] + +jobs: + format_test: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.12"] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest black "black[jupyter]" + pip install build + - name: Check + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 --version + flake8 . --count --show-source --statistics + black --version + black -l 80 . --check + python -m compileall -f arc/*.py + + function_test: + name: Basic test suite + runs-on: ubuntu-latest + needs: [format_test] + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: 3.12 + - name: Setup ARC + run: | + pip install . + pip install pytest coverage + pytest --version + - name: Run tests + run: + coverage run -m pytest -s -v + - name: Coverage report + run: + coverage report -m + + build_wheels: + name: Build wheels on ${{ matrix.os }} + needs: [function_test] + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-13, macos-14] + + steps: + - uses: actions/checkout@v4 + + # Used to host cibuildwheel + - uses: actions/setup-python@v5 + + - name: Install cibuildwheel + run: python -m pip install cibuildwheel==2.18.0 + + - name: Build wheels + run: python -m cibuildwheel --output-dir wheelhouse + # to supply options, put them in 'env', like: + # env: + # CIBW_SOME_OPTION: value + + - uses: actions/upload-artifact@v4 + with: + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} + path: ./wheelhouse/*.whl + + build_sdist: + name: Build source distribution + needs: [function_test] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Build sdist + run: pipx run build --sdist + + - uses: actions/upload-artifact@v4 + with: + name: cibw-sdist + path: dist/*.tar.gz + + upload_pypi: + name: Publish package to PyPI + needs: [build_wheels, build_sdist] + runs-on: ubuntu-latest + environment: deploy + permissions: + id-token: write + #if: github.event_name == 'release' && github.event.action == 'published' + # or, alternatively, upload to PyPI on every tag starting with 'v' (remove on: release above to use this) + # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + steps: + - name: Get artifacts + uses: actions/download-artifact@v4 + with: + # unpacks all CIBW artifacts into dist/ + pattern: cibw-* + path: dist + merge-multiple: true + + - name: Upload + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ \ No newline at end of file diff --git a/.github/workflows/windows.yaml b/.github/workflows/windows.yaml deleted file mode 100644 index d071a34..0000000 --- a/.github/workflows/windows.yaml +++ /dev/null @@ -1,34 +0,0 @@ -name: ARC build for Windows - -on: [push] - -jobs: - build: - - runs-on: windows-latest - strategy: - matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] - - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest black "black[jupyter]" - pip install build - - name: Check - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 --version - flake8 . --count --show-source --statistics - black --version - black -l 80 . --check - python -m compileall -f arc/*.py - - name: Build - run: | - python -m build diff --git a/pyproject.toml b/pyproject.toml index 636a1de..1e969d3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -73,3 +73,6 @@ Homepage = "https://atomcalc.org/" Repository = "https://github.com/nikolasibalic/ARC-Alkali-Rydberg-Calculator" Documentation = "https://arc-alkali-rydberg-calculator.readthedocs.io/en/latest/" Download = "https://github.com/nikolasibalic/ARC-Alkali-Rydberg-Calculator/archive/refs/tags/v3.4.1.tar.gz" + +[tool.cibuildwheel] +skip = ["*-win32", "*-manylinux_i686", "*-musllinux_i686" ,"pp*"] \ No newline at end of file diff --git a/test/test_import.py b/test/test_import.py new file mode 100644 index 0000000..b8d94a4 --- /dev/null +++ b/test/test_import.py @@ -0,0 +1,50 @@ +from arc import ( + Cesium, + Rubidium85, + Rubidium87, + Potassium39, + Potassium40, + Potassium41, + Lithium6, + Lithium7, + Strontium88, + Ytterbium174, + Calcium40, + Sodium, +) + + +def test_import_cs(): + _ = Cesium() + + +def test_import_rb(): + _ = Rubidium85() + _ = Rubidium87() + + +def test_import_li(): + _ = Lithium6() + _ = Lithium7 + + +def test_import_K(): + _ = Potassium39() + _ = Potassium40() + _ = Potassium41() + + +def test_import_Na(): + _ = Sodium() + + +def test_import_Sr(): + _ = Strontium88() + + +def test_import_Ca(): + _ = Calcium40() + + +def test_import_Yt(): + _ = Ytterbium174() From c161853ea917f8e1dc8ac2e4df25bd99f5ddc59a Mon Sep 17 00:00:00 2001 From: Nikola Sibalic Date: Sun, 19 May 2024 23:30:31 +0200 Subject: [PATCH 2/2] prepare for merge to main and deploy to PyPI --- .github/workflows/wheels.yaml | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/workflows/wheels.yaml b/.github/workflows/wheels.yaml index 7ce00a6..9e6a4ad 100644 --- a/.github/workflows/wheels.yaml +++ b/.github/workflows/wheels.yaml @@ -1,6 +1,15 @@ -name: Build wheels - -on: [push] +name: Test, build, release + +on: + pull_request: + branches: + - master + push: + branches: + - master + - 'releases/**' + release: + types: [created] jobs: format_test: @@ -55,6 +64,7 @@ jobs: build_wheels: name: Build wheels on ${{ matrix.os }} needs: [function_test] + if: github.event_name == 'release' && github.event.action == 'published' runs-on: ${{ matrix.os }} strategy: matrix: @@ -71,9 +81,6 @@ jobs: - name: Build wheels run: python -m cibuildwheel --output-dir wheelhouse - # to supply options, put them in 'env', like: - # env: - # CIBW_SOME_OPTION: value - uses: actions/upload-artifact@v4 with: @@ -102,9 +109,7 @@ jobs: environment: deploy permissions: id-token: write - #if: github.event_name == 'release' && github.event.action == 'published' - # or, alternatively, upload to PyPI on every tag starting with 'v' (remove on: release above to use this) - # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + if: github.event_name == 'release' && github.event.action == 'published' steps: - name: Get artifacts uses: actions/download-artifact@v4 @@ -115,6 +120,4 @@ jobs: merge-multiple: true - name: Upload - uses: pypa/gh-action-pypi-publish@release/v1 - with: - repository-url: https://test.pypi.org/legacy/ \ No newline at end of file + uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file