Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Julen Godoy committed May 29, 2023
1 parent 9e7e1a6 commit 5b4bc2b
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 12 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ENV_RUBY_VERSION=2.7
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.4.9
ruby-version: 2.7

- name: Build and test with Rake
run: |
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/xlsx_writer_wrapper`. To experiment with that code, run `bin/console` for an interactive prompt.

TODO: Delete this and the text above, and describe your gem
## 👩🏾‍💻 Setup - Docker

1. Ensure you have desktop `docker` installed or install it with `brew install --cask docker`
2. Create a Github TOKEN in https://github.com/settings/tokens with all "repo" permissions, then add an export for it in your profile specs: `~/.bashrc` or `~/.zshrc` or 🤷🏾‍♀️
```bash
export GITHUB_TOKEN=123adf123...
```
3. Build image: `docker compose build`
4. Then you can bring up all the services with `docker compose up -d`, this command starts the container APP or `make up`
6. Launch all specs: `docker compose exec app bundle exec rspec`
7. Launch console: `docker compose exec app sh`

## Installation

Expand Down
22 changes: 22 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: '3.2'

services:
app:
build:
context: .
dockerfile: dockerfile
args:
RUBY_VERSION: ${ENV_RUBY_VERSION}
tty: true
stdin_open: true
command: irb
volumes:
- .:/app
- bundle_path:/bundle
environment:
BUNDLE_FORCE_RUBY_PLATFORM: 'true'
GITHUB_TOKEN: ${GITHUB_TOKEN}
BUNDLE_PATH: /bundle/vendor

volumes:
bundle_path:
9 changes: 9 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

set -e

gem install bundler -v 2.3.26
./bin/setup
bundle check

exec "$@"
6 changes: 6 additions & 0 deletions docker/gitconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[url "https://github.com/"]
insteadOf = [email protected]:
[credential "https://github.com"]
username = x-oauth-token
[credential]
helper = "!f() { echo \"password=$GITHUB_TOKEN\"; }; f"
24 changes: 24 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
ARG RUBY_VERSION

FROM ruby:${RUBY_VERSION}-slim

WORKDIR /app


RUN apt-get update && apt-get install \
-yq \
--no-install-suggests \
--no-install-recommends \
--allow-downgrades \
--allow-remove-essential \
--allow-change-held-packages \
git build-essential \
libffi-dev && apt clean
# git build-essential libffi-dev \
# && apt clean

# To get gems from git
COPY docker/gitconfig /root/.gitconfig
COPY docker/entrypoint.sh /

ENTRYPOINT ["/entrypoint.sh"]
Binary file added lib/libxlsxwriter.so.5
Binary file not shown.
1 change: 1 addition & 0 deletions lib/libxlsxwriter_arm.so
30 changes: 19 additions & 11 deletions lib/xlsx_writer_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,25 @@

module XlsxWriterWrapper
def library_path
@library_path ||= begin
if os == :macosx
case cpu
when :arm
File.dirname(__FILE__) + "/libxlsxwriter.dylib"
when :intel
File.dirname(__FILE__) + "/libxlsxwriterintel.dylib"
base_dir = File.dirname(__FILE__)
@library_path ||=
begin
case os
when :macosx
case cpu
when :arm
"#{base_dir}/libxlsxwriter.dylib"
when :intel
"#{base_dir}/libxlsxwriterintel.dylib"
end
else
case cpu
when :arm
"#{base_dir}/libxlsxwriter_arm.so"
when :intel
"#{base_dir}/libxlsxwriter.so"
end
end
else
File.dirname(__FILE__) + "/libxlsxwriter.so"
end
end
end
module_function :library_path
Expand Down Expand Up @@ -45,7 +53,7 @@ def cpu
case host_cpu
when "x86_64"
:intel
when "arm"
when /arm|aarch64/
:arm
end
)
Expand Down

0 comments on commit 5b4bc2b

Please sign in to comment.