This repository has been archived by the owner on Oct 28, 2023. It is now read-only.
generated from EmbarkStudios/opensource-template
-
Notifications
You must be signed in to change notification settings - Fork 83
197 lines (182 loc) · 6.13 KB
/
ci.yaml
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
on:
push:
branches:
- main
tags:
- "*"
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
name: CI
jobs:
lint:
name: Lint
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
# make sure all code has been formatted with rustfmt
- run: rustup component add rustfmt
- name: check rustfmt
run: cargo fmt -- --check --color always
# run clippy to verify we have no warnings
- run: cargo fetch
- run: rustup component add clippy
- name: cargo clippy
run: cargo clippy --all-targets -- -D warnings
test:
name: Test
strategy:
matrix:
os: [ubuntu-20.04, windows-latest, macOS-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Install build deps
if: matrix.os == 'ubuntu-20.04'
run: |
sudo apt-get install -y libxkbcommon-x11-dev
- run: cargo fetch
- name: cargo test build
run: cargo build --tests --release --all-features
- name: cargo test
run: cargo test --release --all-features
build:
name: Build WASM
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: wasm32-wasi
override: true
- run: cargo fetch
- name: cargo build
run: cargo build --target wasm32-wasi
deny-check:
name: cargo-deny
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: EmbarkStudios/cargo-deny-action@v1
publish-check:
name: Publish Check
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Install build deps
run: |
sudo apt-get install -y libxkbcommon-x11-dev
- run: cargo fetch
- name: copy README
shell: bash
run: |
cp README.md lib
cp README.md cli
- name: cargo publish lib
run: cargo publish --dry-run --allow-dirty --manifest-path lib/Cargo.toml
release:
name: Release
needs: [test, deny-check]
if: startsWith(github.ref, 'refs/tags/')
strategy:
matrix:
include:
- os: ubuntu-20.04
rust: stable
target: x86_64-unknown-linux-musl
bin: texture-synthesis
# We don't enable the progress feature when targeting
# musl since there are some dependencies on shared libs
features: ""
- os: windows-latest
rust: stable
target: x86_64-pc-windows-msvc
bin: texture-synthesis.exe
features: --features=progress
- os: macOS-latest
rust: stable
target: x86_64-apple-darwin
bin: texture-synthesis
features: --features=progress
- os: macOS-latest
rust: stable
target: aarch64-apple-darwin
bin: texture-synthesis
features: --features=progress
runs-on: ${{ matrix.os }}
steps:
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
override: true
target: ${{ matrix.target }}
- name: Install build deps
if: matrix.os == 'ubuntu-20.04'
run: |
sudo apt-get install -y musl-tools libxkbcommon-x11-dev
- name: Workaround xcode shenanigans
if: matrix.target == 'aarch64-apple-darwin'
# https://github.com/actions/virtual-environments/issues/2557#issuecomment-769611326
run: |
sudo xcode-select -s "/Applications/Xcode_12.3.app"
sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*
- name: Checkout
uses: actions/checkout@v2
- name: cargo fetch
run: cargo fetch --target ${{ matrix.target }}
- name: Release build
run: cargo build --manifest-path cli/Cargo.toml --release --target ${{ matrix.target }} ${{ matrix.features }}
- name: Package
shell: bash
run: |
name=texture-synthesis
tag=$(git describe --tags --abbrev=0)
release_name="$name-$tag-${{ matrix.target }}"
# Archive in .zip for Windows, .tar.gz for other platforms
if [ "${{ matrix.os }}" == "windows-latest" ]; then
release_archive="${release_name}.zip"
else
release_archive="${release_name}.tar.gz"
fi
mkdir "$release_name"
if [ "${{ matrix.target }}" != "x86_64-pc-windows-msvc" ]; then
strip "target/${{ matrix.target }}/release/${{ matrix.bin }}"
fi
cp "target/${{ matrix.target }}/release/${{ matrix.bin }}" "$release_name/"
cp README.md LICENSE-APACHE LICENSE-MIT "$release_name/"
# Archive in .zip for Windows, .tar.gz for other platforms
if [ "${{ matrix.os }}" == "windows-latest" ]; then
7z a "$release_archive" "$release_name"
else
tar czvf "$release_archive" "$release_name"
fi
rm -r "$release_name"
# Windows environments in github actions don't have the gnu coreutils installed,
# which includes the shasum exe, so we just use powershell instead
if [ "${{ matrix.os }}" == "windows-latest" ]; then
echo "(Get-FileHash \"${release_archive}\" -Algorithm SHA256).Hash | Out-File -Encoding ASCII -NoNewline \"${release_archive}.sha256\"" | pwsh -c -
else
echo -n "$(shasum -ba 256 "${release_archive}" | cut -d " " -f 1)" > "${release_archive}.sha256"
fi
- name: Publish
uses: softprops/action-gh-release@v1
with:
draft: true
files: "texture-synthesis*"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}