Skip to content

Commit

Permalink
fix workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
AbstractUmbra committed Jul 21, 2023
1 parent 1df1534 commit e928724
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 48 deletions.
105 changes: 76 additions & 29 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,65 +4,98 @@ name: Build

on:
push:
branches:
- main
tags:
- '*.*.*'
pull_request:
branches:
- main
- "*.*.*"
workflow_run:
workflows: ["Type Coverage and Linting"]
types: [completed]
branches: [main]

jobs:
build:
name: Build
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version: [ "3.11" ]
python-version: ["3.11", "3.x"]

name: "Build @ ${{ matrix.python-version }}"
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: "Checkout Repository"
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: "Set up Python ${{ matrix.python-version }}"
uses: actions/setup-python@v1
- name: "Load cached poetry installation @ ${{ matrix.python-version }}"
id: cached-poetry
uses: actions/cache@v3
with:
path: ~/.local
key: poetry-0

- name: "Setup Poetry @ ${{ matrix.python-version }}"
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true
virtualenvs-path: .venv

- name: "Setup Python @ ${{ matrix.python-version }}"
id: setup-python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
python-version: "${{ matrix.python-version }}"
cache: "poetry"

- name: "Set up Poetry ${{ matrix.python-version }}"
uses: Gr1N/setup-poetry@v7
- name: "Load cached venv @ ${{ matrix.python-version }}"
id: cached-pip-wheels
uses: actions/cache@v3
with:
poetry-preview: true
path: .venv/
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: "Install Python deps ${{ matrix.python-version }}"
- name: "Install Python deps @ ${{ matrix.python-version }}"
if: ${{ steps.cached-pip-wheels.outputs.cache-hit != 'true' }}
id: install-deps
run: |
poetry install --all-extras
poetry install --no-interaction
- name: "Check it imports ${{ matrix.python-version }}"
- name: Activate venv @ ${{ matrix.python-version }}
run: |
echo "$(poetry env info --path)/bin" >> $GITHUB_PATH
- name: "Check it imports @ ${{ matrix.python-version }}"
run: |
poetry run python -c 'import mystbin'
- name: "Build wheels ${{ matrix.python-version }}"
- name: "Build wheels @ ${{ matrix.python-version}}"
run: |
poetry build
- name: "Upload artifacts ${{ matrix.python-version }}"
uses: actions/upload-artifact@v2
- name: "Build docs @ ${{ matrix.python-version}}"
run: |
cd docs/
poetry run sphinx-build -aETW --keep-going . build
- name: "Upload artifacts @ ${{ matrix.python-version}}"
uses: actions/upload-artifact@v3
with:
name: distributions
path: dist/*

# Credits to most of this step go to Gorialis (Devon R [https://github.com/Gorialis])
# as I found them in their Jishaku builds (https://github.com/Gorialis/jishaku/blob/d3f50749b5a977b544e5fd14894585f656247486/.github/workflows/deploy.yml#L82-L119)
create_release:
needs: [ build ]
name: Create Release
needs: [build]
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')

steps:
- name: Checkout Repository
uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
Expand All @@ -73,10 +106,24 @@ jobs:
name: distributions
path: dist

- name: Set up Poetry
uses: Gr1N/setup-poetry@v7
- name: Create GitHub release
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -x
assets=()
for asset in ./dist/*.{whl,tar.gz}; do
assets+=("-a" "$asset")
done
tag_name="${GITHUB_REF##*/}"
hub release create "${assets[@]}" -F "CHANGELOG.md" "$tag_name"
- name: "Set up Poetry"
uses: snok/install-poetry@v1
with:
poetry-preview: true
virtualenvs-create: true
virtualenvs-in-project: false

- name: Publish to PyPI
env:
Expand Down
55 changes: 36 additions & 19 deletions .github/workflows/coverage_and_lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ on:
pull_request:
branches:
- main
types:
- opened
- synchronize
types: [opened, reopened, synchronize]

jobs:
job:
Expand All @@ -26,37 +24,56 @@ jobs:
with:
fetch-depth: 0

- name: "Load cached poetry installation @ ${{ matrix.python-version }}"
id: cached-poetry
uses: actions/cache@v3
with:
path: ~/.local
key: poetry-0

- name: "Setup Poetry @ ${{ matrix.python-version }}"
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: 1.2.0b2
version: latest
virtualenvs-create: true
virtualenvs-in-project: false
virtualenvs-in-project: true
virtualenvs-path: .venv

- name: "Setup Python @ ${{ matrix.python-version }}"
uses: actions/setup-python@v3
id: setup-python
uses: actions/setup-python@v4
with:
python-version: "${{ matrix.python-version }}"
cache: "poetry"

- name: "Load cached venv @ ${{ matrix.python-version }}"
id: cached-pip-wheels
uses: actions/cache@v3
with:
path: .venv/
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: "Install Python deps @ ${{ matrix.python-version }}"
env:
PY_VER: "${{ matrix.python-version }}"
if: ${{ steps.cached-pip-wheels.outputs.cache-hit != 'true' }}
id: install-deps
run: |
poetry env use "$PY_VER"
poetry install --all-extras --no-interaction
poetry install --without=dev --no-interaction
- uses: actions/setup-node@v3
with:
node-version: "17"
- run: npm install --location=global pyright@latest

- name: "Type Coverage @ ${{ matrix.python-version }}"
- name: Activate venv @ ${{ matrix.python-version }}
run: |
poetry run pyright
poetry run pyright --ignoreexternal --lib --verifytypes mystbin
echo "$(poetry env info --path)/bin" >> $GITHUB_PATH
- name: "Run Pyright @ ${{ matrix.python-version }}"
uses: jakebailey/pyright-action@v1
with:
warnings: false
verify-types: "mystbin"
ignore-external: true
no-comments: ${{ matrix.python-version != '3.x' }}

- name: Lint
if: ${{ github.event_name != 'pull_request' }}
if: ${{ always() && steps.install-deps.outcome == 'success' }}
uses: github/super-linter/slim@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down

0 comments on commit e928724

Please sign in to comment.