Skip to content

Commit

Permalink
Merge pull request #168 from nikolasibalic/new-build-workflow
Browse files Browse the repository at this point in the history
Improved workflow
  • Loading branch information
nikolasibalic authored May 19, 2024
2 parents 9b33b04 + c161853 commit d4ebec7
Show file tree
Hide file tree
Showing 10 changed files with 187 additions and 203 deletions.
28 changes: 11 additions & 17 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

Expand All @@ -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}}"
34 changes: 0 additions & 34 deletions .github/workflows/linux.yaml

This file was deleted.

34 changes: 0 additions & 34 deletions .github/workflows/mac.yaml

This file was deleted.

26 changes: 0 additions & 26 deletions .github/workflows/pypi_linux.yaml

This file was deleted.

29 changes: 0 additions & 29 deletions .github/workflows/pypi_macos.yaml

This file was deleted.

29 changes: 0 additions & 29 deletions .github/workflows/pypi_windows.yaml

This file was deleted.

123 changes: 123 additions & 0 deletions .github/workflows/wheels.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Test, build, release

on:
pull_request:
branches:
- master
push:
branches:
- master
- 'releases/**'
release:
types: [created]

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]
if: github.event_name == 'release' && github.event.action == 'published'
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

- 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'
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
34 changes: 0 additions & 34 deletions .github/workflows/windows.yaml

This file was deleted.

3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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*"]
Loading

0 comments on commit d4ebec7

Please sign in to comment.