From 4239b74e6be96cdd0aff813141a9df6beb10e6bf Mon Sep 17 00:00:00 2001 From: Dalibor Nasevic Date: Mon, 3 Jul 2023 11:03:11 +0200 Subject: [PATCH 1/5] Add issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 27 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 20 +++++++++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 22 ++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md 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 + + From d84cc9682cbdf705b09787e05e8a37a779d97d7a Mon Sep 17 00:00:00 2001 From: Dalibor Nasevic Date: Tue, 4 Jul 2023 12:11:18 +0200 Subject: [PATCH 2/5] Remove xcgo and docker from build.sh --- .github/workflows/build.yml | 2 +- .ruby-version | 2 +- spec/support/libcobhandemo/build.sh | 31 +++++++++-------------------- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d5a0da0..8898214 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' 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/spec/support/libcobhandemo/build.sh b/spec/support/libcobhandemo/build.sh index 3c5ee93..f8b7d2f 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,16 +24,12 @@ esac # OS Detection case $(uname -s) in "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" + OUTPUT_FILE="$LIB_NAME-$SYS_FN_PART.dylib" + BUILD_CMD="GOOS=darwin GOARCH=$GOARCH go build -buildmode=c-shared -ldflags='-s -w' -o $OUTPUT_FILE $LIB_NAME.go" BUILD_DIR="tmp/build/darwin" ;; "Linux") - DYN_EXT="so" - OUTPUT_FILE="$LIB_NAME-$SYS_FN_PART.$DYN_EXT" - DOCKER_IMG=golang:1.17.7-bullseye + OUTPUT_FILE="$LIB_NAME-$SYS_FN_PART.so" 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" ;; @@ -44,19 +41,9 @@ esac 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/ From 06a4a7141aea2574d25f0761f7be5b56f42552c9 Mon Sep 17 00:00:00 2001 From: Dalibor Nasevic Date: Tue, 4 Jul 2023 12:14:35 +0200 Subject: [PATCH 3/5] Fix rubocop offenses --- Gemfile | 4 ++++ cobhan.gemspec | 5 ----- demo/demo.rb | 6 +++--- spec/support/build_binary.rb | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) 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 From 44f5fc007d95f0c7bbc397a9322e9e3e98db54b1 Mon Sep 17 00:00:00 2001 From: Dalibor Nasevic Date: Tue, 4 Jul 2023 12:33:53 +0200 Subject: [PATCH 4/5] Use latest Go version --- .github/workflows/build.yml | 2 +- spec/support/libcobhandemo/arm64_build_and_test.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8898214..34beb9c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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/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" From 61eb0967b3defa08f5023500328fb9925ea89c4b Mon Sep 17 00:00:00 2001 From: Dalibor Nasevic Date: Tue, 4 Jul 2023 12:38:53 +0200 Subject: [PATCH 5/5] Remove duplication --- spec/support/libcobhandemo/build.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/spec/support/libcobhandemo/build.sh b/spec/support/libcobhandemo/build.sh index f8b7d2f..7cf180e 100755 --- a/spec/support/libcobhandemo/build.sh +++ b/spec/support/libcobhandemo/build.sh @@ -24,13 +24,13 @@ esac # OS Detection case $(uname -s) in "Darwin") - OUTPUT_FILE="$LIB_NAME-$SYS_FN_PART.dylib" - BUILD_CMD="GOOS=darwin GOARCH=$GOARCH go build -buildmode=c-shared -ldflags='-s -w' -o $OUTPUT_FILE $LIB_NAME.go" + GOOS=darwin + DYN_EXT="dylib" BUILD_DIR="tmp/build/darwin" ;; "Linux") - OUTPUT_FILE="$LIB_NAME-$SYS_FN_PART.so" - BUILD_CMD="GOOS=linux GOARCH=$GOARCH go build -buildmode=c-shared -ldflags='-s -w' -o $OUTPUT_FILE $LIB_NAME.go" + GOOS=linux + DYN_EXT="so" BUILD_DIR="tmp/build/linux" ;; *) @@ -39,6 +39,9 @@ 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