Skip to content

Commit

Permalink
merge drone branch
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonenzo committed Jun 24, 2020
2 parents c5b1645 + 922508e commit b67ab61
Show file tree
Hide file tree
Showing 7 changed files with 218 additions and 1 deletion.
74 changes: 74 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
kind: pipeline
name: default

steps:
## builds and pushes to hub.docker.com, the docker repo is just private right now.
- name: docker build
image: plugins/docker
settings:
username:
from_secret: docker_username
password:
from_secret: docker_password
repo: nelsonenzo/tmux-appimage
tags: build-${DRONE_COMMIT}

- name: copy artifact to s3
image: nelsonenzo/tmux-appimage:build-${DRONE_COMMIT}
commands:
export AWS_ACCESS_KEY_ID=$${aws_access_key_id}
export AWS_ACCESS_SECRET_KEY=$${aws_access_secret_key}
aws s3 cp /opt/releases/tmux-3.0a-x86_64.AppImage tmux-appimage/${DRONE_COMMIT}/tmux-3.0a-x86_64.AppImage

# copy the image to s3://tmux-appimage-builds/build-id/appimage
## requires IAM key for S3
## change to update.sh script to pull Appimage from S3
## how to identify the build id in userdata or tags?
# - name: terraform test environment
# terraform:
# image: jmccann/drone-terraform:1
# plan: false
# root_dir: terraform

# terraform build 5 instances
# run tests
# if successful && branch == master
## publish to github
## push to s3/latest with zsync file.
## destroy instances
# if fail
## output command to ssh


