Skip to content

Commit 34f9eb9

Browse files
authored
Migrate to GitHub Actions CI (#27)
1 parent 8cab50b commit 34f9eb9

File tree

9 files changed

+73
-63
lines changed

9 files changed

+73
-63
lines changed

.github/workflows/build.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: rust
2+
3+
on: [ push, pull_request ]
4+
5+
jobs:
6+
default:
7+
name: Default
8+
strategy:
9+
matrix:
10+
platform: [ ubuntu-latest, macos-latest, windows-latest ]
11+
toolchain: [ stable, 1.28.0, nightly ]
12+
runs-on: ${{ matrix.platform }}
13+
steps:
14+
- uses: actions/checkout@v2
15+
- uses: actions-rs/toolchain@v1
16+
with:
17+
toolchain: ${{ matrix.toolchain }}
18+
override: true
19+
- uses: actions-rs/cargo@v1
20+
with:
21+
command: build
22+
args: --release --all-features
23+
no_std:
24+
name: no_std
25+
strategy:
26+
matrix:
27+
toolchain: [ stable, 1.30.0, nightly ]
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v2
31+
- uses: actions-rs/toolchain@v1
32+
with:
33+
toolchain: ${{ matrix.toolchain }}
34+
override: true
35+
- name: Build
36+
working-directory: no_std
37+
run: cargo build --release --all-features
38+
xargo:
39+
name: xargo
40+
strategy:
41+
matrix:
42+
project_dir: [ xargo, no_main, panic_immediate_abort]
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v2
46+
- uses: actions-rs/toolchain@v1
47+
with:
48+
toolchain: nightly
49+
override: true
50+
- name: Build
51+
working-directory: ${{ matrix.project_dir }}
52+
run: >
53+
rustup component add rust-src;
54+
cargo install xargo --force;
55+
xargo build --target x86_64-unknown-linux-gnu --release --verbose;

.travis.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ license-file = "LICENSE.txt"
77
[dependencies]
88

99
[profile.release]
10-
opt-level = 'z' # Optimize for size.
10+
opt-level = "z" # Optimize for size.
1111
lto = true # Enable Link Time Optimization
1212
codegen-units = 1 # Reduce number of codegen units to increase optimizations.
13-
panic = 'abort' # Abort on panic
13+
panic = "abort" # Abort on panic

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Minimizing Rust Binary Size
22

3-
| Build Status | |
4-
|--------------|--------------------------------------------------------------------------------|
5-
| Travis | [![Travis Build Status][travis-build-status-svg]][travis-build-status] |
3+
[![GitHub Actions][github-actions-badge]](https://github.com/johnthagen/min-sized-rust/actions)
4+
5+
[github-actions-badge]: https://github.com/johnthagen/min-sized-rust/workflows/build/badge.svg
66

77
This repository demonstrates how to minimize the size of a Rust binary.
88

@@ -70,7 +70,7 @@ which optimizes the binary for **speed**. To instruct Cargo to optimize for mini
7070

7171
```toml
7272
[profile.release]
73-
opt-level = 'z' # Optimize for size.
73+
opt-level = "z" # Optimize for size.
7474
```
7575

7676
# Enable Link Time Optimization (LTO)
@@ -142,7 +142,7 @@ Enable this in `Cargo.toml`:
142142

143143
```toml
144144
[profile.release]
145-
panic = 'abort'
145+
panic = "abort"
146146
```
147147

148148
# Optimize `libstd` with Xargo
@@ -242,9 +242,9 @@ If you want an executable smaller than 20 kilobytes, Rust's string formatting co
242242
be removed. `panic_immediate_abort` only removes some usages of this code. There is a lot of other
243243
code that uses formatting in some of cases. That includes Rust's "pre-main" code in `libstd`.
244244

245-
By using a C entry point (by added the `#![no_main]` attribute) , managing stdio manually, and
245+
By using a C entry point (by adding the `#![no_main]` attribute) , managing stdio manually, and
246246
carefully analyzing which chunks of code you or your dependencies include, you can sometimes
247-
make use of `libstd ` while avoiding bloated `core::fmt`.
247+
make use of `libstd` while avoiding bloated `core::fmt`.
248248

249249
Expect the code to be hacky and unportable, with more `unsafe{}`s than usual. It feels like
250250
`no_std`, but with `libstd`.

no_main/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ license = "MIT"
1111
# This isn't required for development builds, but makes development
1212
# build behavior match release builds. To enable unwinding panics
1313
# during development, simply remove this line.
14-
panic = 'abort'
14+
panic = "abort"
1515

1616
[profile.release]
1717
opt-level = "z"
1818
lto = true
1919
codegen-units = 1
20-
panic = 'abort'
20+
panic = "abort"

no_std/.cargo/config

Lines changed: 0 additions & 3 deletions
This file was deleted.

no_std/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
name = "min-sized-no_std"
33
version = "0.1.0"
44
authors = ["johnthagen <johnthagen@gmail.com>"]
5-
edition = "2018"
65
license = "MIT"
76

87
[dependencies]
@@ -13,7 +12,7 @@ libc = { version = "0.2", default-features = false }
1312
panic = "abort"
1413

1514
[profile.release]
16-
opt-level = 'z' # Optimize for size.
15+
opt-level = "z" # Optimize for size.
1716
lto = true # Enable Link Time Optimization
1817
codegen-units = 1 # Reduce number of codegen units to increase optimizations.
19-
panic = 'abort' # Abort on panic
18+
panic = "abort" # Abort on panic

panic_immediate_abort/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ license = "MIT"
1111
# This isn't required for development builds, but makes development
1212
# build behavior match release builds. To enable unwinding panics
1313
# during development, simply remove this line.
14-
panic = 'abort'
14+
panic = "abort"
1515

1616
[profile.release]
1717
opt-level = "z"
1818
lto = true
1919
codegen-units = 1
20-
panic = 'abort'
20+
panic = "abort"

xargo/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ license = "MIT"
1111
# This isn't required for development builds, but makes development
1212
# build behavior match release builds. To enable unwinding panics
1313
# during development, simply remove this line.
14-
panic = 'abort' # Abort on panic
14+
panic = "abort" # Abort on panic
1515

1616
[profile.release]
17-
opt-level = 'z' # Optimize for size.
17+
opt-level = "z" # Optimize for size.
1818
lto = true # Enable Link Time Optimization
1919
codegen-units = 1 # Reduce number of codegen units to increase optimizations.
20-
panic = 'abort' # Abort on panic
20+
panic = "abort" # Abort on panic

0 commit comments

Comments
 (0)