Repository navigation
107 lines (102 loc) · 3.45 KB
/
Copy pathci.yml
File metadata and controls
107 lines (102 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: ci
on:
push:
branches: ["**"]
tags: ["v*"]
pull_request:
# The Go binding links rgbconsignment/lib/<GOOS>_<GOARCH>/librgb_consignment.a,
# and those archives are committed so that `go get` works without a Rust
# toolchain. `libs` rebuilds all four whenever the Rust side changes and
# `commit-libs` pushes them back to the branch; `test` runs against whatever
# archive is committed.
jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, macos-15]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: actions/setup-go@v5
with:
go-version: "1.22"
- run: cargo fmt --check
- run: cargo test
- run: go vet ./rgbconsignment && go test ./rgbconsignment
libs:
# Only the Rust side changes the archive; skip on Go/doc-only pushes.
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/')
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
targets: "x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu"
- os: macos-15
targets: "aarch64-apple-darwin x86_64-apple-darwin"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: tj-actions/changed-files@v45
id: rust
with:
files: |
src/**
Cargo.toml
Cargo.lock
scripts/build-lib.sh
- if: steps.rust.outputs.any_changed == 'true'
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.targets }}
- if: steps.rust.outputs.any_changed == 'true'
uses: Swatinem/rust-cache@v2
with:
key: lib-${{ matrix.os }}
- if: steps.rust.outputs.any_changed == 'true' && runner.os == 'Linux'
name: Cross toolchain for aarch64
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
{
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc"
echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc"
echo "AR_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ar"
} >> "$GITHUB_ENV"
- if: steps.rust.outputs.any_changed == 'true'
uses: actions/setup-go@v5
with:
go-version: "1.22"
- if: steps.rust.outputs.any_changed == 'true'
name: Build archives
run: |
for t in ${{ matrix.targets }}; do ./scripts/build-lib.sh "$t"; done
- if: steps.rust.outputs.any_changed == 'true'
uses: actions/upload-artifact@v4
with:
name: libs-${{ matrix.os }}
path: rgbconsignment/lib/*/librgb_consignment.a
if-no-files-found: error
commit-libs:
needs: libs
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
- uses: actions/download-artifact@v4
with:
pattern: libs-*
path: rgbconsignment/lib
merge-multiple: true
- name: Commit rebuilt archives
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "chore: rebuild static archives [skip ci]"
file_pattern: rgbconsignment/lib/*/librgb_consignment.a