# COMMENTING FOR NOW. THIS WORKS THOUGH. DO NOT DELETE.
# - name: create release on github
# image: nelsonenzo/tmux-appimage:692f3cf549ebbb95b5111845dc9f92a202e8d9a8
# environment:
# FILE: /opt/releases/tmux-3.0a-x86_64.AppImage
# GITHUB_TOKEN:
# from_secret: personal_access_token
# commands:
# - |
# cat > github.json <<- EOM
# {
# "tag_name": "${DRONE_REPO_BRANCH}",
# "target_commitish": "${DRONE_REPO_BRANCH}",
# "name": "Tmux AppImage $RELEASE_TAG ${DRONE_REPO_BRANCH}",
# "body": "Appimage release for branch ${DRONE_REPO_BRANCH}",
# "draft": true,
# "prerelease": true
# }
# EOM
# - echo $(cat github.json)
# - |
# curl -X POST -d @github.json \
# -H "Authorization: token $${GITHUB_TOKEN}" \
# https://api.github.com/repos/nelsonenzo/tmux-appimage/releases > githubresponse.txt
# - echo $(cat githubresponse.txt)
# - export GITHUB_RELEASE_ID=$(jq .id githubresponse.txt)
# - echo $GITHUB_RELEASE_ID
# - |
# curl -H "Authorization: token $${GITHUB_TOKEN}" \
# -H "Content-Type: $(file -b --mime-type $FILE)" \
# --data-binary @$FILE \
# "https://uploads.github.com/repos/nelsonenzo/tmux-appimage/releases/$GITHUB_RELEASE_ID/assets?name=$(basename $FILE)"
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
opt/releases/*
localnotes/*
dronesecrets.txt
.terraform
terraform/notes.md
terraform.tfstate
terraform.tfstate.backup
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous
RUN yum install -y libevent2-devel.x86_64 ncurses-devel

## Change RELEASE_TAG to desired version/git sha
ENV RELEASE_TAG=3.0a
ENV RELEASE_TAG=3.1a
RUN git clone https://github.com/tmux/tmux.git && cd tmux && git checkout $RELEASE_TAG

WORKDIR /tmux
Expand Down
8 changes: 8 additions & 0 deletions github.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"tag_name": "drone",
"target_commitish": "drone",
"name": "Tmux AppImage 3.0a drone",
"body": "Appimage release for branch drone",
"draft": true,
"prerelease": true
}
17 changes: 17 additions & 0 deletions terraform/runtest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
# arch_ip = ssh [email protected]
# debian_ip = ssh [email protected]
# redhat_ip = ssh [email protected]
# suse_ip = ssh [email protected]
# ubuntu_ip = ssh [email protected]
hosts='[email protected]
[email protected]
[email protected]
[email protected]
[email protected]'

for i in $hosts; do
echo $i
# ssh $i 'sudo -u root tmux ls; ls /touch-passed-true;'
ssh -o StrictHostKeyChecking=no $i 'cat /touch-passed-true && cat /session-passed-true'
done
64 changes: 64 additions & 0 deletions terraform/tmux-testing.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
provider "aws" {
region = "us-east-1"
# shared_credentials_file = "/home/nelson/.aws/sso/cache/9cbcd2e573df943bafdb496ecb072776ba8ddecb.json"
# profile = "tools"
}

# # Find the latest available AMI that is tagged with Component = web
# data "aws_ami" "ubuntu" {
# filter {
# name = "id"
# values = ["ami-07ebfd5b3428b6f4d"]
# }
#
#
# most_recent = true
# }

resource "aws_instance" "ubuntu_1804" {
ami = "ami-07ebfd5b3428b6f4d"
instance_type = "t1.micro"
key_name = "personal-aws"
associate_public_ip_address = true
user_data = file("./userdata.sh")
}

resource "aws_instance" "suse_linux" {
ami = "ami-0df6cfabfbe4385b7"
instance_type = "t1.micro"
key_name = "personal-aws"
associate_public_ip_address = true
user_data = file("./userdata.sh")
}

resource "aws_instance" "redhat_enterprise" {
ami = "ami-0c322300a1dd5dc79"
instance_type = "t1.micro"
key_name = "personal-aws"
associate_public_ip_address = true
user_data = file("./userdata.sh")
}

resource "aws_instance" "debian_stretch" {
ami = "ami-066027b63b44ebc0a"
instance_type = "t1.micro"
key_name = "personal-aws"
associate_public_ip_address = true
user_data = file("./userdata.sh")
}

resource "aws_instance" "arch_linux" {
ami = "ami-0f040c7d22aedeb27"
instance_type = "t1.micro"
key_name = "personal-aws"
associate_public_ip_address = true
user_data = file("./userdata.sh")
}


output "ubuntu_ip" { value = "ubuntu@${aws_instance.ubuntu_1804.public_ip}" }
output "suse_ip" { value = "ec2-user@${aws_instance.suse_linux.public_ip}" }
output "redhat_ip" { value = "ec2-user@${aws_instance.redhat_enterprise.public_ip}" }
output "debian_ip" { value = "admin@${aws_instance.debian_stretch.public_ip}" }
output "arch_ip" { value = "arch@${aws_instance.arch_linux.public_ip}" }
# TERM=xterm sudo ./squashfs-root/usr/bin/tmux -2
48 changes: 48 additions & 0 deletions terraform/userdata.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

DOWNLOAD=$(curl -s "https://api.github.com/repos/nelsonenzo/tmux-appimage/releases/tags/master" | grep browser_download_url | awk '{print $2}')
DOWNLOAD=$(sed -e 's/^"//' -e 's/"$//' <<<"$DOWNLOAD")
curl -L -s $DOWNLOAD --output /usr/local/bin/tmux
sudo chmod +x /usr/local/bin/tmux

function touch-test {
sleep 1;
if grep -q 'touch: missing file operand' $HOME/touch-output.txt; then
echo 1 > $HOME/touch-passed-true
fi
}

function validate_tmux_session_running {
tmux ls;
if [ $? = 0 ]; then
echo 1 > $HOME/session-passed-true
else
exit 1;
fi
}

if which pacman; then
sudo pacman -Sy --noconfirm fuse2
TERM=xterm tmux new -d -s touch-session 'touch > $HOME/touch-output.txt 2>&1;'
touch-test
TERM=xterm tmux -2 tmux new -d -s test-session
elif which yum; then
sudo yum install -y fuse
TERM=xterm tmux new -d -s touch-session 'touch > $HOME/touch-output.txt 2>&1;'
touch-test
TERM=xterm tmux -2 tmux new -d -s test-session
elif which zypper; then
sudo zypper install -y fuse
tmux new -d -s touch-session 'touch > $HOME/touch-output.txt 2>&1;'
touch-test
tmux new -d -s test-session
elif which apt-get; then
sudo apt-get install -y fuse
tmux new -d -s touch-session 'touch > $HOME/touch-output.txt 2>&1;'
touch-test
tmux new -d -s test-session
else
echo "no-package-manager" > tmux-env.txt
fi

validate_tmux_session_running

0 comments on commit b67ab61

Please sign in to comment.