-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
374 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: QA | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
qa: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
profile: minimal | ||
components: rustfmt, clippy | ||
override: true | ||
|
||
- uses: actions/cache@v3 | ||
continue-on-error: false | ||
with: | ||
path: | | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
target/ | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} | ||
|
||
- run: | | ||
make qa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
qa: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
profile: minimal | ||
components: rustfmt, clippy | ||
override: true | ||
|
||
- uses: actions/cache@v3 | ||
continue-on-error: false | ||
with: | ||
path: | | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
target/ | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} | ||
|
||
- run: | | ||
make qa | ||
build: | ||
needs: | ||
- qa | ||
runs-on: ${{ matrix.platform.on }} | ||
name: ${{ matrix.platform.name }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
platform: | ||
- { on: ubuntu-20.04, name: linux-amd64, target: x86_64-unknown-linux-musl } | ||
- { on: ubuntu-20.04, name: freebsd-amd64, target: x86_64-unknown-freebsd } | ||
- { on: macos-11, name: darwin-amd64, target: x86_64-apple-darwin } | ||
- { on: macos-11, name: darwin-arm64, target: aarch64-apple-darwin } | ||
- { on: windows-2022, name: windows-amd64, target: x86_64-pc-windows-gnu } | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
target: ${{ matrix.platform.target }} | ||
profile: minimal | ||
override: true | ||
|
||
- uses: actions/cache@v3 | ||
continue-on-error: false | ||
with: | ||
path: | | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
target/ | ||
key: ${{ runner.os }}-cargo-release-${{ hashFiles('Cargo.lock') }} | ||
|
||
- run: | | ||
make release | ||
tar -czvf sold-${{ github.ref_name }}-${{ matrix.platform.name }}.tar.gz -C release sold* | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: sold-${{ github.ref_name }}-${{ matrix.platform.name }} | ||
path: | | ||
release/sold* | ||
- uses: softprops/action-gh-release@v1 | ||
if: ${{ startsWith(github.ref, 'refs/tags/') }} | ||
with: | ||
draft: false | ||
files: | | ||
sold-${{ github.ref_name }}-${{ matrix.platform.name }}.tar.gz | ||
prerelease: true | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ build/ | |
sold/target/ | ||
target/ | ||
.idea/ | ||
.deps-ready | ||
release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,6 @@ | |
members = [ | ||
'sold' | ||
] | ||
|
||
[profile.release] | ||
strip = true # Automatically strip symbols from the binary. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
UNAME := $(shell uname) | ||
|
||
ifeq ($(UNAME), win) | ||
TARGET = sold.exe | ||
else | ||
TARGET = sold | ||
endif | ||
|
||
.deps-ready: | ||
bash script/toolchain.sh -s | ||
touch .deps-ready | ||
|
||
clean: | ||
rm -fr release | ||
cargo clean | ||
|
||
test: .deps-ready | ||
cargo test | ||
|
||
fmt: | ||
cargo fmt | ||
|
||
lint: .deps-ready | ||
cargo fmt --all -- --check | ||
cargo clippy --all-targets | ||
|
||
qa: lint test | ||
|
||
target/release/$(TARGET): .deps-ready | ||
cargo build --release | ||
|
||
release: target/release/$(TARGET) | ||
mkdir -p release | ||
cp target/release/$(TARGET) release/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit | ||
|
||
projectDir=$(cd "$(dirname "${0}")/.." && pwd) | ||
# shellcheck source=script/util.sh | ||
source "${projectDir}/script/util.sh" || source ./util.sh | ||
|
||
usage() { | ||
println "POSIX-compliant bash script to manage toolchain for develop project" | ||
println "Usage: ${0} <option>" | ||
println "Options:" | ||
println " -h this help" | ||
println " -x enable debug mode (trace per command line in scripts)" | ||
println " -c check requirements for environment" | ||
println " -s setup environment ENV_TYPE=${ENV_TYPE}" | ||
} | ||
|
||
commonSetup() { | ||
info "setup common" | ||
} | ||
|
||
debianSetup() { | ||
info "setup for platform debian" | ||
sudo apt-get update | ||
info "Installing libs for build project" | ||
sudo apt-get install -qq -y \ | ||
build-essential \ | ||
cmake \ | ||
g++ \ | ||
gcc \ | ||
libboost-all-dev \ | ||
unzip \ | ||
curl \ | ||
libclang-dev | ||
commonSetup | ||
} | ||
|
||
macosSetup() { | ||
info "setup for platform macos" | ||
checkCommand brew "Requires a Homebrew install, see https://brew.sh" | ||
brew update | ||
brew install boost | ||
brew install cmake | ||
brew install curl | ||
if [ "$CI" = true ]; then | ||
brew upgrade cmake | ||
fi | ||
commonSetup | ||
} | ||
|
||
windowsSetup() { | ||
info "setup for platform windows" | ||
tryCommand make || choco install -y make | ||
tryCommand curl || choco install -y curl | ||
tryCommand cmake || choco install -y cmake | ||
cmake -P "${projectDir}/compiler/scripts/install_deps.cmake" | ||
commonSetup | ||
} | ||
|
||
checkRequirements() { | ||
tryCommand git && git --version | ||
tryCommand cargo && cargo --version | ||
tryCommand make && println "make $(make --version | grep Make | cut -d" " -f3)" | ||
} | ||
|
||
checkEnvironment() { | ||
printENV | ||
tryCommand bash && println "bash ${BASH_VERSION}" | ||
checkRequirements | ||
} | ||
|
||
setupEnvironment() { | ||
checkRequirements | ||
|
||
case "$OS_FAMILY" in | ||
debian) debianSetup ;; | ||
macos) macosSetup ;; | ||
windows) windowsSetup ;; | ||
*) notReady "setup toolchain" ;; | ||
esac | ||
} | ||
|
||
main() { | ||
if [ "$(id -u)" == "0" ]; then fatal "Not running as root"; fi | ||
if [ -z "$*" ]; then usage; fi | ||
|
||
cmd= | ||
while getopts ":hxsc" flag; do | ||
case "${flag}" in | ||
x) set -o xtrace ;; | ||
s) cmd=setupEnvironment ;; | ||
c) cmd=checkEnvironment ;; | ||
?) usage ;; | ||
esac | ||
done | ||
|
||
${cmd} | ||
} | ||
|
||
main "$*" |
Oops, something went wrong.