Skip to content

Commit e4c7602

Browse files
committed
Move compile binary into reusable step
1 parent 6c10d2f commit e4c7602

File tree

2 files changed

+89
-58
lines changed

2 files changed

+89
-58
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,12 @@ jobs:
7777
# Compile the binaries and upload artifacts
7878
compile-binaries:
7979
strategy:
80-
fail-fast: false
80+
fail-fast: true
8181
matrix:
8282
include:
8383
- os: ubuntu-latest
8484
package-suffix: linux-amd64
8585
ci-arch: auto
86-
- os: ubuntu-latest
87-
package-suffix: linux-aarch64
88-
ci-arch: aarch64
8986
- os: macos-latest
9087
package-suffix: macos-amd64
9188
ci-arch: auto
@@ -96,59 +93,21 @@ jobs:
9693
- os: windows-latest
9794
package-suffix: windows-amd64
9895
ci-arch: auto
99-
runs-on: ${{ matrix.os }}
100-
continue-on-error: true
101-
steps:
102-
- uses: actions/checkout@v2
103-
with:
104-
submodules: recursive
105-
- uses: actions/setup-python@v1
106-
with:
107-
python-version: "3.10"
96+
uses: ./.github/workflows/compile-binary.yml
97+
with:
98+
os: ${{ matrix.os }}
99+
package-suffix: ${{ matrix.package-suffix }}
100+
ci-arch: ${{ matrix.ci-arch }}
101+
rust-add-target: ${{ matrix.rust-add-target }}
108102

109-
# Install Rust locally for non-Linux (Linux uses an internal docker
110-
# command to build with cibuildwheel which uses rustup install defined
111-
# in pyproject.toml)
112-
- if: ${{ runner.os != 'Linux' }}
113-
uses: actions-rs/toolchain@v1
114-
with:
115-
toolchain: stable
116-
target: ${{ matrix.rust-add-target }}
117-
- if: ${{ runner.os != 'Linux' }}
118-
uses: Swatinem/rust-cache@v1
119-
with:
120-
working-directory: temporalio/bridge
121-
122-
# Need QEMU for ARM build on Linux
123-
- if: ${{ matrix.package-suffix == 'linux-aarch64' }}
124-
uses: docker/setup-qemu-action@v1
125-
with:
126-
image: tonistiigi/binfmt:latest
127-
platforms: arm64
128-
129-
# Prepare
130-
- run: python -m pip install --upgrade wheel poetry poethepoet
131-
- run: poetry install --no-root
132-
133-
# Add the source dist only for Linux x64 for now
134-
- if: ${{ matrix.package-suffix == 'linux-amd64' }}
135-
run: poetry build --format sdist
136-
137-
# Build and fix the wheel
138-
- run: poetry run cibuildwheel --output-dir dist --arch ${{ matrix.ci-arch }}
139-
- run: poe fix-wheel
140-
141-
# Do test only for ci-arch auto (i.e. local machine)
142-
- if: ${{ matrix.ci-arch == 'auto' }}
143-
uses: actions/setup-go@v2
144-
with:
145-
go-version: "1.18"
146-
- if: ${{ matrix.ci-arch == 'auto' }}
147-
run: poe test-dist-single
148-
149-
# Upload dist
150-
- uses: actions/upload-artifact@v2
151-
with:
152-
name: packages-${{ matrix.package-suffix }}
153-
path: dist
103+
# We separate out Linux aarch64 because it is too slow to build every PR, so
104+
# we only build on push. When we have a ARM Linux runner or invest the time
105+
# into not using QEMU, we may move back.
106+
compile-binaries-linux-aarch64:
107+
if: ${{ github.event_name != 'pull_request' }}
108+
uses: ./.github/workflows/compile-binary.yml
109+
with:
110+
os: ubuntu-latest
111+
package-suffix: linux-aarch64
112+
ci-arch: aarch64
154113

.github/workflows/compile-binary.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Compile Binary
2+
on:
3+
workflow_call:
4+
inputs:
5+
os:
6+
required: true
7+
type: string
8+
package-suffix:
9+
required: true
10+
type: string
11+
ci-arch:
12+
required: true
13+
type: string
14+
rust-add-target:
15+
type: string
16+
17+
jobs:
18+
compile-binaries:
19+
runs-on: ${{ inputs.os }}
20+
steps:
21+
- uses: actions/checkout@v2
22+
with:
23+
submodules: recursive
24+
- uses: actions/setup-python@v1
25+
with:
26+
python-version: "3.10"
27+
28+
# Install Rust locally for non-Linux (Linux uses an internal docker
29+
# command to build with cibuildwheel which uses rustup install defined
30+
# in pyproject.toml)
31+
- if: ${{ runner.os != 'Linux' }}
32+
uses: actions-rs/toolchain@v1
33+
with:
34+
toolchain: stable
35+
target: ${{ inputs.rust-add-target }}
36+
- if: ${{ runner.os != 'Linux' }}
37+
uses: Swatinem/rust-cache@v1
38+
with:
39+
working-directory: temporalio/bridge
40+
41+
# Need QEMU for ARM build on Linux
42+
- if: ${{ inputs.package-suffix == 'linux-aarch64' }}
43+
uses: docker/setup-qemu-action@v1
44+
with:
45+
image: tonistiigi/binfmt:latest
46+
platforms: arm64
47+
48+
# Prepare
49+
- run: python -m pip install --upgrade wheel poetry poethepoet
50+
- run: poetry install --no-root
51+
52+
# Add the source dist only for Linux x64 for now
53+
- if: ${{ inputs.package-suffix == 'linux-amd64' }}
54+
run: poetry build --format sdist
55+
56+
# Build and fix the wheel
57+
- run: poetry run cibuildwheel --output-dir dist --arch ${{ inputs.ci-arch }}
58+
- run: poe fix-wheel
59+
60+
# Do test only for ci-arch auto (i.e. local machine)
61+
- if: ${{ inputs.ci-arch == 'auto' }}
62+
uses: actions/setup-go@v2
63+
with:
64+
go-version: "1.18"
65+
- if: ${{ inputs.ci-arch == 'auto' }}
66+
run: poe test-dist-single
67+
68+
# Upload dist
69+
- uses: actions/upload-artifact@v2
70+
with:
71+
name: packages-${{ inputs.package-suffix }}
72+
path: dist

0 commit comments

Comments
 (0)