Skip to content

Commit 46dabb8

Browse files
authored
Merge pull request #136 from praveenperera/switch-to-github-actions
Switch to GitHub actions (Mean Bean CI Template)
2 parents 5c1bc60 + 1810fa1 commit 46dabb8

File tree

7 files changed

+453
-36
lines changed

7 files changed

+453
-36
lines changed

.github/workflows/mean_bean_ci.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Mean Bean CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
install-cross:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v1
10+
with:
11+
depth: 50
12+
- uses: XAMPPRocky/get-github-release@v1
13+
id: cross
14+
with:
15+
owner: rust-embedded
16+
repo: cross
17+
matches: ${{ matrix.platform }}
18+
token: ${{ secrets.GITHUB_TOKEN }}
19+
- uses: actions/upload-artifact@v1
20+
with:
21+
name: cross-${{ matrix.platform }}
22+
path: ${{ steps.cross.outputs.install_path }}
23+
strategy:
24+
matrix:
25+
platform: [linux-musl]
26+
27+
macos:
28+
runs-on: macos-latest
29+
strategy:
30+
fail-fast: true
31+
matrix:
32+
channel: [stable, beta, nightly]
33+
target:
34+
- x86_64-apple-darwin
35+
### Disable running tests on M1 target, not currently working
36+
### https://github.com/rust-lang/rust/issues/73908
37+
# - aarch64-apple-darwin
38+
steps:
39+
- name: Setup | Checkout
40+
uses: actions/checkout@v2
41+
- name: Setup | Rust
42+
uses: actions-rs/toolchain@v1
43+
with:
44+
toolchain: stable
45+
override: true
46+
profile: minimal
47+
target: ${{ matrix.target }}
48+
- run: ci/set_rust_version.bash ${{ matrix.channel }} ${{ matrix.target }}
49+
- name: Test
50+
uses: actions-rs/cargo@v1
51+
env:
52+
SDKROOT: /Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk
53+
with:
54+
command: test
55+
args: --target ${{ matrix.target }}
56+
use-cross: false
57+
58+
linux:
59+
runs-on: ubuntu-latest
60+
needs: install-cross
61+
steps:
62+
- uses: actions/checkout@v2
63+
with:
64+
depth: 50
65+
66+
- name: Download Cross
67+
uses: actions/download-artifact@v1
68+
with:
69+
name: cross-linux-musl
70+
path: /tmp/
71+
- run: chmod +x /tmp/cross
72+
- run: ci/set_rust_version.bash ${{ matrix.channel }} ${{ matrix.target }}
73+
- run: ci/build.bash /tmp/cross ${{ matrix.target }}
74+
# These targets have issues with being tested so they are disabled
75+
# by default. You can try disabling to see if they work for
76+
# your project.
77+
- run: ci/test.bash /tmp/cross ${{ matrix.target }}
78+
if: |
79+
!contains(matrix.target, 'android') &&
80+
!contains(matrix.target, 'bsd') &&
81+
!contains(matrix.target, 'solaris') &&
82+
matrix.target != 'armv5te-unknown-linux-musleabi' &&
83+
matrix.target != 'sparc64-unknown-linux-gnu'
84+
85+
strategy:
86+
fail-fast: true
87+
matrix:
88+
channel: [stable, beta, nightly]
89+
target:
90+
- arm-unknown-linux-gnueabi
91+
- armv7-unknown-linux-gnueabihf
92+
- i686-unknown-linux-musl
93+
- x86_64-unknown-linux-musl
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
on:
2+
push:
3+
# # Sequence of patterns matched against refs/tags
4+
tags:
5+
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
6+
7+
name: Mean Bean Deploy
8+
env:
9+
BIN: mcfly
10+
11+
jobs:
12+
# This job downloads and stores `cross` as an artifact, so that it can be
13+
# redownloaded across all of the jobs. Currently this copied pasted between
14+
# `mean_bean_ci.yml` and `mean_bean_deploy.yml`. Make sure to update both places when making
15+
# changes.
16+
install-cross:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v1
20+
with:
21+
depth: 50
22+
- uses: XAMPPRocky/get-github-release@v1
23+
id: cross
24+
with:
25+
owner: rust-embedded
26+
repo: cross
27+
matches: ${{ matrix.platform }}
28+
token: ${{ secrets.GITHUB_TOKEN }}
29+
- uses: actions/upload-artifact@v1
30+
with:
31+
name: cross-${{ matrix.platform }}
32+
path: ${{ steps.cross.outputs.install_path }}
33+
strategy:
34+
matrix:
35+
platform: [linux-musl]
36+
37+
macos:
38+
runs-on: macos-latest
39+
strategy:
40+
matrix:
41+
target:
42+
# macOS
43+
- x86_64-apple-darwin
44+
## Disabling creating M1 builds, will need to wait for github to release M1 VMs
45+
# - aarch64-apple-darwin
46+
steps:
47+
- name: Get tag
48+
id: tag
49+
uses: dawidd6/action-get-tag@v1
50+
51+
- name: Setup | Checkout
52+
uses: actions/checkout@v2
53+
54+
# Cache files between builds
55+
- name: Setup | Cache Cargo
56+
uses: actions/cache@v2
57+
with:
58+
path: |
59+
~/.cargo/registry
60+
~/.cargo/git
61+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.target }}
62+
63+
- name: Setup | Rust
64+
uses: actions-rs/toolchain@v1
65+
with:
66+
toolchain: stable
67+
override: true
68+
profile: minimal
69+
target: ${{ matrix.target }}
70+
71+
- name: Build | Build
72+
uses: actions-rs/cargo@v1
73+
env:
74+
SDKROOT: /Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk
75+
with:
76+
command: build
77+
args: --release --target ${{ matrix.target }}
78+
79+
- run: tar -czvf ${{ env.BIN }}.tar.gz --directory=target/${{ matrix.target }}/release ${{ env.BIN }}
80+
- uses: XAMPPRocky/[email protected]
81+
id: create_release
82+
env:
83+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84+
with:
85+
tag_name: ${{ github.ref }}
86+
release_name: ${{ github.ref }}
87+
draft: false
88+
prerelease: false
89+
90+
- uses: actions/upload-release-asset@v1
91+
id: upload-release-asset
92+
env:
93+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94+
with:
95+
upload_url: ${{ steps.create_release.outputs.upload_url }}
96+
asset_path: ${{ env.BIN }}.tar.gz
97+
asset_name: ${{ env.BIN }}-${{steps.tag.outputs.tag}}-${{ matrix.target }}.tar.gz
98+
asset_content_type: application/gzip
99+
100+
linux:
101+
runs-on: ubuntu-latest
102+
needs: install-cross
103+
strategy:
104+
matrix:
105+
target:
106+
- arm-unknown-linux-gnueabi
107+
- armv7-unknown-linux-gnueabihf
108+
- i686-unknown-linux-musl
109+
- x86_64-unknown-linux-musl
110+
steps:
111+
- name: Get tag
112+
id: tag
113+
uses: dawidd6/action-get-tag@v1
114+
115+
- uses: actions/checkout@v2
116+
- uses: actions/download-artifact@v1
117+
with:
118+
name: cross-linux-musl
119+
path: /tmp/
120+
- run: chmod +x /tmp/cross
121+
122+
- run: ci/set_rust_version.bash stable ${{ matrix.target }}
123+
- run: ci/build.bash /tmp/cross ${{ matrix.target }} RELEASE
124+
- run: tar -czvf ${{ env.BIN }}.tar.gz --directory=target/${{ matrix.target }}/release ${{ env.BIN }}
125+
- uses: XAMPPRocky/[email protected]
126+
id: create_release
127+
env:
128+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
129+
with:
130+
tag_name: ${{ github.ref }}
131+
release_name: ${{ github.ref }}
132+
draft: false
133+
prerelease: false
134+
- name: Upload Release Asset
135+
id: upload-release-asset
136+
uses: actions/upload-release-asset@v1
137+
env:
138+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
139+
with:
140+
upload_url: ${{ steps.create_release.outputs.upload_url }}
141+
asset_path: ${{ env.BIN }}.tar.gz
142+
asset_name: ${{ env.BIN }}-${{steps.tag.outputs.tag}}-${{ matrix.target }}.tar.gz
143+
asset_content_type: application/gzip

ci/build.bash

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
# Script for building your rust projects.
3+
set -e
4+
5+
source ci/common.bash
6+
7+
# $1 {path} = Path to cross/cargo executable
8+
CROSS=$1
9+
# $1 {string} = <Target Triple> e.g. x86_64-pc-windows-msvc
10+
TARGET_TRIPLE=$2
11+
# $3 {boolean} = Are we building for deployment?
12+
RELEASE_BUILD=$3
13+
14+
required_arg $CROSS 'CROSS'
15+
required_arg $TARGET_TRIPLE '<Target Triple>'
16+
17+
if [ -z "$RELEASE_BUILD" ]; then
18+
$CROSS build --target $TARGET_TRIPLE
19+
$CROSS build --target $TARGET_TRIPLE --all-features
20+
else
21+
$CROSS build --target $TARGET_TRIPLE --all-features --release
22+
fi
23+

ci/common.bash

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
required_arg() {
2+
if [ -z "$1" ]; then
3+
echo "Required argument $2 missing"
4+
exit 1
5+
fi
6+
}

0 commit comments

Comments
 (0)