Skip to content

Commit

Permalink
setup DI
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyar committed Mar 21, 2023
1 parent 3eb1c45 commit d2b0333
Show file tree
Hide file tree
Showing 8 changed files with 374 additions and 5 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/qa.yml
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
93 changes: 93 additions & 0 deletions .github/workflows/release.yml
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 }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ build/
sold/target/
target/
.idea/
.deps-ready
release
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
members = [
'sold'
]

[profile.release]
strip = true # Automatically strip symbols from the binary.
35 changes: 35 additions & 0 deletions Makefile
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/

10 changes: 5 additions & 5 deletions compiler/scripts/install_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ case $(uname -s) in
10.15)
echo "Installing solidity dependencies on macOS 10.15 Catalina."
;;
11.0 | 11.1 | 11.2 | 11.3 | 11.4)
echo "Installing solidity dependencies on macOS 11.0 / 11.1 / 11.2 / 11.3 / 11.4 Big Sur."
11.*)
echo "Installing solidity dependencies on macOS 11.x Big Sur."
;;
12.*)
echo "Installing solidity dependencies on macOS 12 Monterey."
;;
*)
echo "Unsupported macOS version."
echo "Unsupported macOS version: $(sw_vers -productVersion)"
echo "We only support Mavericks, Yosemite, El Capitan, Sierra, High Sierra, Mojave, Catalina, Big Sur and Monterey."
exit 1
;;
Expand Down Expand Up @@ -177,7 +177,7 @@ case $(uname -s) in
Debian*)
#Debian
. /etc/os-release

# Install "normal packages"
sudo apt-get -y update
sudo apt-get -y install \
Expand Down Expand Up @@ -254,7 +254,7 @@ case $(uname -s) in
Ubuntu|LinuxMint)
#LinuxMint is a distro on top of Ubuntu.
#Ubuntu

sudo apt-get -y update
sudo apt-get -y install \
build-essential \
Expand Down
101 changes: 101 additions & 0 deletions script/toolchain.sh
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 "$*"
Loading

0 comments on commit d2b0333

Please sign in to comment.