Skip to content

Commit

Permalink
CI integration
Browse files Browse the repository at this point in the history
  • Loading branch information
MeNsaaH committed Mar 20, 2022
1 parent e89e420 commit f343233
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 13 deletions.
14 changes: 1 addition & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,6 @@ jobs:
uses: actions/checkout@v2
- name: Setup SSH server
# run docker ssh container for ssh tests
run: |
sudo mkdir -p /home/runner/.ssh
echo "${{ secrets.TEST_PUB_KEY }}" >> /home/runner/.ssh/id_rsa.pub
echo "${{ secrets.TEST_PRIV_KEY }}" >> /home/runner/.ssh/id_rsa
docker run -d \
-e PASSWORD_ACCESS=false \
-e PGID=1000 \
-e PUID=1000 \
-e SUDO_ACCESS=false \
-e USER_NAME=dev \
-e PUBLIC_KEY_FILE=/root/.ssh/id_rsa.pub \
-v /home/runner/.ssh/id_rsa.pub:/root/.ssh/id_rsa.pub \
linuxserver/openssh-server
run: make prep-ci
- name: Test
run: go test -v ./...
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ vendor/
*.swp

docker-compose.yaml
ssh-key/ci/
config-ci.yaml
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Example:
# make
# make ci-test
.PHONY: prep-ci
# Creates the ssh keys and docker container for running test
ci-test:
./scripts/make-ci-test.sh
go test -v ./..
2 changes: 2 additions & 0 deletions integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"strings"
"testing"

"github.com/bisohns/saido/config"
"github.com/bisohns/saido/driver"
"github.com/bisohns/saido/inspector"
)
Expand All @@ -17,6 +18,7 @@ func NewWebForTest() driver.Driver {
}

func NewSSHForTest() driver.Driver {
_ = config.GetConfig()
return &driver.SSH{
User: "dev",
Host: "127.0.0.1",
Expand Down
20 changes: 20 additions & 0 deletions scripts/make-ci-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
SSH_KEY_NAME=${SSH_KEY_NAME:-ci-test-key}
SSH_KEY_PATH=ssh-key/ci
SSH_USER=ci-dev
rm -rf $SSH_KEY_PATH
mkdir -p $SSH_KEY_PATH
ssh-keygen -f "$SSH_KEY_PATH/${SSH_KEY_NAME}" -N ""
docker run -d -p 2222:2222 -e USER_NAME=$SSH_USER --name linux-sshserver -v $(pwd)/ci.pub:/config/.ssh/authorized_keys linuxserver/openssh-server
cat <<EOF > config-ci.yaml
hosts:
connection:
type: ssh
username: ${SSH_USER}
private_key_path: $(pwd)/${SSH_KEY_NAME}.pub
children:
"$(docker inspect -f "{{ .NetworkSettings.IPAddress }}" linux-sshserver)":
metrics:
- memory
- cpu
EOF

0 comments on commit f343233

Please sign in to comment.