Skip to content

Commit

Permalink
Add github action workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
fxpineau committed Aug 17, 2021
1 parent e45b6f9 commit a6d57d7
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 4 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: BenchLib

on: [push]

jobs:
test:
name: Bench
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Bench
run: cargo bench

21 changes: 21 additions & 0 deletions .github/workflows/clitest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: TestCli

on: [push]

jobs:
test:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]

steps:
- uses: actions/checkout@v2
- name: Install cli
run: cargo install --path crates/cli
- name: Test cli
run: |
cd crates/cli/test
./test.bash
17 changes: 17 additions & 0 deletions .github/workflows/libtest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: TestLib

on: [push]

jobs:
test:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- uses: actions/checkout@v2
- name: Run lib tests
run: cargo test --verbose -- --nocapture

125 changes: 125 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Inspired from both:
# - https://github.com/BurntSushi/ripgrep/blob/master/.github/workflows/release.yml
# - https://github.com/input-output-hk/chain-wallet-libs/blob/master/.github/workflows/release.yaml

name: Release

on:
push:
tags:
- 'v[0-9]+.*' # push events to matching releases

jobs:
create-github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Get the release version from the tag
id: get_version
run: echo ::set-output name=version::``${GITHUB_REF#refs/tags/}``

build-cli-releases:
name: Release CLI assets
needs: create-github-release
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
# Linux
#- { os: ubuntu-latest, cross: true, toolchain: stable, target: aarch64-unknown-linux-gnu }
#- { os: ubuntu-latest, cross: true, toolchain: stable, target: arm-unknown-linux-gnueabi }
#- { os: ubuntu-latest, cross: true, toolchain: stable, target: armv7-unknown-linux-gnueabihf }
#- { os: ubuntu-latest, cross: true, toolchain: stable, target: mips64el-unknown-linux-gnuabi64 }
#- { os: ubuntu-latest, cross: true, toolchain: stable, target: powerpc64le-unknown-linux-gnu }
- { os: ubuntu-latest, cross: true, toolchain: stable, target: i686-unknown-linux-musl }
- { os: ubuntu-latest, cross: true, toolchain: stable, target: i686-unknown-linux-gnu }
- { os: ubuntu-latest, cross: true, toolchain: stable, target: x86_64-unknown-linux-musl }
- { os: ubuntu-latest, cross: false, toolchain: stable, target: x86_64-unknown-linux-gnu }
# Android
#- { os: ubuntu-latest, cross: true, toolchain: stable, target: aarch64-linux-android }
#- { os: ubuntu-latest, cross: true, toolchain: stable, target: arm-linux-androideabi }
#- { os: ubuntu-latest, cross: true, toolchain: stable, target: armv7-linux-androideabi }
#- { os: ubuntu-latest, cross: true, toolchain: stable, target: i686-linux-android }
#- { os: ubuntu-latest, cross: true, toolchain: stable, target: x86_64-linux-android }
# Macos
- { os: macos-latest, cross: false, toolchain: stable, target: x86_64-apple-darwin }
# iOS
#- { os: macos-latest, cross: false, toolchain: stable, target: aarch64-apple-ios }
#- { os: macos-latest, cross: false, toolchain: stable, target: x86_64-apple-ios }
# Windows
- { os: windows-latest, cross: false, toolchain: stable-x86_64-pc-windows-gnu, target: x86_64-pc-windows-gnu }
- { os: windows-latest, cross: false, toolchain: stable-x86_64-pc-windows-msvc, target: x86_64-pc-windows-msvc }
steps:
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.config.toolchain }}
target: ${{ matrix.config.target }}
override: true
default: true
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: true
- name: Build library
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.config.cross }}
command: build
args: --release --target ${{ matrix.config.target }} -p moc-cli
- name: Create tar (Not Windows)
if: matrix.config.os != 'windows-latest'
run: tar czfv moc-${{ needs.create-github-release.outputs.version }}-${{ matrix.config.target }}.tar.gz target/${{ matrix.config.target }}/release/moc
- name: Create ZIP (Windows)
if: matrix.config.os == 'windows-latest'
run: compress-archive target\${{ matrix.config.target }}\release\moc moc-${{ needs.create-github-release.outputs.version }}-${{ matrix.config.target }}.zip
- name: Upload compressed binary asset
if: matrix.config.os != 'windows-latest'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-github-release.outputs.upload_url }}
asset_path: "moc-${{ needs.create-github-release.outputs.version }}-${{ matrix.config.target }}.tar.gz"
asset_name: "moc-${{ needs.create-github-release.outputs.version }}-${{ matrix.config.target }}.tar.gz"
asset_content_type: application/gzip
- name: Upload compressed binary asset
if: matrix.config.os == 'windows-latest'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-github-release.outputs.upload_url }}
asset_path: "moc-${{ needs.create-github-release.outputs.version }}-${{ matrix.config.target }}.zip"
asset_name: "moc-${{ needs.create-github-release.outputs.version }}-${{ matrix.config.target }}.zip"
asset_content_type: application/gzip




# Done manually so far!
#build-deb-releases:
# name: Install cargo-deb (Ubuntu)
# run: |
# ci/build_deb.bash


#build-wasm-releases:
# name: Release WASM assets
# needs: create-github-release



18 changes: 18 additions & 0 deletions .github/workflows/wasmtest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: TestWASM

on: [push]

jobs:
wasmtest:
name: Test WASM
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: WASM test
run: |
source $HOME/.cargo/env
cd crates/wasm
wasm-pack test --node
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

cargo-features = ["strip"]
# Nightly feature :o/
#cargo-features = ["strip"]

[package]
name = "moc"
Expand Down Expand Up @@ -86,7 +86,7 @@ opt-level = 3

# See opti here: https://github.com/johnthagen/min-sized-rust
[profile.release]
strip = true # Automatically strip symbols from the binary.
# strip = true # Automatically strip symbols from the binary (nightly feature :o/ ).
lto = true # Optimize at the link stage (may remove dead code)
codegen-units = 1
panic = "abort"
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/test/test.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ moc="moc"
resources="resources"

${moc} -V
[[ "$?" != 0 ]] {{ echo "'moc' command line not found!"; exit 1; }}
[[ "$?" != 0 ]] && {{ echo "'moc' command line not found!"; exit 1; }}

# 1: cmd, 2: expected
test(){
Expand Down

0 comments on commit a6d57d7

Please sign in to comment.