Skip to content

Commit d1030e5

Browse files
authored
Merge pull request #549 from nickelc/gh-actions
Add GitHub workflows for CI and Release
2 parents 82eae24 + f57649e commit d1030e5

File tree

3 files changed

+420
-0
lines changed

3 files changed

+420
-0
lines changed

.github/workflows/ci.yml

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
name: CI
2+
3+
on: [pull_request, push]
4+
5+
jobs:
6+
format:
7+
name: Rustfmt
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v2
13+
14+
- name: Install rust
15+
uses: actions-rs/toolchain@v1
16+
with:
17+
toolchain: stable
18+
components: rustfmt
19+
profile: minimal
20+
override: true
21+
22+
- name: Run rustfmt
23+
uses: actions-rs/cargo@v1
24+
with:
25+
command: fmt
26+
args: --all -- --check
27+
28+
clippy:
29+
name: Clippy
30+
runs-on: ubuntu-latest
31+
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v2
35+
36+
- name: Install packages
37+
run: |
38+
sudo apt-get update
39+
sudo apt-get -yq --no-install-suggests --no-install-recommends install libasound2-dev libudev-dev
40+
41+
- name: Install rust
42+
uses: actions-rs/toolchain@v1
43+
with:
44+
toolchain: stable
45+
components: clippy
46+
profile: minimal
47+
override: true
48+
49+
- name: Run clippy
50+
uses: actions-rs/clippy-check@v1
51+
with:
52+
token: ${{ secrets.GITHUB_TOKEN }}
53+
args: -- -D warnings
54+
55+
assets:
56+
name: Check assets
57+
runs-on: ubuntu-latest
58+
59+
steps:
60+
- name: Checkout
61+
uses: actions/checkout@v2
62+
63+
- name: Checkout assets
64+
uses: actions/checkout@v2
65+
with:
66+
repository: ozkriff/zemeroth_assets
67+
path: assets
68+
69+
- name: Check
70+
run: |
71+
SRC=$(grep "const ASSETS_HASHSUM" src/main.rs | cut -d\" -f 2)
72+
ASSETS=$(cat assets/.checksum.md5)
73+
74+
echo "Source: $SRC"
75+
echo "Assets: $ASSETS"
76+
if [ "$SRC" != "$ASSETS" ]; then
77+
false
78+
fi
79+
80+
build:
81+
name: ${{ matrix.build }}
82+
runs-on: ${{ matrix.os }}
83+
84+
# The build matrix does not yet support 'allow failures' at job level.
85+
# See `jobs.nightly` for the nightly job definition.
86+
strategy:
87+
matrix:
88+
build: [Linux, macOS, Win32, Win64]
89+
90+
include:
91+
- build: Linux
92+
os: ubuntu-latest
93+
packages: libasound2-dev libudev-dev
94+
- build: macOS
95+
os: macOS-latest
96+
- build: Win32
97+
os: windows-latest
98+
rust: stable-i686-pc-windows-msvc
99+
target: i686-pc-windows-msvc
100+
- build: Win64
101+
os: windows-latest
102+
103+
steps:
104+
- name: Checkout
105+
uses: actions/checkout@v2
106+
107+
- name: Install packages (Linux)
108+
if: runner.os == 'Linux' && matrix.packages
109+
run: |
110+
sudo apt-get update
111+
sudo apt-get -yq --no-install-suggests --no-install-recommends install ${{ matrix.packages }}
112+
113+
- name: Install rust
114+
uses: actions-rs/toolchain@v1
115+
with:
116+
toolchain: ${{ matrix.rust || 'stable' }}
117+
target: ${{ matrix.target }}
118+
profile: minimal
119+
override: true
120+
121+
- name: Build
122+
uses: actions-rs/cargo@v1
123+
with:
124+
command: build
125+
args: --examples --all
126+
127+
- name: Test
128+
uses: actions-rs/cargo@v1
129+
with:
130+
command: test
131+
args: --all
132+
133+
wasm:
134+
name: WASM
135+
runs-on: ubuntu-latest
136+
137+
steps:
138+
- name: Checkout
139+
uses: actions/checkout@v2
140+
141+
- name: Install rust
142+
uses: actions-rs/toolchain@v1
143+
with:
144+
toolchain: stable
145+
target: wasm32-unknown-unknown
146+
profile: minimal
147+
override: true
148+
149+
- name: Install cargo-web
150+
run: |
151+
CARGO_WEB_RELEASE=$(curl -L -s -H 'Accept: application/json' https://github.com/koute/cargo-web/releases/latest)
152+
CARGO_WEB_VERSION=$(echo $CARGO_WEB_RELEASE | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
153+
CARGO_WEB_HOST_TRIPLE="x86_64-unknown-linux-gnu"
154+
CARGO_WEB_URL="https://github.com/koute/cargo-web/releases/download/$CARGO_WEB_VERSION/cargo-web-$CARGO_WEB_HOST_TRIPLE.gz"
155+
156+
echo "Downloading cargo-web from: $CARGO_WEB_URL"
157+
curl -L $CARGO_WEB_URL | gzip -d > cargo-web
158+
chmod +x cargo-web
159+
160+
mkdir -p ~/.cargo/bin
161+
mv cargo-web ~/.cargo/bin
162+
163+
- name: Build
164+
run: |
165+
cargo web build
166+
167+
nightly:
168+
name: Nightly
169+
runs-on: ${{ matrix.os }}
170+
171+
strategy:
172+
matrix:
173+
os: [ubuntu-latest, windows-latest, macOS-latest]
174+
175+
include:
176+
- os: ubuntu-latest
177+
packages: libasound2-dev libudev-dev
178+
179+
steps:
180+
- name: Checkout
181+
uses: actions/checkout@v2
182+
183+
- name: Install packages (Linux)
184+
if: runner.os == 'Linux' && matrix.packages
185+
run: |
186+
sudo apt-get update
187+
sudo apt-get -yq --no-install-suggests --no-install-recommends install ${{ matrix.packages }}
188+
189+
- name: Install rust
190+
uses: actions-rs/toolchain@v1
191+
with:
192+
toolchain: nightly
193+
profile: minimal
194+
override: true
195+
196+
- name: Build
197+
continue-on-error: true
198+
uses: actions-rs/cargo@v1
199+
with:
200+
command: build
201+
args: --examples --all
202+
203+
- name: Test
204+
continue-on-error: true
205+
uses: actions-rs/cargo@v1
206+
with:
207+
command: test
208+
args: --all

0 commit comments

Comments
 (0)