Skip to content

Commit e928724

Browse files
committed
fix workflows
1 parent 1df1534 commit e928724

File tree

2 files changed

+112
-48
lines changed

2 files changed

+112
-48
lines changed

.github/workflows/build.yaml

Lines changed: 76 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,65 +4,98 @@ name: Build
44

55
on:
66
push:
7-
branches:
8-
- main
97
tags:
10-
- '*.*.*'
11-
pull_request:
12-
branches:
13-
- main
8+
- "*.*.*"
9+
workflow_run:
10+
workflows: ["Type Coverage and Linting"]
11+
types: [completed]
12+
branches: [main]
1413

1514
jobs:
1615
build:
17-
name: Build
16+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1817
runs-on: ubuntu-latest
19-
2018
strategy:
19+
fail-fast: false
2120
matrix:
22-
python-version: [ "3.11" ]
21+
python-version: ["3.11", "3.x"]
2322

23+
name: "Build @ ${{ matrix.python-version }}"
2424
steps:
25-
- name: Checkout source
26-
uses: actions/checkout@v2
25+
- name: "Checkout Repository"
26+
uses: actions/checkout@v3
27+
with:
28+
fetch-depth: 0
2729

28-
- name: "Set up Python ${{ matrix.python-version }}"
29-
uses: actions/setup-python@v1
30+
- name: "Load cached poetry installation @ ${{ matrix.python-version }}"
31+
id: cached-poetry
32+
uses: actions/cache@v3
33+
with:
34+
path: ~/.local
35+
key: poetry-0
36+
37+
- name: "Setup Poetry @ ${{ matrix.python-version }}"
38+
if: steps.cached-poetry.outputs.cache-hit != 'true'
39+
uses: snok/install-poetry@v1
40+
with:
41+
version: latest
42+
virtualenvs-create: true
43+
virtualenvs-in-project: true
44+
virtualenvs-path: .venv
45+
46+
- name: "Setup Python @ ${{ matrix.python-version }}"
47+
id: setup-python
48+
uses: actions/setup-python@v4
3049
with:
31-
python-version: ${{ matrix.python-version }}
50+
python-version: "${{ matrix.python-version }}"
51+
cache: "poetry"
3252

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

38-
- name: "Install Python deps ${{ matrix.python-version }}"
60+
- name: "Install Python deps @ ${{ matrix.python-version }}"
61+
if: ${{ steps.cached-pip-wheels.outputs.cache-hit != 'true' }}
62+
id: install-deps
3963
run: |
40-
poetry install --all-extras
64+
poetry install --no-interaction
4165
42-
- name: "Check it imports ${{ matrix.python-version }}"
66+
- name: Activate venv @ ${{ matrix.python-version }}
67+
run: |
68+
echo "$(poetry env info --path)/bin" >> $GITHUB_PATH
69+
70+
- name: "Check it imports @ ${{ matrix.python-version }}"
4371
run: |
4472
poetry run python -c 'import mystbin'
4573
46-
- name: "Build wheels ${{ matrix.python-version }}"
74+
- name: "Build wheels @ ${{ matrix.python-version}}"
4775
run: |
4876
poetry build
4977
50-
- name: "Upload artifacts ${{ matrix.python-version }}"
51-
uses: actions/upload-artifact@v2
78+
- name: "Build docs @ ${{ matrix.python-version}}"
79+
run: |
80+
cd docs/
81+
poetry run sphinx-build -aETW --keep-going . build
82+
83+
- name: "Upload artifacts @ ${{ matrix.python-version}}"
84+
uses: actions/upload-artifact@v3
5285
with:
5386
name: distributions
5487
path: dist/*
5588

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

6397
steps:
64-
- name: Checkout Repository
65-
uses: actions/checkout@v2
98+
- uses: actions/checkout@v3
6699
with:
67100
fetch-depth: 0
68101
submodules: true
@@ -73,10 +106,24 @@ jobs:
73106
name: distributions
74107
path: dist
75108

76-
- name: Set up Poetry
77-
uses: Gr1N/setup-poetry@v7
109+
- name: Create GitHub release
110+
shell: bash
111+
env:
112+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113+
run: |
114+
set -x
115+
assets=()
116+
for asset in ./dist/*.{whl,tar.gz}; do
117+
assets+=("-a" "$asset")
118+
done
119+
tag_name="${GITHUB_REF##*/}"
120+
hub release create "${assets[@]}" -F "CHANGELOG.md" "$tag_name"
121+
122+
- name: "Set up Poetry"
123+
uses: snok/install-poetry@v1
78124
with:
79-
poetry-preview: true
125+
virtualenvs-create: true
126+
virtualenvs-in-project: false
80127

