diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..891c617 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,27 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..bbcbbe7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..2ac35da --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,22 @@ + + +## Summary + + + +## Changelog + + + +## Test Plan + + diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d5a0da0..34beb9c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,7 +31,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v2 with: - go-version: '1.17.7' + go-version: '1.20.5' - name: Build Linux if: matrix.os == 'ubuntu-20.04' @@ -76,7 +76,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v2 with: - go-version: '1.17.7' + go-version: '1.20.5' - name: Install OS dependencies shell: bash diff --git a/.ruby-version b/.ruby-version index 944880f..be94e6f 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.2.0 +3.2.2 diff --git a/Gemfile b/Gemfile index e81ecb2..ed6eedd 100644 --- a/Gemfile +++ b/Gemfile @@ -6,3 +6,7 @@ source 'https://rubygems.org' gemspec gem 'rake', '~> 13.0' +gem 'rspec', '~> 3.10.0' +gem 'rubocop', '~> 1.7' +gem 'simplecov', '~> 0.21.2' +gem 'simplecov-console', '~> 0.9.1' diff --git a/cobhan.gemspec b/cobhan.gemspec index dc0261c..deef901 100644 --- a/cobhan.gemspec +++ b/cobhan.gemspec @@ -36,9 +36,4 @@ Gem::Specification.new do |spec| spec.require_paths = ['lib'] spec.add_dependency 'ffi', '~> 1.15.4' - - spec.add_development_dependency 'rspec', '~> 3.10.0' - spec.add_development_dependency 'rubocop', '~> 1.7' - spec.add_development_dependency 'simplecov', '~> 0.21.2' - spec.add_development_dependency 'simplecov-console', '~> 0.9.1' end diff --git a/demo/demo.rb b/demo/demo.rb index 5e31c53..e6a153a 100644 --- a/demo/demo.rb +++ b/demo/demo.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true require 'cobhan' -require_relative './../spec/support/build_binary' -require_relative './../spec/support/measure_time' -require_relative './../spec/support/cobhan_module' +require_relative '../spec/support/build_binary' +require_relative '../spec/support/measure_time' +require_relative '../spec/support/cobhan_module' LIB_ROOT_PATH = File.join(__dir__, '../tmp') LIB_NAME = 'libcobhandemo' diff --git a/spec/support/build_binary.rb b/spec/support/build_binary.rb index 38392c1..9bd75f9 100644 --- a/spec/support/build_binary.rb +++ b/spec/support/build_binary.rb @@ -12,6 +12,6 @@ def build_binary(lib_root_path, lib_name) abort('Aborted.') unless input.downcase == 'y' end - Dir.mkdir_p(lib_root_path) + FileUtils.mkdir_p(lib_root_path) system("./spec/support/#{lib_name}/build.sh", exception: true) end diff --git a/spec/support/libcobhandemo/arm64_build_and_test.sh b/spec/support/libcobhandemo/arm64_build_and_test.sh index 188653d..7eb7d52 100755 --- a/spec/support/libcobhandemo/arm64_build_and_test.sh +++ b/spec/support/libcobhandemo/arm64_build_and_test.sh @@ -6,7 +6,7 @@ DYN_EXT="so" SYS_FN_PART="arm64" GOARCH="arm64" OUTPUT_FILE="$LIB_NAME-$SYS_FN_PART.$DYN_EXT" -DOCKER_IMG=golang:1.17.7-bullseye +DOCKER_IMG=golang:1.20.5-bullseye BUILD_CMD="GOOS=linux GOARCH=$GOARCH go build -buildmode=c-shared -ldflags='-s -w' -o $OUTPUT_FILE $LIB_NAME.go" BUILD_DIR="tmp/build/linux-arm64" diff --git a/spec/support/libcobhandemo/build.sh b/spec/support/libcobhandemo/build.sh index 3c5ee93..7cf180e 100755 --- a/spec/support/libcobhandemo/build.sh +++ b/spec/support/libcobhandemo/build.sh @@ -2,6 +2,7 @@ set -euo LIB_NAME=libcobhandemo +ROOT_DIR=$(pwd) SRC_DIR="spec/support/$LIB_NAME" # Normalize machine architecture for file names @@ -10,7 +11,7 @@ case $(uname -m) in SYS_FN_PART="x64" GOARCH="amd64" ;; - "aarch64") + "aarch64" | "arm64") SYS_FN_PART="arm64" GOARCH="arm64" ;; @@ -23,17 +24,13 @@ esac # OS Detection case $(uname -s) in "Darwin") + GOOS=darwin DYN_EXT="dylib" - OUTPUT_FILE="$LIB_NAME-$SYS_FN_PART.$DYN_EXT" - DOCKER_IMG=neilotoole/xcgo:go1.17 - BUILD_CMD="GOOS=darwin GOARCH=$GOARCH CC=o64-clang CXX=o64-clang++ go build -buildmode=c-shared -ldflags='-s -w' -o $OUTPUT_FILE $LIB_NAME.go" BUILD_DIR="tmp/build/darwin" ;; "Linux") + GOOS=linux DYN_EXT="so" - OUTPUT_FILE="$LIB_NAME-$SYS_FN_PART.$DYN_EXT" - DOCKER_IMG=golang:1.17.7-bullseye - BUILD_CMD="GOOS=linux GOARCH=$GOARCH go build -buildmode=c-shared -ldflags='-s -w' -o $OUTPUT_FILE $LIB_NAME.go" BUILD_DIR="tmp/build/linux" ;; *) @@ -42,21 +39,14 @@ case $(uname -s) in ;; esac +OUTPUT_FILE="$LIB_NAME-$SYS_FN_PART.$DYN_EXT" +BUILD_CMD="GOOS=$GOOS GOARCH=$GOARCH go build -buildmode=c-shared -ldflags='-s -w' -o $OUTPUT_FILE $LIB_NAME.go" + mkdir -p $BUILD_DIR cp -R $SRC_DIR/* $BUILD_DIR +cd $BUILD_DIR -# Debug -echo $BUILD_CMD -# docker run -it --rm --name cobhan-builder \ -# --volume "$(pwd)/$BUILD_DIR":/usr/src/cobhan \ -# -w /usr/src/cobhan \ -# $DOCKER_IMG \ -# bash - -docker run --rm --name cobhan-builder \ - --volume "$(pwd)/$BUILD_DIR":/usr/src/cobhan \ - -w /usr/src/cobhan \ - $DOCKER_IMG \ - sh -c "$BUILD_CMD" - +echo "$BUILD_CMD" +sh -c "$BUILD_CMD" +cd "$ROOT_DIR" cp $BUILD_DIR/$OUTPUT_FILE tmp/