Skip to content

Commit e94cf29

Browse files
committed
Split build-python-package to its own action
1 parent c2fe28e commit e94cf29

File tree

3 files changed

+77
-36
lines changed

3 files changed

+77
-36
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Build emsarray Python package
2+
description: Build the emsarray Python package in both tarball and wheel formats.
3+
inputs:
4+
python-version:
5+
description: Python version to use.
6+
required: true
7+
artifact-name:
8+
description: Name of the uploaded artifact
9+
required: false
10+
default: "Python package"
11+
12+
outputs:
13+
artifact-name:
14+
description: Name of the uploaded artifact
15+
value: ${{ inputs.artifact-name }}
16+
17+
runs:
18+
using: composite
19+
20+
steps:
21+
- uses: actions/checkout@v3
22+
- uses: actions/setup-python@v4
23+
with:
24+
python-version: ${{ inputs.python-version }}
25+
cache: 'pip'
26+
27+
- name: Build python package
28+
shell: bash -l {0}
29+
run: |
30+
pip install build
31+
python3 -m build
32+
33+
- uses: actions/upload-artifact@v3
34+
with:
35+
name: ${{ inputs.artifact-name }}
36+
path: dist

.github/actions/environment/action.yaml

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ inputs:
44
python-version:
55
description: Python version to install. Used as a Conda version constraint.
66
required: true
7+
package-artifact-name:
8+
description: Name of the emsarray Python package artifact
9+
required: false
10+
default: "Python package"
711

812
runs:
913
using: composite
@@ -13,26 +17,36 @@ runs:
1317
- uses: actions/setup-python@v4
1418
with:
1519
cache: 'pip'
20+
cache-dependency-path: |
21+
continuous-integration/requirements.txt
22+
continuous-integration/environment.yaml
23+
setup.cfg
1624
python-version: ${{ inputs.python-version }}
1725

18-
- name: Fetch Python package
26+
- name: Fetch built emsarray package
1927
uses: actions/download-artifact@v3
2028
with:
21-
name: "Python package"
29+
name: ${{ inputs.python-artifact-name }}
2230
path: "dist/"
2331

32+
- name: Cache conda packages
33+
uses: actions/cache@v2
34+
with:
35+
path: ~/conda_pkgs_dir
36+
key:
37+
${{ runner.os }}-conda-${{
38+
hashFiles('continuous-integration/environment.yaml') }}
39+
2440
- name: Install base Conda environment
25-
uses: mamba-org/provision-with-micromamba@main
41+
uses: conda-incubator/setup-miniconda@v2
2642
with:
27-
cache-downloads: true
28-
cache-env: false
29-
channels: conda-forge
3043
environment-file: continuous-integration/environment.yaml
31-
environment-name: continuous-integration
32-
extra-specs: |
33-
python=${{ inputs.python-version }}
34-
wheel
35-
pip
44+
python-version: ${{ inputs.python-version }}
45+
channels: conda-forge
46+
- shell: bash -l {0}
47+
run: |
48+
conda install -c conda-forge wheel
49+
3650
3751
- name: Install Python packages
3852
shell: bash -l {0}

.github/workflows/ci.yaml

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,20 @@ on:
1111

1212
workflow_dispatch:
1313

14+
env:
15+
python-version: "3.11"
16+
1417
jobs:
1518
build:
1619
runs-on: ubuntu-latest
17-
env:
18-
python_version: "3.11"
20+
outputs:
21+
artifact-name: ${{ steps.build.outputs.artifact-name }}
1922
steps:
2023
- uses: actions/checkout@v3
21-
22-
- uses: actions/setup-python@v4
24+
- uses: ./.github/actions/build-python-package
25+
id: build
2326
with:
24-
python-version: ${{ env.python_version }}
25-
cache: 'pip'
26-
27-
- name: Build python package
28-
shell: bash -l {0}
29-
run: |
30-
pip install build
31-
python3 -m build
32-
33-
- uses: actions/upload-artifact@v3
34-
with:
35-
name: "Python package"
36-
path: dist
27+
python-version: ${{ env.python-version }}
3728

3829
test:
3930
runs-on: ubuntu-latest
@@ -50,6 +41,7 @@ jobs:
5041
- uses: ./.github/actions/environment
5142
with:
5243
python-version: ${{ matrix.python-version }}
44+
package-artifact-name: ${{ needs.build.outputs.artifact-name }}
5345

5446
- name: Run tests
5547
shell: bash -l {0}
@@ -80,20 +72,18 @@ jobs:
8072
run:
8173
shell: bash -l {0}
8274

83-
env:
84-
python_version: "3.11"
85-
8675
steps:
8776
- uses: actions/checkout@v3
8877
- uses: ./.github/actions/environment
8978
with:
90-
python-version: ${{ env.python_version }}
79+
python-version: ${{ env.python-version }}
80+
package-artifact-name: ${{ needs.build.outputs.artifact-name }}
9181

9282
- name: 'mypy cache'
9383
uses: actions/cache@v3
9484
with:
9585
path: '.mypy_cache'
96-
key: mypy-${{ runner.os }}-py${{ env.python_version }}-${{ hashFiles('requirements.txt') }}
86+
key: mypy-${{ runner.os }}-py${{ env.python-version }}-${{ hashFiles('requirements.txt') }}
9787

9888
- run: flake8 src/ tests/
9989
- run: isort --diff --check-only src/ tests/
@@ -112,7 +102,8 @@ jobs:
112102
- uses: actions/checkout@v3
113103
- uses: ./.github/actions/environment
114104
with:
115-
python-version: "3.11"
105+
python-version: ${{ env.python-version }}
106+
package-artifact-name: ${{ needs.build.outputs.artifact-name }}
116107

117108
- run: |
118109
cd docs/
@@ -126,14 +117,14 @@ jobs:
126117
publish:
127118
runs-on: ubuntu-latest
128119
timeout-minutes: 5
129-
needs: ['test', 'lint', 'docs']
120+
needs: ['build', 'test', 'lint', 'docs']
130121
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
131122

132123
steps:
133124
- name: Fetch Python package
134125
uses: actions/download-artifact@v3
135126
with:
136-
name: "Python package"
127+
name: ${{ needs.build.outputs.artifact-name }}
137128
path: "dist"
138129

139130
- name: "Check tag matches version"

0 commit comments

Comments
 (0)