-
Notifications
You must be signed in to change notification settings - Fork 0
210 lines (202 loc) · 7.18 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
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
198
199
200
201
202
203
204
205
206
207
208
209
210
name: Checks
on: [push, pull_request]
env:
CARGO_TERM_COLOR: always
PLAYDATE_SDK_VERSION: 2.0.3
PLAYDATE_SDK_PATH: ${{ github.workspace }}/PlaydateSDK
jobs:
# Cargo package checks
checks:
runs-on: ubuntu-latest
strategy:
matrix:
target:
- x86_64
- thumbv7em
profile:
- debug
- release
env:
CARGO_BUILD_FLAGS: --target ${{ matrix.target == 'x86_64' && 'x86_64-unknown-linux-gnu' || 'thumbv7em-none-eabihf' }} ${{ matrix.profile == 'release' && '--release' || '' }}
CARGO_TARGET: ${{ matrix.target == 'x86_64' && 'x86_64-unknown-linux-gnu' || 'thumbv7em-none-eabihf' }}
steps:
# Checkout repo
- name: Checkout
uses: actions/checkout@v3
# Install Playdate SDK
- name: Install Playdate SDK
run: |
mkdir PlaydateSDK
curl -L https://download-keycdn.panic.com/playdate_sdk/Linux/PlaydateSDK-${{ env.PLAYDATE_SDK_VERSION }}.tar.gz | tar xz --strip 1 -C PlaydateSDK
# Setup up rust toolchain
- name: Setup Rust Toolchain
uses: dtolnay/rust-toolchain@nightly
with:
targets: ${{ env.CARGO_TARGET }}
components: clippy, rust-src
# Build all projects except playdate-cli
- name: Cargo Build (${{ matrix.target }}, ${{ matrix.profile }})
run: cargo build --workspace ${{ env.CARGO_BUILD_FLAGS }} --exclude playdate-cli
# Test sys package
- name: Cargo Test (${{ matrix.target }}, ${{ matrix.profile }})
run: cargo test -p playdate-rs-sys ${{ env.CARGO_BUILD_FLAGS }}
if: ${{ matrix.target == 'x86_64' }}
# Format checks
- name: Cargo clippy checks
run: cargo clippy ${{ env.CARGO_BUILD_FLAGS }} -- -D warnings
if: ${{ matrix.target == 'x86_64' }}
build-examples:
runs-on: ubuntu-latest
strategy:
matrix:
target:
- x86_64
- thumbv7em
example:
- hello_world
- mandelbrot
env:
CARGO_PROFILE_BUILD_FLAGS: -p playdate-rs ${{ matrix.target == 'thumbv7em' && '--device' || '' }}
CARGO_TARGET: ${{ matrix.target == 'x86_64' && 'x86_64-unknown-linux-gnu' || 'thumbv7em-none-eabihf' }}
steps:
# Install packages
- name: Install gcc-arm-none-eabi
run: |
sudo apt-get update
sudo apt-get install -y gcc-arm-none-eabi
if: ${{ matrix.target == 'thumbv7em' }}
# Checkout repo
- name: Checkout
uses: actions/checkout@v3
# Install Playdate SDK
- name: Install Playdate SDK
run: |
mkdir PlaydateSDK
curl -L https://download-keycdn.panic.com/playdate_sdk/Linux/PlaydateSDK-${{ env.PLAYDATE_SDK_VERSION }}.tar.gz | tar xz --strip 1 -C PlaydateSDK
# Setup up rust toolchain
- name: Setup Rust Toolchain
uses: dtolnay/rust-toolchain@nightly
with:
targets: ${{ env.CARGO_TARGET }}
components: rust-src
# Build examples
- name: Build playdate-rs example (${{ matrix.example }})
run: cargo playdate build --example ${{ matrix.example }} ${{ env.CARGO_PROFILE_BUILD_FLAGS }}
# Cargo format checks
format-checks:
runs-on: ubuntu-latest
steps:
# Checkout repo
- name: Checkout
uses: actions/checkout@v3
# Setup up rust toolchain
- name: Setup Rust Toolchain
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
# Format checks
- name: Cargo fmt checks
run: cargo fmt -- --check
# Playdate CLI integration checks
cli-checks:
runs-on: ubuntu-latest
strategy:
matrix:
target:
- x86_64
- thumbv7em
profile:
- debug
- release
playdate-rs-version:
- head
- crates-io
env:
CARGO_PROFILE_BUILD_FLAGS: ${{ matrix.target == 'thumbv7em' && '--device' || '' }} ${{ matrix.profile == 'release' && '--release' || '' }}
CARGO_TARGET: ${{ matrix.target == 'x86_64' && 'x86_64-unknown-linux-gnu' || 'thumbv7em-none-eabihf' }}
steps:
# Install packages
- name: Install gcc-arm-none-eabi
run: |
sudo apt-get update
sudo apt-get install -y gcc-arm-none-eabi
if: ${{ matrix.target == 'thumbv7em' }}
# Checkout repo
- name: Checkout
uses: actions/checkout@v3
# Install Playdate SDK
- name: Install Playdate SDK
run: |
mkdir PlaydateSDK
curl -L https://download-keycdn.panic.com/playdate_sdk/Linux/PlaydateSDK-${{ env.PLAYDATE_SDK_VERSION }}.tar.gz | tar xz --strip 1 -C PlaydateSDK
# Setup up rust toolchain
- name: Setup Rust Toolchain
uses: dtolnay/rust-toolchain@nightly
with:
targets: ${{ env.CARGO_TARGET }}
components: clippy, rust-src, rustfmt
# Install playdate-cli
- name: Install playdate-cli
run: |
cargo install --path .
rm -r ../.cargo
working-directory: playdate-cli
# Init new project
- name: Init cargo playdate project (crates.io)
run: mkdir new-project && cd new-project && cargo playdate init
if: ${{ matrix.playdate-rs-version == 'crates-io' }}
- name: Init cargo playdate project (head)
run: mkdir new-project && cd new-project && cargo playdate init --use-local-playdate-rs ${{ github.workspace }}/playdate-rs
if: ${{ matrix.playdate-rs-version == 'head' }}
# Build project
- name: Build cargo playdate project
run: cargo playdate build ${{ env.CARGO_PROFILE_BUILD_FLAGS }}
working-directory: new-project
# Format checks
- name: Cargo fmt checks
run: cargo fmt -- --check
working-directory: new-project
- name: Cargo clippy checks
run: cargo clippy -- -D warnings
working-directory: new-project
if: ${{ matrix.target == 'x86_64' }}
# Cargo format checks
build-docs:
runs-on: ubuntu-latest
env:
DOCS_RS: "1"
steps:
# Checkout repo
- name: Checkout
uses: actions/checkout@v3
# Setup up rust toolchain
- name: Setup Rust Toolchain
run: rustup default nightly
# Build docs
- name: Build cargo docs (debug)
run: cargo doc --workspace --no-deps
- name: Build cargo docs (release)
run: cargo doc --workspace --no-deps --release
# Publish packages
publish-crates:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: [checks, format-checks, cli-checks, build-docs, build-examples]
steps:
# Checkout repo
- name: Checkout
uses: actions/checkout@v3
# Install Playdate SDK
- name: Install Playdate SDK
run: |
mkdir PlaydateSDK
curl -L https://download-keycdn.panic.com/playdate_sdk/Linux/PlaydateSDK-${{ env.PLAYDATE_SDK_VERSION }}.tar.gz | tar xz --strip 1 -C PlaydateSDK
# Setup up rust toolchain
- name: Setup Rust Toolchain
uses: dtolnay/rust-toolchain@nightly
# Publish crates
- name: Publish Crates
uses: katyo/publish-crates@v2
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
ignore-unpublished-changes: true