Skip to content

Commit

Permalink
chore(CI): migrate to github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
stakach committed May 26, 2021
1 parent 1589903 commit 52bb1cb
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 33 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CI
on:
push:
workflow_dispatch:
schedule:
- cron: "0 6 * * 1"
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
crystal:
- latest
- nightly
- 1.0.0
runs-on: ${{ matrix.os }}
container: crystallang/crystal:${{ matrix.crystal }}-alpine

services:
# Label used to access the service container
sshdev:
# Docker Hub image
image: placeos/ssh-test
options: >-
-p 2222:22
-e ROOT_PASS="somepassword"
steps:
- uses: actions/checkout@v2
- name: Install LibSSH2
run: apk add --no-cache libssh2 libssh2-dev libssh2-static
- name: Install dependencies
run: shards install --ignore-crystal-version
- name: Lint
run: ./bin/ameba
- name: Format
run: crystal tool format --check
- name: Run tests
run: crystal spec -v --error-trace
env:
SPEC_SSH_HOST: sshdev
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ssh2.cr

[![Build Status](https://travis-ci.org/spider-gazelle/ssh2.cr.svg?branch=master)](https://travis-ci.org/spider-gazelle/ssh2.cr)
[![CI](https://github.com/spider-gazelle/ssh2/actions/workflows/ci.yml/badge.svg)](https://github.com/spider-gazelle/ssh2/actions/workflows/ci.yml)

This library provides binding for libssh2 library.

Expand Down
16 changes: 9 additions & 7 deletions spec/ssh2_spec.cr
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
require "../src/ssh2"
require "spec"

SPEC_SSH_HOST = ENV["SPEC_SSH_HOST"]? || "localhost"

def connect_ssh
SSH2::Session.open("localhost", 2222) do |session|
SSH2::Session.open(SPEC_SSH_HOST, 2222) do |session|
if ENV["TRAVIS"]?
session.login("root", "somepassword")
else
Expand All @@ -26,7 +28,7 @@ describe SSH2 do
end

it "should be able to connect in interactive mode" do
SSH2::Session.open("localhost", 2222) do |session|
SSH2::Session.open(SPEC_SSH_HOST, 2222) do |session|
session.interactive_login("root") { "somepassword" }

session.open_session do |channel|
Expand All @@ -39,7 +41,7 @@ describe SSH2 do
end

it "should obtain a list of supported auth methods" do
SSH2::Session.open("localhost", 2222) do |session|
SSH2::Session.open(SPEC_SSH_HOST, 2222) do |session|
methods = session.login_with_noauth("root")
methods.should eq(["publickey", "password", "keyboard-interactive"])
end
Expand Down Expand Up @@ -90,20 +92,20 @@ describe SSH2::KnownHosts do
else
fail "unknown key_type: #{key_type}"
end
known_hosts.add("localhost", "", key, "comment", typemask)
known_hosts.add(SPEC_SSH_HOST, "", key, "comment", typemask)
known_hosts.add("127.0.0.1", "", key, "comment", typemask)
known_hosts.size.should eq(2)
known_hosts.map(&.name).includes?("localhost").should be_true
known_hosts.map(&.name).includes?(SPEC_SSH_HOST).should be_true
known_hosts.write_file("known_hosts")
known_hosts.delete_if { |h| h.name == "localhost" }
known_hosts.delete_if { |h| h.name == SPEC_SSH_HOST }
known_hosts.size.should eq(1)
end

connect_ssh do |session|
known_hosts = session.knownhosts
known_hosts.read_file("known_hosts")
key, _ = session.hostkey
host = known_hosts.check("localhost", 2222, key, LibSSH2::TypeMask::PLAIN | LibSSH2::TypeMask::KEYENC_RAW)
host = known_hosts.check(SPEC_SSH_HOST, 2222, key, LibSSH2::TypeMask::PLAIN | LibSSH2::TypeMask::KEYENC_RAW)
host.should eq(LibSSH2::KnownHostCheck::MATCH)
end
File.delete("known_hosts")
Expand Down

0 comments on commit 52bb1cb

Please sign in to comment.