Skip to content

Commit

Permalink
Add GitHub actions workflows for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
parasyte committed Jul 24, 2021
1 parent 89678a9 commit 11a5e03
Show file tree
Hide file tree
Showing 7 changed files with 655 additions and 599 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/mean_bean_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Mean Bean CI

on: [push, pull_request]

jobs:
lints:
name: Lints
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
fetch-depth: 50
- name: Update apt repos
run: sudo apt-get -y update
- name: Install build dependencies
run: sudo apt -y install libgtk-3-dev
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: clippy, rustfmt
override: true
- name: Cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Cargo doc
uses: actions-rs/cargo@v1
with:
command: doc
args: --workspace --no-deps
- name: Cargo clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all --tests -- -D warnings

windows:
name: Windows
runs-on: windows-latest
needs: lints
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 50
- run: ci/set_rust_version.bash ${{ matrix.channel }} ${{ matrix.target }}
shell: bash
- run: ci/build.bash cargo ${{ matrix.target }}
shell: bash
- run: ci/test.bash cargo ${{ matrix.target }}
shell: bash

strategy:
fail-fast: true
matrix:
channel: [stable]
target:
# Windows
- i686-pc-windows-msvc
- x86_64-pc-windows-msvc

macos:
name: macOS
runs-on: macos-latest
needs: lints
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 50
- run: ci/set_rust_version.bash ${{ matrix.channel }} ${{ matrix.target }}
- run: ci/build.bash cargo ${{ matrix.target }}
- run: ci/test.bash cargo ${{ matrix.target }}

strategy:
fail-fast: true
matrix:
channel: [stable]
target:
# macOS
- x86_64-apple-darwin
85 changes: 85 additions & 0 deletions .github/workflows/mean_bean_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Mean Bean Deploy
env:
BIN: cartunes

on:
push:
# Sequence of patterns matched against refs/tags
tags:
- "[0-9]+\\.[0-9]+\\.[0-9]+" # Push events to matching semver tags

jobs:
windows:
name: Windows
runs-on: windows-latest
strategy:
matrix:
target:
# Windows
- i686-pc-windows-msvc
- x86_64-pc-windows-msvc
steps:
- uses: actions/checkout@v2
- run: bash ci/set_rust_version.bash stable ${{ matrix.target }}
- run: bash ci/build.bash cargo ${{ matrix.target }} RELEASE
# TODO: Compress with UPX
- run: |
cd ./target/${{ matrix.target }}/release/
7z a "${{ env.BIN }}.zip" "${{ env.BIN }}.exe"
mv "${{ env.BIN }}.zip" $GITHUB_WORKSPACE
shell: bash
# We're using using a fork of `actions/create-release` that detects
# whether a release is already available or not first.
- uses: XAMPPRocky/[email protected]
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
# Draft should **always** be false. GitHub doesn't provide a way to
# get draft releases from its API, so there's no point using it.
draft: false
prerelease: false
- uses: actions/upload-release-asset@v1
id: upload-release-asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.BIN }}.zip
asset_name: ${{ env.BIN }}-${{ matrix.target }}.zip
asset_content_type: application/zip

macos:
name: macOS
runs-on: macos-latest
strategy:
matrix:
target:
# macOS
- x86_64-apple-darwin
steps:
- uses: actions/checkout@v2
- run: ci/set_rust_version.bash stable ${{ matrix.target }}
- run: ci/build.bash cargo ${{ matrix.target }} RELEASE
# TODO: macOS app package and disk image
- run: tar -czvf ${{ env.BIN }}.tar.gz --directory=target/${{ matrix.target }}/release ${{ env.BIN }}
- uses: XAMPPRocky/[email protected]
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: false
- uses: actions/upload-release-asset@v1
id: upload-release-asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.BIN }}.tar.gz
asset_name: ${{ env.BIN }}-${{ matrix.target }}.tar.gz
asset_content_type: application/gzip
23 changes: 23 additions & 0 deletions ci/build.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
# Script for building your rust projects.
set -e

source ci/common.bash

# $1 {path} = Path to cross/cargo executable
CROSS=$1
# $1 {string} = <Target Triple> e.g. x86_64-pc-windows-msvc
TARGET_TRIPLE=$2
# $3 {boolean} = Are we building for deployment?
RELEASE_BUILD=$3

required_arg $CROSS 'CROSS'
required_arg $TARGET_TRIPLE '<Target Triple>'

if [ -z "$RELEASE_BUILD" ]; then
$CROSS build --target $TARGET_TRIPLE
$CROSS build --target $TARGET_TRIPLE --all-features
else
$CROSS build --target $TARGET_TRIPLE --all-features --release
fi

6 changes: 6 additions & 0 deletions ci/common.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
required_arg() {
if [ -z "$1" ]; then
echo "Required argument $2 missing"
exit 1
fi
}
4 changes: 4 additions & 0 deletions ci/set_rust_version.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -e
rustup default $1
rustup target add $2
16 changes: 16 additions & 0 deletions ci/test.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
# Script for building your rust projects.
set -e

source ci/common.bash

# $1 {path} = Path to cross/cargo executable
CROSS=$1
# $1 {string} = <Target Triple>
TARGET_TRIPLE=$2

required_arg $CROSS 'CROSS'
required_arg $TARGET_TRIPLE '<Target Triple>'

$CROSS test --target $TARGET_TRIPLE
$CROSS test --target $TARGET_TRIPLE --all-features
Loading

0 comments on commit 11a5e03

Please sign in to comment.