Skip to content

Commit

Permalink
Merge pull request #1 from docksal/develop
Browse files Browse the repository at this point in the history
Release 1.1.0
  • Loading branch information
lmakarov authored Oct 16, 2018
2 parents 9f42d1c + 7401654 commit 46fe0f6
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 2 deletions.
28 changes: 28 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
sudo: required

language: generic

env:
REPO: docksal/ssh-agent
IMAGE_DNS: ${REPO}:dev
DOCKSAL_VERSION: develop

services:
- docker

install:
# Install Docksal to have a matching versions of Docker on the build host
- curl -fsSL https://get.docksal.io | DOCKSAL_VERSION=${DOCKSAL_VERSION} bash
- fin version
- fin sysinfo

script:
- make
- make start
- make test

after_success:
- make release

after_failure:
- make logs
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.4
FROM alpine:3.8

RUN apk add --no-cache \
bash \
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2016-2017 Docksal
Copyright (c) 2016-2018 Docksal

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
54 changes: 54 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
-include env_make

VERSION ?= dev

REPO = docksal/ssh-agent
NAME = docksal-ssh-agent

.EXPORT_ALL_VARIABLES:

.PHONY: build exec test push shell run start stop logs debug clean release

build:
docker build -t ${REPO}:${VERSION} .

test:
IMAGE=${REPO}:${VERSION} bats tests/test.bats

push:
docker push ${REPO}:${VERSION}

exec:
@docker exec ${NAME} ${CMD}

exec-it:
@docker exec -it ${NAME} ${CMD}

shell:
@make exec-it -e CMD=sh

run: clean
docker run --rm -it ${REPO}:${VERSION} sh

# This is the only place where fin is used/necessary
start:
IMAGE_SSH_AGENT=${REPO}:${VERSION} fin system reset ssh-agent

stop:
docker stop ${NAME}

logs:
docker logs ${NAME}

logs-follow:
docker logs -f ${NAME}

debug: build start logs-follow

release:
@scripts/release.sh

clean:
docker rm -vf ${NAME} || true

default: build
16 changes: 16 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

if [[ "${TRAVIS_PULL_REQUEST}" == "false" ]]; then
# develop => edge
[[ "${TRAVIS_BRANCH}" == "develop" ]] && TAG="edge"
# master => latest
[[ "${TRAVIS_BRANCH}" == "master" ]] && TAG="latest"
# tags/v1.2.0 => 1.2
[[ "${TRAVIS_TAG}" != "" ]] && TAG="${TRAVIS_TAG:1:3}"

if [[ "$TAG" != "" ]]; then
docker login -u "${DOCKER_USER}" -p "${DOCKER_PASS}"
docker tag ${IMAGE_DNS} ${REPO}:${TAG}
docker push ${REPO}:${TAG}
fi;
fi;
45 changes: 45 additions & 0 deletions tests/test.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bats

# Debugging
teardown() {
echo
echo "Output:"
echo "================================================================"
echo "${output}"
echo "================================================================"
}

# To work on a specific test:
# run `export SKIP=1` locally, then comment skip in the test you want to debug

@test "ssh-agent container is up and using the \"${IMAGE}\" image" {
[[ ${SKIP} == 1 ]] && skip

run docker ps --filter "name=docksal-ssh-agent" --format "{{ .Image }}"
[[ "$output" =~ "$IMAGE" ]]
unset output
}

@test "fin ssh-key add" {
[[ ${SKIP} == 1 ]] && skip

# Generate a key
ssh_key_name="ssh_agent_test_id_rsa"
ssh_key_file="${HOME}/.ssh/${ssh_key_name}"
rm -f ${ssh_key_file}
ssh-keygen -t rsa -b 4096 -f ${ssh_key_file} -q -N ""

# Add the key to the agent
run fin ssh-add ${ssh_key_name}
# Cleanup garbage \r from the output otherwise there won't be an exact match
[[ "$(echo ${output} | tr -d '\r')" == "Identity added: ${ssh_key_name} (${ssh_key_name})" ]]
unset output

# Check they key is present in the agent
run fin ssh-add -l
[[ ${output} == *${ssh_key_name}* ]]
unset output

# Cleanup
rm -f ${ssh_key_file}
}

0 comments on commit 46fe0f6

Please sign in to comment.