Skip to content

Commit f932a3c

Browse files
authored
Merge pull request #53 from macisamuele/maci-build-and-test-on-all-os
Define github actions workflows and publish binaries artifacts
2 parents e07609c + 2a2018d commit f932a3c

File tree

4 files changed

+122
-11
lines changed

4 files changed

+122
-11
lines changed

.cargo/config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[target.x86_64-pc-windows-msvc]
2-
rustflags = ["-Ctarget-feature=+crt-static", "-Zunstable-options"]
2+
rustflags = ["-Ctarget-feature=+crt-static"]

.github/workflows/build.yml

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: ci
2+
3+
on:
4+
pull_request: {}
5+
push: {}
6+
release:
7+
types: [published]
8+
9+
jobs:
10+
fmt:
11+
name: Format
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- uses: actions-rs/toolchain@v1
16+
with:
17+
profile: minimal
18+
override: true
19+
components: rustfmt
20+
- uses: actions-rs/cargo@v1
21+
with:
22+
command: fmt
23+
args: --all -- --check
24+
25+
clippy:
26+
name: Clippy
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v2
30+
- uses: actions-rs/toolchain@v1
31+
with:
32+
profile: minimal
33+
override: true
34+
components: clippy
35+
- uses: actions-rs/clippy-check@v1
36+
with:
37+
token: ${{ secrets.GITHUB_TOKEN }}
38+
args: --all-targets --all-features -- -F warnings
39+
40+
test:
41+
name: Unitest (${{ matrix.os }})
42+
runs-on: ${{ matrix.os }}
43+
strategy:
44+
matrix:
45+
os: [macos-latest, ubuntu-latest, windows-latest]
46+
steps:
47+
- uses: actions/checkout@v2
48+
- uses: actions-rs/toolchain@v1
49+
with:
50+
profile: minimal
51+
override: true
52+
components: clippy
53+
- uses: actions-rs/cargo@v1
54+
env:
55+
RUST_BACKTRACE: full
56+
RUSTFLAGS: -F warnings
57+
with:
58+
command: test
59+
args: --all --all-features
60+
- name: "Ensure Cargo.lock is not modified"
61+
run: git diff --exit-code Cargo.lock
62+
63+
build-release:
64+
name: Build release Executable (${{ matrix.os }})
65+
runs-on: ${{ matrix.os }}
66+
strategy:
67+
matrix:
68+
include:
69+
- os: ubuntu-latest
70+
target: x86_64-unknown-linux-musl
71+
- os: macos-latest
72+
target: x86_64-apple-darwin
73+
- os: windows-latest
74+
target: x86_64-pc-windows-msvc
75+
env:
76+
BINARY_EXTENSION: ${{ endsWith(matrix.target, '-msvc') && '.exe' || '' }}
77+
PATH_BINARY: ${{ github.workspace }}/target/release/simple-http-server${{ endsWith(matrix.target, '-msvc') && '.exe' || '' }}
78+
steps:
79+
- uses: actions/checkout@v2
80+
- uses: actions-rs/toolchain@v1
81+
with:
82+
profile: minimal
83+
override: true
84+
components: clippy
85+
target: ${{ matrix.target }}
86+
- uses: actions-rs/cargo@v1
87+
with:
88+
command: build
89+
args: --release --bin simple-http-server --locked
90+
- uses: actions/upload-artifact@v2
91+
with:
92+
name: ${{ matrix.target }}-simple-http-server${{ env.BINARY_EXTENSION }}
93+
path: ${{ env.PATH_BINARY }}
94+
- name: Evaluate shasum
95+
run: echo -n $(shasum -ba 256 ${{ env.PATH_BINARY }} | cut -d " " -f 1) > ${{ env.PATH_BINARY }}.sha256
96+
- uses: actions/upload-artifact@v2
97+
with:
98+
name: ${{ matrix.target }}-simple-http-server.sha256
99+
path: ${{ env.PATH_BINARY }}.sha256
100+
101+
- name: '[Optional] Publish Artifact'
102+
if: ${{ github.event_name == 'release' }}
103+
uses: svenstaro/upload-release-action@v2
104+
with:
105+
repo_token: ${{ secrets.GITHUB_TOKEN }}
106+
file: ${{ env.PATH_BINARY }}
107+
asset_name: ${{ matrix.target }}-simple-http-server${{ env.BINARY_EXTENSION }}
108+
tag: ${{ github.ref }}
109+
overwrite: true
110+
- name: '[Optional] Publish Artifact (shasum)'
111+
if: ${{ github.event_name == 'release' }}
112+
uses: svenstaro/upload-release-action@v2
113+
with:
114+
repo_token: ${{ secrets.GITHUB_TOKEN }}
115+
file: ${{ env.PATH_BINARY }}.sha256
116+
asset_name: ${{ matrix.target }}-simple-http-server${{ env.BINARY_EXTENSION }}.sha256
117+
tag: ${{ github.ref }}
118+
overwrite: true

.travis.yml

-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ script:
99
stages:
1010
- Check
1111
- Clippy
12-
- Example
1312
- Test
1413
jobs:
1514
include:
@@ -21,10 +20,6 @@ jobs:
2120
name: Clippy
2221
script:
2322
- make clippy
24-
- stage: Example
25-
name: Example
26-
script:
27-
- make example
2823
- stage: Test
2924
name: Unitest
3025
script:

Makefile

+3-5
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ fmt:
22
cargo fmt --all -- --check
33

44
clippy:
5-
RUSTFLAGS='-F warnings' cargo clippy --all --tests --all-features
6-
7-
example:
8-
cargo build --examples
5+
cargo clippy --all --tests --all-features -- -F warnings
96

7+
test: export RUST_BACKTRACE := full
108
test:
11-
RUSTFLAGS='-F warnings' RUST_BACKTRACE=full cargo test --all --all-features
9+
RUSTFLAGS='-F warnings' cargo test --all --all-features
1210

1311
ci: fmt clippy example test
1412
git diff --exit-code Cargo.lock

0 commit comments

Comments
 (0)