81128
- name: Publish to PyPI
82129
env:

.github/workflows/coverage_and_lint.yaml

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ on:
77
pull_request:
88
branches:
99
- main
10-
types:
11-
- opened
12-
- synchronize
10+
types: [opened, reopened, synchronize]
1311

1412
jobs:
1513
job:
@@ -26,37 +24,56 @@ jobs:
2624
with:
2725
fetch-depth: 0
2826

27+
- name: "Load cached poetry installation @ ${{ matrix.python-version }}"
28+
id: cached-poetry
29+
uses: actions/cache@v3
30+
with:
31+
path: ~/.local
32+
key: poetry-0
33+
2934
- name: "Setup Poetry @ ${{ matrix.python-version }}"
35+
if: steps.cached-poetry.outputs.cache-hit != 'true'
3036
uses: snok/install-poetry@v1
3137
with:
32-
version: 1.2.0b2
38+
version: latest
3339
virtualenvs-create: true
34-
virtualenvs-in-project: false
40+
virtualenvs-in-project: true
41+
virtualenvs-path: .venv
3542

3643
- name: "Setup Python @ ${{ matrix.python-version }}"
37-
uses: actions/setup-python@v3
44+
id: setup-python
45+
uses: actions/setup-python@v4
3846
with:
3947
python-version: "${{ matrix.python-version }}"
48+
cache: "poetry"
49+
50+
- name: "Load cached venv @ ${{ matrix.python-version }}"
51+
id: cached-pip-wheels
52+
uses: actions/cache@v3
53+
with:
54+
path: .venv/
55+
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
4056

4157
- name: "Install Python deps @ ${{ matrix.python-version }}"
42-
env:
43-
PY_VER: "${{ matrix.python-version }}"
58+
if: ${{ steps.cached-pip-wheels.outputs.cache-hit != 'true' }}
59+
id: install-deps
4460
run: |
45-
poetry env use "$PY_VER"
46-
poetry install --all-extras --no-interaction
61+
poetry install --without=dev --no-interaction
4762
48-
- uses: actions/setup-node@v3
49-
with:
50-
node-version: "17"
51-
- run: npm install --location=global pyright@latest
52-
53-
- name: "Type Coverage @ ${{ matrix.python-version }}"
63+
- name: Activate venv @ ${{ matrix.python-version }}
5464
run: |
55-
poetry run pyright
56-
poetry run pyright --ignoreexternal --lib --verifytypes mystbin
65+
echo "$(poetry env info --path)/bin" >> $GITHUB_PATH
66+
67+
- name: "Run Pyright @ ${{ matrix.python-version }}"
68+
uses: jakebailey/pyright-action@v1
69+
with:
70+
warnings: false
71+
verify-types: "mystbin"
72+
ignore-external: true
73+
no-comments: ${{ matrix.python-version != '3.x' }}
5774

5875
- name: Lint
59-
if: ${{ github.event_name != 'pull_request' }}
76+
if: ${{ always() && steps.install-deps.outcome == 'success' }}
6077
uses: github/super-linter/slim@v4
6178
env:
6279
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)