From 1076413d032257e7bcd1fb62ebd4f617a97e44de Mon Sep 17 00:00:00 2001 From: James Harton Date: Fri, 28 Jul 2023 07:57:02 +1200 Subject: [PATCH] chore: migrate to local. --- .drone.yml | 236 +++++++++++++++++++++++++ .gitlab-ci.yml | 32 ---- .tool-versions | 1 + Gemfile.lock | 1 + README.md | 12 +- lib/wag/export.rb | 2 +- lib/wag/import.rb | 2 +- lib/wag/module.rb | 2 +- lib/wag/table.rb | 2 +- renovate.json | 3 - spec/acceptance/code_validates_spec.rb | 2 +- spec/wag/export_spec.rb | 4 +- spec/wag/import_spec.rb | 4 +- spec/wag/module_spec.rb | 2 +- spec/wag/table_spec.rb | 2 +- wag.gemspec | 8 +- 16 files changed, 259 insertions(+), 56 deletions(-) create mode 100644 .drone.yml delete mode 100644 .gitlab-ci.yml create mode 100644 .tool-versions delete mode 100644 renovate.json diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..75902f5 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,236 @@ +kind: pipeline +type: docker +name: build + +steps: +- name: restore ASDF cache + image: meltwater/drone-cache + pull: "always" + environment: + AWS_ACCESS_KEY_ID: + from_secret: ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY: + from_secret: SECRET_ACCESS_KEY + AWS_PLUGIN_PATH_STYLE: true + settings: + restore: true + endpoint: + from_secret: S3_ENDPOINT + bucket: + from_secret: CACHE_BUCKET + region: us-east-1 + path-style: true + cache_key: 'asdf-{{ os }}-{{ arch }}-{{ checksum ".tool-versions" }}' + mount: + - .asdf + +- name: restore bundle cache + image: meltwater/drone-cache + pull: "always" + environment: + AWS_ACCESS_KEY_ID: + from_secret: ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY: + from_secret: SECRET_ACCESS_KEY + AWS_PLUGIN_PATH_STYLE: true + settings: + restore: true + endpoint: + from_secret: S3_ENDPOINT + bucket: + from_secret: CACHE_BUCKET + region: us-east-1 + path-style: true + cache_key: 'bundle-{{ checksum "Gemfile.lock" }}-{{ checksum ".tool-versions" }}' + mount: + - .bundle + +- name: install dependencies + image: code.harton.nz/james/asdf_container:latest + pull: "always" + environment: + ASDF_DATA_DIR: /drone/src/.asdf + BUNDLE_CACHE_PATH: /drone/src/.bundle + depends_on: + - restore ASDF cache + - restore bundle cache + commands: + - apt-get update + - apt-get install -y wabt + - rm -rf /var/cache/apt + - mkdir -p bin + - cp -v /usr/bin/wat2wasm bin/ + - cp -v /usr/bin/wasm-validate bin/ + - asdf_install + - rm -rf .asdf/downloads + - asdf bundle install + +- name: store ASDF cache + image: meltwater/drone-cache + pull: "always" + environment: + AWS_ACCESS_KEY_ID: + from_secret: ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY: + from_secret: SECRET_ACCESS_KEY + AWS_PLUGIN_PATH_STYLE: true + depends_on: + - install dependencies + settings: + rebuild: true + override: false + endpoint: + from_secret: S3_ENDPOINT + bucket: + from_secret: CACHE_BUCKET + region: us-east-1 + path-style: true + cache_key: 'asdf-{{ os }}-{{ arch }}-{{ checksum ".tool-versions" }}' + mount: + - .asdf + +- name: store bundle cache + image: meltwater/drone-cache + pull: "always" + environment: + AWS_ACCESS_KEY_ID: + from_secret: ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY: + from_secret: SECRET_ACCESS_KEY + AWS_PLUGIN_PATH_STYLE: true + depends_on: + - install dependencies + settings: + rebuild: true + override: false + endpoint: + from_secret: S3_ENDPOINT + bucket: + from_secret: CACHE_BUCKET + region: us-east-1 + path-style: true + cache_key: 'bundle-{{ checksum "Gemfile.lock" }}-{{ checksum ".tool-versions" }}' + mount: + - .bundle + +- name: store WABT cache + image: meltwater/drone-cache + pull: "always" + environment: + AWS_ACCESS_KEY_ID: + from_secret: ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY: + from_secret: SECRET_ACCESS_KEY + AWS_PLUGIN_PATH_STYLE: true + depends_on: + - install dependencies + settings: + rebuild: true + override: false + endpoint: + from_secret: S3_ENDPOINT + bucket: + from_secret: CACHE_BUCKET + region: us-east-1 + path-style: true + cache_key: 'wabt' + mount: + - bin + +--- + +kind: pipeline +type: docker +name: test + +depends_on: + - build + +steps: +- name: restore ASDF cache + image: meltwater/drone-cache + pull: "always" + environment: + AWS_ACCESS_KEY_ID: + from_secret: ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY: + from_secret: SECRET_ACCESS_KEY + AWS_PLUGIN_PATH_STYLE: true + settings: + restore: true + endpoint: + from_secret: S3_ENDPOINT + bucket: + from_secret: CACHE_BUCKET + region: us-east-1 + path-style: true + cache_key: 'asdf-{{ os }}-{{ arch }}-{{ checksum ".tool-versions" }}' + mount: + - .asdf + +- name: restore bundle cache + image: meltwater/drone-cache + pull: "always" + environment: + AWS_ACCESS_KEY_ID: + from_secret: ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY: + from_secret: SECRET_ACCESS_KEY + AWS_PLUGIN_PATH_STYLE: true + settings: + restore: true + endpoint: + from_secret: S3_ENDPOINT + bucket: + from_secret: CACHE_BUCKET + region: us-east-1 + path-style: true + cache_key: 'bundle-{{ checksum "Gemfile.lock" }}-{{ checksum ".tool-versions" }}' + mount: + - .bundle + +- name: restore WABT cache + image: meltwater/drone-cache + pull: "always" + environment: + AWS_ACCESS_KEY_ID: + from_secret: ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY: + from_secret: SECRET_ACCESS_KEY + AWS_PLUGIN_PATH_STYLE: true + settings: + restore: true + endpoint: + from_secret: S3_ENDPOINT + bucket: + from_secret: CACHE_BUCKET + region: us-east-1 + path-style: true + cache_key: 'wabt' + mount: + - bin + +- name: rubocop + image: code.harton.nz/james/asdf_container:latest + pull: "always" + environment: + BUNDLE_CACHE_PATH: /drone/src/.bundle + ASDF_DATA_DIR: /drone/src/.asdf + depends_on: + - restore ASDF cache + - restore bundle cache + commands: + - asdf bundle exec rubocop + +- name: rspec + image: code.harton.nz/james/asdf_container:latest + pull: "always" + environment: + BUNDLE_CACHE_PATH: /drone/src/.bundle + ASDF_DATA_DIR: /drone/src/.asdf + depends_on: + - restore ASDF cache + - restore bundle cache + commands: + - export PATH=/drone/src/bin:$PATH + - asdf bundle exec rspec diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 795a068..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,32 +0,0 @@ -image: ruby:latest - -stages: - - test - - release - -before_script: - - apt-get update && apt-get install wabt && rm -rf /var/cache/apt - - bundle install - -test: - stage: test - script: - - bundle exec rspec - -rubocop: - stage: test - script: - - bundle exec rspec - -release: - stage: release - only: - - /^v[0-9]+\.[0-9]+\.[0-9]+$/ - except: - - branches - script: - - gem build - artifacts: - name: "wag-$CI_COMMIT_TAG.gem" - paths: - - wag-*.gem diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..0b2d858 --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +ruby 3.1.2 diff --git a/Gemfile.lock b/Gemfile.lock index 6f6a574..d89424e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -59,6 +59,7 @@ GEM unicode-display_width (2.4.2) PLATFORMS + arm64-darwin-22 x86_64-linux DEPENDENCIES diff --git a/README.md b/README.md index 2777a0a..9938c42 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ It is closely modeled after WAT, the WebAssembly text format, and at this stage generates WAT and compiles and validates it using [the WebAssembly Binary Toolkit][1]. Due to the flexibility of WAT this library is very flexible in what structures -it allows you to create. Be aware that you can build modules which are not -valid WASM. Always validate your modules by using `#to_wasm.valid?`. +it allows you to create. Be aware that you can build modules which are not +valid WASM. Always validate your modules by using `#to_wasm.valid?`. ## Keyword conflict @@ -20,7 +20,7 @@ of `public_send`, etc. ## Folding WAG supports generating both the "folded" and "unfolded" variants of the WAT -language. As an example here are two implementations of Euclid's Greatest +language. As an example here are two implementations of Euclid's Greatest Common Divisor algorithm: ### Example of unfolded generation @@ -68,6 +68,7 @@ end ``` ### Example of folded generation + ```ruby folded = WAG::Module.new.build do func(:gcd) do @@ -154,7 +155,6 @@ Or install it yourself as: $ gem install wag - ## Development After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. @@ -163,7 +163,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To ## Contributing -Bug reports and pull requests are welcome on GitLab at https://gitlab.com/jimsy/wag. +Bug reports and pull requests are welcome at https://code.harton.nz/james/wag. ## License @@ -172,7 +172,7 @@ This software is licensed under the terms of the this package for the terms. This license actively proscribes this software being used by and for some -industries, countries and activities. If your usage of this software doesn't +industries, countries and activities. If your usage of this software doesn't comply with the terms of this license, then [contact me](mailto:james@harton.nz) with the details of your use-case to organise the purchase of a license - the cost of which may include a donation to a suitable charity or NGO. diff --git a/lib/wag/export.rb b/lib/wag/export.rb index 2c73772..69cf2cf 100644 --- a/lib/wag/export.rb +++ b/lib/wag/export.rb @@ -26,7 +26,7 @@ module WAG @desc end - def table(number, type = :anyfunc, &block) + def table(number, type = :funcref, &block) @desc = Table.new(number, type) @desc.instance_exec(&block) if block @desc diff --git a/lib/wag/import.rb b/lib/wag/import.rb index a4ee138..e642932 100644 --- a/lib/wag/import.rb +++ b/lib/wag/import.rb @@ -29,7 +29,7 @@ module WAG @desc end - def table(number, type = :anyfunc, &block) + def table(number, type = :funcref, &block) @desc = Table.new(number, type) @desc.instance_exec(&block) if block @desc diff --git a/lib/wag/module.rb b/lib/wag/module.rb index feae59a..ef2a9fb 100644 --- a/lib/wag/module.rb +++ b/lib/wag/module.rb @@ -76,7 +76,7 @@ module WAG func end - def table(elements, type = :anyfunc, &block) + def table(elements, type = :funcref, &block) table = Table.new(elements, type) @tables << table table.instance_exec(&block) if block diff --git a/lib/wag/table.rb b/lib/wag/table.rb index 9105dad..38e1934 100644 --- a/lib/wag/table.rb +++ b/lib/wag/table.rb @@ -5,7 +5,7 @@ module WAG include WAG::Encodable attr_reader :elements, :type - def initialize(elements, type = :anyfunc) + def initialize(elements, type = :funcref) @elements = elements @type = type end diff --git a/renovate.json b/renovate.json deleted file mode 100644 index a932bc9..0000000 --- a/renovate.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": ["gitlab>jimsy/renovate"] -} diff --git a/spec/acceptance/code_validates_spec.rb b/spec/acceptance/code_validates_spec.rb index 0556568..6c676b1 100644 --- a/spec/acceptance/code_validates_spec.rb +++ b/spec/acceptance/code_validates_spec.rb @@ -45,7 +45,7 @@ RSpec.describe 'WAT code generation' do memory(:mem, 1) - table(16, :anyfunc) + table(16, :funcref) elem(0, :dead, :dead, :dead, :alive, :dead, :dead, :dead, :dead, :dead, :dead, :dead, :alive, :alive, :dead, :dead, :dead, diff --git a/spec/wag/export_spec.rb b/spec/wag/export_spec.rb index 457886b..7cc4728 100644 --- a/spec/wag/export_spec.rb +++ b/spec/wag/export_spec.rb @@ -19,12 +19,12 @@ RSpec.describe WAG::Export do describe 'When exporting a table' do before do - export.table(1, :anyfunc) + export.table(1, :funcref) end describe '#to_sexpr' do subject { super().to_sexpr } - it { is_expected.to eq [:export, 'marty', [:table, 1, :anyfunc]] } + it { is_expected.to eq [:export, 'marty', [:table, 1, :funcref]] } end end diff --git a/spec/wag/import_spec.rb b/spec/wag/import_spec.rb index e2145cb..8508015 100644 --- a/spec/wag/import_spec.rb +++ b/spec/wag/import_spec.rb @@ -19,12 +19,12 @@ RSpec.describe WAG::Import do describe 'When importing a table' do before do - import.table(1, :anyfunc) + import.table(1, :funcref) end describe '#to_sexpr' do subject { super().to_sexpr } - it { is_expected.to eq [:import, 'marty', 'mcfly', [:table, 1, :anyfunc]] } + it { is_expected.to eq [:import, 'marty', 'mcfly', [:table, 1, :funcref]] } end end diff --git a/spec/wag/module_spec.rb b/spec/wag/module_spec.rb index c06d172..645e80a 100644 --- a/spec/wag/module_spec.rb +++ b/spec/wag/module_spec.rb @@ -115,7 +115,7 @@ RSpec.describe WAG::Module do describe '#to_sexpr' do subject { super().to_sexpr } - it { is_expected.to eq [:module, [:table, 16, :anyfunc]] } + it { is_expected.to eq [:module, [:table, 16, :funcref]] } end end end diff --git a/spec/wag/table_spec.rb b/spec/wag/table_spec.rb index bcbd8df..4c2eb49 100644 --- a/spec/wag/table_spec.rb +++ b/spec/wag/table_spec.rb @@ -8,6 +8,6 @@ RSpec.describe WAG::Table do describe '#to_sexpr' do subject { super().to_sexpr } - it { is_expected.to eq [:table, elements, :anyfunc] } + it { is_expected.to eq [:table, elements, :funcref] } end end diff --git a/wag.gemspec b/wag.gemspec index 8b966ae..2172ba9 100644 --- a/wag.gemspec +++ b/wag.gemspec @@ -6,19 +6,19 @@ Gem::Specification.new do |spec| spec.name = 'wag' spec.version = WAG::VERSION spec.authors = ['James Harton'] - spec.email = ['james@automat.nz'] + spec.email = ['james@harton.nz'] spec.summary = 'WebAssembly Generator' spec.description = 'Generate and compile WebAssembly code from Ruby' - spec.homepage = 'https://gitlab.com/jimsy/wag' + spec.homepage = 'https://code.harton.nz/james/wag' spec.license = 'Hippocratic' spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0') # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'" spec.metadata['homepage_uri'] = spec.homepage - spec.metadata['source_code_uri'] = 'https://gitlab.com/jimsy/wag' - spec.metadata['changelog_uri'] = 'https://gitlab.com/jimsy/wag' + spec.metadata['source_code_uri'] = 'https://code.harton.nz/james/wag' + spec.metadata['changelog_uri'] = 'https://code.harton.nz/james/wag' # Specify which files should be added to the gem when it is released. The `git # ls-files -z` loads the files in the RubyGem that have been added into git.