Skip to content

Commit 00bd819

Browse files
authored
Only run macos/windows tests in certain cases. (#2185)
1 parent 5d66803 commit 00bd819

4 files changed

Lines changed: 170 additions & 54 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: 'Build and Test Rust'
2+
description: 'Common build and test steps for Rust projects'
3+
inputs:
4+
target:
5+
description: 'Rust target triple'
6+
required: true
7+
rust-version:
8+
description: 'Rust version (msrv or latest)'
9+
required: true
10+
default: 'latest'
11+
runs:
12+
using: 'composite'
13+
steps:
14+
- uses: stellar/actions/rust-cache@main
15+
- name: Use the minimum supported Rust version
16+
if: ${{ inputs.rust-version == 'msrv' }}
17+
shell: bash
18+
run: |
19+
msrv="$(cargo metadata --format-version 1 --no-deps | jq -r '.packages | map(.rust_version) | map(values) | min')"
20+
rustup override set $msrv
21+
rustup component add clippy --toolchain $msrv
22+
- run: rustup update
23+
shell: bash
24+
- run: cargo version
25+
shell: bash
26+
- run: rustup target add ${{ inputs.target }}
27+
shell: bash
28+
- run: rustup target add wasm32v1-none
29+
shell: bash
30+
- if: runner.os == 'Linux'
31+
run: sudo apt-get update && sudo apt-get -y install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libudev-dev libdbus-1-dev
32+
shell: bash
33+
- run: cargo clippy --all-targets --target ${{ inputs.target }}
34+
shell: bash
35+
- run: make test
36+
shell: bash
37+
env:
38+
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
39+
CARGO_BUILD_TARGET: ${{ inputs.target }}
40+
CI_TESTS: true
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: 'Build Binary'
2+
description: 'Common binary build steps'
3+
inputs:
4+
target:
5+
description: 'Rust target triple'
6+
required: true
7+
crate-name:
8+
description: 'Crate name to build'
9+
required: true
10+
binary-name:
11+
description: 'Binary name'
12+
required: true
13+
binary-ext:
14+
description: 'Binary extension (e.g. .exe for Windows)'
15+
required: false
16+
default: ''
17+
runs:
18+
using: 'composite'
19+
steps:
20+
- run: rustup update
21+
shell: bash
22+
- run: rustup target add ${{ inputs.target }}
23+
shell: bash
24+
- if: runner.os == 'Linux'
25+
run: sudo apt-get update && sudo apt-get -y install libudev-dev libdbus-1-dev
26+
shell: bash
27+
- name: Setup vars
28+
shell: bash
29+
run: |
30+
version="$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "${{ inputs.crate-name }}") | .version')"
31+
echo "VERSION=${version}" >> $GITHUB_ENV
32+
echo "NAME=${{ inputs.crate-name }}-${version}-${{ inputs.target }}" >> $GITHUB_ENV
33+
- name: Build
34+
shell: bash
35+
run: cargo build --package ${{ inputs.crate-name }} --release --target ${{ inputs.target }}
36+
- name: Build provenance for binary attestation (release only)
37+
if: github.event_name == 'release'
38+
uses: actions/attest-build-provenance@v3
39+
with:
40+
subject-path: target/${{ inputs.target }}/release/${{ inputs.binary-name }}${{ inputs.binary-ext }}
41+
- name: Compress
42+
shell: bash
43+
run: |
44+
cd target/${{ inputs.target }}/release
45+
tar czvf $NAME.tar.gz ${{ inputs.binary-name }}${{ inputs.binary-ext }}
46+
- name: Upload to Artifacts
47+
uses: ./.github/actions/artifact-upload
48+
with:
49+
name: ${{ env.NAME }}.tar.gz
50+
path: 'target/${{ inputs.target }}/release/${{ env.NAME }}.tar.gz'

.github/workflows/binaries.yml

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -32,49 +32,61 @@ jobs:
3232
target: x86_64-unknown-linux-gnu
3333
- os: ubuntu-22.04-arm # Use 22 to get an older version of glibc for increased compat
3434
target: aarch64-unknown-linux-gnu
35+
runs-on: ${{ matrix.sys.os }}
36+
steps:
37+
- uses: actions/checkout@v5
38+
- uses: ./.github/actions/build-binary
39+
with:
40+
target: ${{ matrix.sys.target }}
41+
crate-name: ${{ matrix.crate.name }}
42+
binary-name: ${{ matrix.crate.binary }}
43+
44+
build-macos:
45+
if: github.event_name == 'release' || (github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')))
46+
strategy:
47+
fail-fast: false
48+
matrix:
49+
crate:
50+
- name: stellar-cli
51+
binary: stellar
52+
sys:
3553
- os: macos-14
3654
target: aarch64-apple-darwin
3755
- os: macos-13
3856
target: x86_64-apple-darwin
57+
runs-on: ${{ matrix.sys.os }}
58+
steps:
59+
- uses: actions/checkout@v5
60+
- uses: ./.github/actions/build-binary
61+
with:
62+
target: ${{ matrix.sys.target }}
63+
crate-name: ${{ matrix.crate.name }}
64+
binary-name: ${{ matrix.crate.binary }}
65+
66+
build-windows:
67+
if: github.event_name == 'release' || (github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')))
68+
strategy:
69+
fail-fast: false
70+
matrix:
71+
crate:
72+
- name: stellar-cli
73+
binary: stellar
74+
sys:
3975
- os: windows-latest
4076
target: x86_64-pc-windows-msvc
4177
ext: .exe
4278
runs-on: ${{ matrix.sys.os }}
4379
steps:
44-
- uses: actions/checkout@v5
45-
- run: rustup update
46-
- run: rustup target add ${{ matrix.sys.target }}
47-
48-
- if: runner.os == 'Linux'
49-
run: sudo apt-get update && sudo apt-get -y install libudev-dev libdbus-1-dev
50-
51-
- name: Setup vars
52-
run: |
53-
version="$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "stellar-cli") | .version')"
54-
echo "VERSION=${version}" >> $GITHUB_ENV
55-
echo "NAME=${{ matrix.crate.name }}-${version}-${{ matrix.sys.target }}" >> $GITHUB_ENV
56-
57-
- name: Build
58-
run: |
59-
cargo build --package ${{ matrix.crate.name }} --release --target ${{ matrix.sys.target }}
60-
- name: Build provenance for binary attestation (release only)
61-
if: github.event_name == 'release'
62-
uses: actions/attest-build-provenance@v3
63-
with:
64-
subject-path: target/${{ matrix.sys.target }}/release/${{ matrix.crate.binary }}${{ matrix.sys.ext }}
65-
- name: Compress
66-
run: |
67-
cd target/${{ matrix.sys.target }}/release
68-
tar czvf $NAME.tar.gz ${{ matrix.crate.binary }}${{ matrix.sys.ext }}
69-
70-
- name: Upload to Artifacts
71-
uses: ./.github/actions/artifact-upload
72-
with:
73-
name: ${{ env.NAME }}.tar.gz
74-
path: 'target/${{ matrix.sys.target }}/release/${{ env.NAME }}.tar.gz'
80+
- uses: actions/checkout@v5
81+
- uses: ./.github/actions/build-binary
82+
with:
83+
target: ${{ matrix.sys.target }}
84+
crate-name: ${{ matrix.crate.name }}
85+
binary-name: ${{ matrix.crate.binary }}
86+
binary-ext: ${{ matrix.sys.ext }}
7587

7688
installer:
77-
needs: build
89+
needs: [build, build-macos, build-windows]
7890
runs-on: windows-latest
7991
steps:
8092
- uses: actions/checkout@v5

.github/workflows/rust.yml

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ jobs:
2424
cargo-deny,
2525
check-generated-full-help-docs,
2626
build-and-test,
27+
build-and-test-macos,
28+
build-and-test-windows,
2729
disallow-git-deps,
2830
publish-dry-run,
2931
]
@@ -74,37 +76,49 @@ jobs:
7476
target: x86_64-unknown-linux-gnu
7577
- os: ubuntu-jammy-8-cores-arm64
7678
target: aarch64-unknown-linux-gnu
79+
runs-on: ${{ matrix.sys.os }}
80+
steps:
81+
- uses: actions/checkout@v5
82+
- uses: ./.github/actions/build-and-test
83+
with:
84+
target: ${{ matrix.sys.target }}
85+
rust-version: ${{ matrix.rust }}
86+
87+
build-and-test-macos:
88+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/'))
89+
strategy:
90+
fail-fast: false
91+
matrix:
92+
rust: [msrv, latest]
93+
sys:
7794
- os: macos-13
7895
target: x86_64-apple-darwin
7996
- os: macos-latest
8097
target: aarch64-apple-darwin
98+
runs-on: ${{ matrix.sys.os }}
99+
steps:
100+
- uses: actions/checkout@v5
101+
- uses: ./.github/actions/build-and-test
102+
with:
103+
target: ${{ matrix.sys.target }}
104+
rust-version: ${{ matrix.rust }}
105+
106+
build-and-test-windows:
107+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/'))
108+
strategy:
109+
fail-fast: false
110+
matrix:
111+
rust: [msrv, latest]
112+
sys:
81113
- os: windows-latest-8-cores
82114
target: x86_64-pc-windows-msvc
83115
runs-on: ${{ matrix.sys.os }}
84-
env:
85-
CI_TESTS: true
86116
steps:
87117
- uses: actions/checkout@v5
88-
- uses: stellar/actions/rust-cache@main
89-
- name: Use the minimum supported Rust version
90-
if: matrix.rust == 'msrv'
91-
run: |
92-
msrv="$(cargo metadata --format-version 1 --no-deps | jq -r '.packages | map(.rust_version) | map(values) | min')"
93-
rustup override set $msrv
94-
rustup component add clippy --toolchain $msrv
95-
- run: rustup update
96-
- run: cargo version
97-
- run: rustup target add ${{ matrix.sys.target }}
98-
- run: rustup target add wasm32v1-none
99-
- if: runner.os == 'Linux'
100-
run:
101-
sudo apt-get update && sudo apt-get -y install gcc-aarch64-linux-gnu
102-
g++-aarch64-linux-gnu libudev-dev libdbus-1-dev
103-
- run: cargo clippy --all-targets --target ${{ matrix.sys.target }}
104-
- run: make test
105-
env:
106-
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
107-
CARGO_BUILD_TARGET: ${{ matrix.sys.target }}
118+
- uses: ./.github/actions/build-and-test
119+
with:
120+
target: ${{ matrix.sys.target }}
121+
rust-version: ${{ matrix.rust }}
108122

109123
disallow-git-deps:
110124
# This job fails if a release is being prepared and there are still crate

0 commit comments

Comments
 (0)