Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create GitHub actions workflow to run tests #41

Merged
merged 10 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby

name: Ruby

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
test:

runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['2.7', '3.0']

steps:
- uses: actions/checkout@v4
- name: Set up Ruby
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
# change this to (see https://github.com/ruby/setup-ruby#versioning):
uses: ruby/setup-ruby@v1 # v1.146.0
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run tests
run: bundle exec rake
12 changes: 0 additions & 12 deletions .travis.yml

This file was deleted.

6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# threema

[![Build Status](https://travis-ci.org/thorsteneckel/threema.svg?branch=master)](https://travis-ci.org/thorsteneckel/threema)
[![codecov](https://codecov.io/gh/thorsteneckel/threema/branch/master/graph/badge.svg)](https://codecov.io/gh/thorsteneckel/threema)
[![Code Climate](https://codeclimate.com/github/thorsteneckel/threema/badges/gpa.svg)](https://codeclimate.com/github/thorsteneckel/threema)
[![Gem](https://img.shields.io/gem/v/threema.svg?maxAge=2592000)]()


This gem provides access to the Threema Gateway API.

## Installation
Expand Down
1 change: 0 additions & 1 deletion lib/threema/blob.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# frozen_string_literal: true

require 'case_transform'
require 'threema/exceptions'

class Threema
Expand Down
2 changes: 0 additions & 2 deletions lib/threema/capabilities.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'case_transform'

class Threema
class Capabilities
class << self
Expand Down
6 changes: 2 additions & 4 deletions lib/threema/lookup.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'case_transform'

class Threema
class Lookup
URL_PATH = {
Expand Down Expand Up @@ -67,7 +65,7 @@ def bulk(params)
def keys_camel_lower(params)
cameled = {}
params.each do |key, value|
cameled[CaseTransform.camel_lower(key.to_s)] = value
cameled[key.to_s.camelize(:lower)] = value
end
cameled
end
Expand All @@ -76,7 +74,7 @@ def underscore_entry_keys(list)
list.collect do |response_entry|
result_entry = {}
response_entry.each do |key, value|
result_entry[CaseTransform.underscore(key).to_sym] = value
result_entry[key.underscore.to_sym] = value
end

result_entry
Expand Down
3 changes: 1 addition & 2 deletions lib/threema/receive.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# frozen_string_literal: true

require 'case_transform'
require 'threema/e2e/mac'
require 'threema/typed_message'
require 'threema/lookup'
Expand Down Expand Up @@ -65,7 +64,7 @@ def classify(type)
end

def class_name(type)
class_name = CaseTransform.camel(type.to_s)
class_name = type.to_s.camelize
"Threema::Receive::#{class_name}"
end

Expand Down
1 change: 0 additions & 1 deletion lib/threema/send.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# frozen_string_literal: true

require 'case_transform'
require 'threema/exceptions'
require 'threema/send/simple'
require 'threema/send/text'
Expand Down
1 change: 1 addition & 0 deletions spec/factories/threema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
factory :threema do
api_identity { test_from }
api_secret { test_api_secret }
private_key { test_private_key }

initialize_with do
new(**attributes)
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/threema_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

FactoryBot.define do
factory :threema_client, class: Threema::Client do
threema { FactoryBot.build(:threema) }
threema

initialize_with do
new(**attributes)
Expand Down
8 changes: 1 addition & 7 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,13 @@
require 'pry'

require 'simplecov'
require 'codecov'
require 'codeclimate-test-reporter'

SimpleCov.start do
# Don't get coverage on the test cases themselves.
add_filter '/spec/'
add_filter '/test/'
# Codecov doesn't automatically ignore vendored files.
add_filter '/vendor/'
end
SimpleCov.formatter = SimpleCov::Formatter::Codecov

CodeClimate::TestReporter.start
SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter

require 'threema'

Expand Down
8 changes: 4 additions & 4 deletions spec/support/shared_values.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ def hello_world
end

def test_public_key
ENV['THREEMARB_PUBLIC']
'd981f35570026a9551fbb27709087fe9c268b8f1395998b4ae5019476cd58fae'
end

def test_private_key
ENV['THREEMARB_PRIVATE']
'2edf856e8a0f8f8e761be57f895f8827f42c6be0c6c891b95494faa7d264f7d9'
end

def test_auth_params
Expand All @@ -24,11 +24,11 @@ def test_auth_params
end

def test_from
ENV['THREEMARB_API_IDENTITY']
'*VALID1'
end

def test_api_secret
ENV['THREEMARB_API_SECRET']
'CWWuNaFDkEZLiRSt'
end

def test_blob_id
Expand Down
14 changes: 7 additions & 7 deletions spec/threema/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
expect(described_class).to respond_to(:url)
end

let(:instance) { build(:threema_client, threema: threema) }
let(:threema) { build(:threema) }
let(:instance) { build(:threema_client) }
let!(:threema) { build(:threema) }

context '#not_found_ok' do
it 'responds to not_found_ok' do
Expand Down Expand Up @@ -53,8 +53,8 @@

before(:each) do
instance.configure do |config|
# Threema API fingerprint as of 2021-02-27
fingerprint = '42b1038e72f00c8c4dad78a3ebdc6d7a50c5ef288da9019b9171e4d675c08a17'
# Threema API fingerprint as of 2024-04-30
fingerprint = '317bc8626c34a2ccd9052164828f4eb71a6bc6290e2569acee5b3a2cbde13d2a'

# See: http://stackoverflow.com/a/22108461
config.use_ssl = true
Expand All @@ -74,8 +74,8 @@
end
end

# this is needed due to internet access restrictions
# in the (travis) CI environment
# skipped in CI because this test requires actual
# private key, identity, etc set in .env variables
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And that's the only spec that fails on my machine locally. 👍

if !ENV['CI']
context 'given Threema Message API URL with matching certificate' do
let(:url) { described_class::API_URL }
Expand All @@ -87,7 +87,7 @@
end

context 'given another URL without matching certificate' do
let(:url) { 'https://github.com/thorsteneckel/threema' }
let(:url) { 'https://github.com/threemarb/threema' }
it { should raise_error(OpenSSL::SSL::SSLError) }

context 'but if static certificate pinning is disabled' do
Expand Down
6 changes: 2 additions & 4 deletions threema.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,19 @@ Gem::Specification.new do |spec|
spec.homepage = 'https://github.com/thorsteneckel/threema'
spec.license = 'MIT'

spec.required_ruby_version = '>= 2.6.0'
spec.required_ruby_version = '>= 2.7.0'

spec.files = Dir['{lib}/**/*']
spec.require_paths = ['lib']

spec.add_runtime_dependency 'case_transform'
spec.add_runtime_dependency 'activesupport', '~> 7.0.8'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to only import active support's string inflections. But I'm not aware how this is possible in Ruby land.

spec.add_runtime_dependency 'dotenv'
spec.add_runtime_dependency 'mimemagic'
spec.add_runtime_dependency 'mime-types'
spec.add_runtime_dependency 'multipart-post'
spec.add_runtime_dependency 'rbnacl'

spec.add_development_dependency 'bundler'
spec.add_development_dependency 'codeclimate-test-reporter', '~> 0.6'
spec.add_development_dependency 'codecov'
spec.add_development_dependency 'factory_bot'
spec.add_development_dependency 'fakefs'
spec.add_development_dependency 'pry'
Expand Down