From 7666e8db9f7a7e89e4ad07abf62b9a0838cde117 Mon Sep 17 00:00:00 2001 From: Candace Moore Date: Wed, 21 Feb 2024 16:15:51 +0100 Subject: [PATCH] add workflows --- .github/workflows/on-commit.yml | 101 ++++++++++++++++++++++++++++++++ .github/workflows/on-tag.yml | 88 ++++++++++++++++++++++++++++ 2 files changed, 189 insertions(+) create mode 100644 .github/workflows/on-commit.yml create mode 100644 .github/workflows/on-tag.yml diff --git a/.github/workflows/on-commit.yml b/.github/workflows/on-commit.yml new file mode 100644 index 0000000..b83df40 --- /dev/null +++ b/.github/workflows/on-commit.yml @@ -0,0 +1,101 @@ +name: Sanity +on: [push] + +jobs: + # + SanityOnMulti: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + python-version: ['3.10', '3.11'] + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + - uses: s-weigand/setup-conda@v1 + with: + conda-channels: conda-forge + python-version: '3.11' + - run: python3 -m venv .venv + - run: .venv/bin/python -m pip install pycodestyle pytest nbmake + - run: .venv/bin/python ./setup.py install + - run: .venv/bin/python ./setup.py test -a "test_multi.py" + # needs to be updated to include Windows + + # SanityOnWindows: + # # PB step 1 debug + # runs-on: ${{ matrix.os }} + # strategy: + # matrix: + # os: [windows-latest] + # python-version: ['3.10', '3.11'] + # steps: + # - uses: actions/checkout@v3 + # with: + # submodules: recursive + # - uses: s-weigand/setup-conda@v1 + # with: + # conda-channels: conda-forge + # python-version: '3.11' + # - run: python3 -m venv .venv + # - run: .venv\bin\python -m pip install pycodestyle pytest nbmake + # - run: .venv\bin\python ./setup.py install + # - run: .venv\bin\python ./setup.py test -a "test_multi.py" + + Lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + - uses: s-weigand/setup-conda@v1 + with: + conda-channels: conda-forge + python-version: '3.11' + - run: python3 -m venv .venv + - run: .venv/bin/python -m pip install wheel + - run: .venv/bin/python -m pip install pycodestyle pytest + - run: .venv/bin/python setup.py lint + + Sphinx: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + submodules: recursive + - uses: s-weigand/setup-conda@v1 + with: + conda-channels: conda-forge + python-version: '3.10' + - run: python3 -m venv .venv + - run: .venv/bin/python -m pip install wheel + - run: .venv/bin/python setup.py install + - run: .venv/bin/python -m pip install sphinx piccolo_theme + - run: .venv/bin/python setup.py apidoc + - run: .venv/bin/python setup.py build_sphinx -W + - name: Publish Docs to Pages + uses: JamesIves/github-pages-deploy-action@v4 + with: + branch: gh-pages + folder: build/sphinx/html + + # Fair-software: + # runs-on: ubuntu-latest + # steps: + # - uses: fair-software/howfairis-github-action@0.2.1 + # name: Measure compliance with fair-software.eu recommendations + # env: + # PYCHARM_HOSTED: "Trick colorama into displaying colored output" + # with: + # MY_REPO_URL: "https://github.com/${{ github.repository }}" + + # Markdown: + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@main + # - uses: gaurav-nelson/github-action-markdown-link-check@v1 + # with: + # config-file: '.github/workflows/mlc-config.json' diff --git a/.github/workflows/on-tag.yml b/.github/workflows/on-tag.yml new file mode 100644 index 0000000..7d0e63b --- /dev/null +++ b/.github/workflows/on-tag.yml @@ -0,0 +1,88 @@ +name: Release + +on: + push: + tags: + - v* + +jobs: + PyPIBuild: + if: ${{ github.repository == 'brickstudymasons/brickstudy' }} + name: Tagged Release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + submodules: recursive + # Unfortunately, wheel will try to do setup.py install to + # build a wheel... and we need this stuff to be able to build + # for CPython. + + - name: Set up Python 3.11 + uses: actions/setup-python@v1 + with: + python-version: 3.11 + - run: python3.11 -m venv .venv + - run: .venv/bin/python -m pip install wheel twine + - run: .venv/bin/python setup.py bdist_wheel + - run: .venv/bin/python setup.py bdist_egg + - run: >- + TWINE_USERNAME=__token__ + TWINE_PASSWORD=${{ secrets.PYPI_TOKEN }} + .venv/bin/python -m twine upload --skip-existing ./dist/*.whl + - uses: actions/upload-artifact@v2 + with: + name: pypi-build + path: dist/* + + CondaBuild: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + python-version: [3.11] + os: [ubuntu-latest, windows-latest, macos-latest] + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + fetch-depth: 0 + - uses: s-weigand/setup-conda@v1.1.1 + with: + conda-channels: conda-forge + python-version: ${{ matrix.python-version }} + - run: conda config --remove channels defaults + - name: Generate conda meta.yaml (Python 3.11) + run: python -u setup.py anaconda_gen_meta + - if: ${{ matrix.os == 'macos-latest' }} + run: python -u setup.py bdist_conda -o + - if: ${{ matrix.os != 'macos-latest' }} + run: python -u setup.py bdist_conda + - name: Upload Anaconda package + run: >- + python setup.py anaconda_upload + --token=${{ secrets.ANACONDA_TOKEN }} + --package=./dist/*/*.tar.bz2 + - uses: actions/upload-artifact@v2 + with: + name: conda-build-${{ matrix.os }}-${{ matrix.python-version }} + path: dist/*/*.tar.bz2 + + PublishArtifacts: + runs-on: ubuntu-latest + needs: [PyPIBuild, CondaBuild] + steps: + - uses: actions/download-artifact@v2 + with: + path: dist + - uses: marvinpinto/action-automatic-releases@latest + with: + repo_token: "${{ secrets.GITHUBTOKEN }}" + prerelease: false + files: | + ./dist/*/linux-64/brickstudy-*.tar.bz2 + ./dist/*/osx-64/brickstudy-*.tar.bz2 + ./dist/*/win-64/brickstudy-*.tar.bz2 + ./dist/pypi-build/*.whl + ./dist/pypi-build/*.egg