Skip to content

Commit 82d2bde

Browse files
committed
Add install checks
1 parent 1fcf7f6 commit 82d2bde

File tree

4 files changed

+101
-32
lines changed

4 files changed

+101
-32
lines changed

.github/workflows/_build.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
name: _build
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
python_version:
8+
description: The Python version.
9+
type: string
10+
required: false
11+
default: '3.11'
12+
runs_on:
13+
description: The runner environment.
14+
type: string
15+
required: false
16+
default: ubuntu-latest
17+
outputs:
18+
artifact_name:
19+
description: The artifact name.
20+
value: build-${{ github.sha }}
21+
22+
jobs:
23+
build:
24+
name: Package
25+
runs-on: ubuntu-latest
26+
timeout-minutes: 30
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v3
30+
- name: Setup
31+
uses: ./.github/actions/setup
32+
with:
33+
python_version: ${{ inputs.python_version }}
34+
- name: Build
35+
run: make build
36+
- name: Upload artifact
37+
uses: actions/upload-artifact@v3
38+
with:
39+
name: build-${{ github.sha }}
40+
if-no-files-found: error
41+
path: dist/

.github/workflows/_publish.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ name: _publish
33

44
on:
55
workflow_call:
6+
inputs:
7+
artifact_name:
8+
description: The artifact name.
9+
type: string
10+
required: true
611
secrets:
712
registry_token:
813
description: The package registry token.
@@ -20,10 +25,10 @@ jobs:
2025
uses: ./.github/actions/setup
2126
with:
2227
install_dependencies: 'false'
23-
- name: Download artifacts
28+
- name: Download artifact
2429
uses: actions/download-artifact@v3
2530
with:
26-
name: ${{ github.sha }}
31+
name: ${{ inputs.artifact_name }}
2732
path: dist/
2833
- name: Publish
2934
run: poetry publish --skip-existing -u $USERNAME -p $PASSWORD

.github/workflows/check.yml

+44-9
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ jobs:
5858
run: make lint
5959
build:
6060
name: Build (Python ${{ matrix.python }} on ${{ matrix.os_name }})
61-
runs-on: ${{ matrix.os }}
62-
timeout-minutes: 30
61+
uses: ./.github/workflows/_build.yml
62+
with:
63+
python_version: ${{ matrix.python }}
64+
runs_on: ${{ matrix.os }}
6365
strategy:
6466
fail-fast: false
6567
matrix:
@@ -77,12 +79,45 @@ jobs:
7779
os_name: macOS
7880
- os: windows-latest
7981
os_name: Windows
82+
install:
83+
name: Install (Python ${{ matrix.python }} on ${{ matrix.os_name }})
84+
runs-on: ${{ matrix.os }}
85+
timeout-minutes: 30
86+
needs: build
87+
strategy:
88+
fail-fast: false
89+
matrix:
90+
os:
91+
- ubuntu-latest
92+
- macos-latest
93+
python:
94+
- '3.10'
95+
- '3.11'
96+
include:
97+
- os: ubuntu-latest
98+
os_name: Linux
99+
- os: macos-latest
100+
os_name: macOS
80101
steps:
81-
- name: Checkout
82-
uses: actions/checkout@v3
83-
- name: Setup
84-
uses: ./.github/actions/setup
102+
- name: Setup Python
103+
uses: actions/setup-python@v4
85104
with:
86-
python_version: ${{ matrix.python }}
87-
- name: Build
88-
run: make build
105+
python-version: ${{ matrix.python }}
106+
- name: Download artifact
107+
uses: actions/download-artifact@v3
108+
with:
109+
name: ${{ needs.build.outputs.artifact_name }}
110+
path: .
111+
- name: Get meta
112+
id: meta
113+
run: echo "whl=$(ls *.whl | head -n1)" >> $GITHUB_OUTPUT
114+
- name: Install
115+
run: pip install $PACKAGE
116+
env:
117+
PACKAGE: ${{ steps.meta.outputs.whl }}
118+
- name: Import
119+
run: echo "import $PACKAGE_IMPORT_NAME" > main.py
120+
env:
121+
PACKAGE_IMPORT_NAME: makenew_pypackage
122+
- name: Run
123+
run: python main.py

.github/workflows/publish.yml

+9-21
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,21 @@ on:
99
- v*
1010

1111
jobs:
12-
artifacts:
13-
name: Build artifacts
14-
runs-on: ubuntu-latest
15-
timeout-minutes: 30
16-
steps:
17-
- name: Checkout
18-
uses: actions/checkout@v3
19-
- name: Setup
20-
uses: ./.github/actions/setup
21-
- name: Build
22-
run: make build
23-
- name: Upload artifacts
24-
uses: actions/upload-artifact@v3
25-
with:
26-
name: ${{ github.sha }}
27-
if-no-files-found: error
28-
path: dist/
12+
build:
13+
name: Build
14+
uses: ./.github/workflows/_build.yml
2915
release:
3016
name: GitHub Releases
3117
runs-on: ubuntu-latest
3218
timeout-minutes: 30
33-
needs: artifacts
19+
needs: build
3420
steps:
3521
- name: Checkout
3622
uses: actions/checkout@v3
37-
- name: Download artifacts
23+
- name: Download artifact
3824
uses: actions/download-artifact@v3
3925
with:
40-
name: ${{ github.sha }}
26+
name: ${{ needs.build.outputs.artifact_name }}
4127
path: dist/
4228
- name: Create GitHub release
4329
uses: softprops/action-gh-release@v1
@@ -49,6 +35,8 @@ jobs:
4935
pypi:
5036
name: PyPI
5137
uses: ./.github/workflows/_publish.yml
52-
needs: artifacts
38+
needs: build
39+
with:
40+
artifact_name: ${{ needs.build.outputs.artifact_name }}
5341
secrets:
5442
registry_token: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)