-
Notifications
You must be signed in to change notification settings - Fork 6
171 lines (160 loc) · 5.74 KB
/
ci.yml
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: CI
on:
pull_request:
types:
- opened
- reopened
- synchronize
push:
branches:
- master
env:
CARGO_TERM_COLOR: always
jobs:
extension:
name: Pack MailExtension
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Zip
run: |
pushd ./extension
zip -r -FS ../external-editor-revived.xpi *
- name: Artifacts
uses: actions/upload-artifact@v3
with:
name: thunderbird-extension
retention-days: 60
path: |
external-editor-revived.xpi
messaging_host:
name: Build, lint, and test messaging host
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
target: [x86_64-unknown-linux-gnu, x86_64-unknown-linux-musl]
rust_toolchain: [stable]
experimental: [false]
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
rust_toolchain: nightly
experimental: true
- os: macos-latest
target: x86_64-apple-darwin
rust_toolchain: stable
experimental: false
- os: macos-latest
target: x86_64-apple-darwin
rust_toolchain: nightly
experimental: true
- os: windows-latest
target: x86_64-pc-windows-msvc
rust_toolchain: stable
experimental: false
- os: windows-latest
target: x86_64-pc-windows-msvc
rust_toolchain: nightly
experimental: true
steps:
- uses: actions/checkout@v4
- name: Cancel Previous Runs
if: contains(matrix.os, 'ubuntu')
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Install Rust Toolchain
id: rust_toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust_toolchain }}
components: rustfmt, clippy
- name: Add Linux Targets
if: contains(matrix.os, 'ubuntu')
run: |
rustup target add x86_64-unknown-linux-gnu
rustup target add x86_64-unknown-linux-musl
- name: Add macOS Targets
if: contains(matrix.os, 'macos')
run: |
rustup target add x86_64-apple-darwin
rustup target add aarch64-apple-darwin
- name: Determine Readable Target Name
id: readable_target
shell: bash
run: |
if [[ "${{ matrix.os }}" == "macos"* ]]; then
printf 'name=%s\n' "universal" >> $GITHUB_OUTPUT
exit 0
fi
case "${{ matrix.target }}" in
x86_64-unknown-linux-gnu)
printf 'name=%s\n' "gnu" >> $GITHUB_OUTPUT
;;
x86_64-unknown-linux-musl)
printf 'name=%s\n' "musl" >> $GITHUB_OUTPUT
;;
x86_64-pc-windows-msvc)
printf 'name=%s\n' "msvc" >> $GITHUB_OUTPUT
;;
esac
- name: Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: build-${{ runner.os }}-rustc-${{ steps.rust_toolchain.outputs.cachekey }}-target-${{ steps.readable_target.outputs.name }}-lock-${{ hashFiles('Cargo.lock') }}-git-${{ github.sha }}
restore-keys: |
build-${{ runner.os }}-rustc-${{ steps.rust_toolchain.outputs.cachekey }}-target-${{ steps.readable_target.outputs.name }}-lock-${{ hashFiles('Cargo.lock') }}-
build-${{ runner.os }}-rustc-${{ steps.rust_toolchain.outputs.cachekey }}-target-${{ steps.readable_target.outputs.name }}-
build-${{ runner.os }}-rustc-${{ steps.rust_toolchain.outputs.cachekey }}-
build-${{ runner.os }}-
- name: rustfmt
shell: bash
run: |
cargo fmt -- --check
- name: Clippy
shell: bash
run: |
cargo clippy --locked --target=${{ matrix.target }} -- -D warnings
cargo clippy --locked --tests --target=${{ matrix.target }} -- -D warnings
- name: Build (Linux, Windows)
if: "!contains(matrix.os, 'macos')"
shell: bash
run: |
cargo build --locked --release --target=${{ matrix.target }}
[[ "${{ matrix.os }}" == "windows"* ]] && EXT='.exe' || EXT=''
mv -f "target/${{ matrix.target }}/release/external-editor-revived${EXT}" "target/release/external-editor-revived${EXT}"
- name: Build (macOS, x86_64)
if: contains(matrix.os, 'macos')
shell: bash
run: |
cargo build --locked --release --target=x86_64-apple-darwin
- name: Build (macOS, aarch64)
if: contains(matrix.os, 'macos')
shell: bash
run: |
cargo build --locked --release --target=aarch64-apple-darwin
- name: macOS Universal Binary
if: contains(matrix.os, 'macos')
run: |
mkdir -p target/release/
lipo -create -output target/release/external-editor-revived target/x86_64-apple-darwin/release/external-editor-revived target/aarch64-apple-darwin/release/external-editor-revived
file target/release/external-editor-revived
- name: Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }}-${{ steps.readable_target.outputs.name }}-${{ matrix.rust_toolchain }}-native-messaging-host
retention-days: 60
path: |
target/release/external-editor-revived
target/release/external-editor-revived.exe
- name: Test
shell: bash
run: |
cargo test --locked --release --target=${{ matrix.target }}