Skip to content
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
109 changes: 100 additions & 9 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,15 @@ blocks:
- unzip /tmp/packer_1.7.9_linux_amd64.zip -d /tmp/
- sudo mv /tmp/packer /usr/local/bin/
jobs:
- name: Build Linux AMI
- name: Build Linux Focal AMI
commands:
- ./ci/build-ami.sh ubuntu-focal x86_64
- name: Build Linux Jammy AMI
commands:
- ./ci/build-ami.sh ubuntu-jammy x86_64
- name: Build Linux Noble AMI
commands:
- ./ci/build-ami.sh ubuntu-noble x86_64
- name: Build Windows AMI
commands:
- ./ci/build-ami.sh windows x86_64
Expand All @@ -119,7 +125,7 @@ blocks:
- cache restore
- ./ci/create-execution-policy-and-bootstrap.sh $AWS_ACCOUNT_ID $AWS_DEFAULT_REGION

- name: Linux launch
- name: Linux Focal launch
dependencies:
- Bootstrap
task:
Expand All @@ -132,7 +138,37 @@ blocks:
- checkout
- cache restore
- ./ci/create-ssm-param.sh s1-agent-aws-stack-linux-token $TOKEN
- SEMAPHORE_AGENT_STACK_CONFIG=./ci/linux-config.json npm run deploy:ci
- SEMAPHORE_AGENT_STACK_CONFIG=./ci/linux-focal-config.json npm run deploy:ci

- name: Linux Jammy launch
dependencies:
- Bootstrap
task:
secrets:
- name: s1-agent-aws-stack-linux-token
- name: agent-aws-stack-tester-credentials
jobs:
- name: Launch stack
commands:
- checkout
- cache restore
- ./ci/create-ssm-param.sh s1-agent-aws-stack-linux-jammy-token $TOKEN_JAMMY
- SEMAPHORE_AGENT_STACK_CONFIG=./ci/linux-jammy-config.json npm run deploy:ci

- name: Linux Noble launch
dependencies:
- Bootstrap
task:
secrets:
- name: s1-agent-aws-stack-linux-token
- name: agent-aws-stack-tester-credentials
jobs:
- name: Launch stack
commands:
- checkout
- cache restore
- ./ci/create-ssm-param.sh s1-agent-aws-stack-linux-noble-token $TOKEN_NOBLE
- SEMAPHORE_AGENT_STACK_CONFIG=./ci/linux-noble-config.json npm run deploy:ci

- name: Windows launch
dependencies:
Expand All @@ -149,9 +185,9 @@ blocks:
- ./ci/create-ssm-param.sh s1-agent-aws-stack-windows-token $TOKEN
- SEMAPHORE_AGENT_STACK_CONFIG=./ci/windows-config.json npm run deploy:ci

- name: Linux tests
- name: Linux Focal tests
dependencies:
- Linux launch
- Linux Focal launch
execution_time_limit:
minutes: 10
task:
Expand All @@ -165,10 +201,55 @@ blocks:
jobs:
- name: Run goss tests
commands:
- if [ "$(grep VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '"' | cut -d. -f1-2)" != "20.04" ]; then exit 1; fi
- sudo curl -L https://github.com/aelsabbahy/goss/releases/latest/download/goss-linux-amd64 -o /usr/local/bin/goss
- sudo chmod +rx /usr/local/bin/goss
- checkout
- goss -g goss/goss.yaml --vars goss/vars-focal.yml validate --max-concurrent 1 --format junit > results.xml

- name: Linux Jammy tests
dependencies:
- Linux Jammy launch
execution_time_limit:
minutes: 10
task:
agent:
machine:
type: s1-agent-aws-stack-linux-jammy
epilogue:
always:
commands:
- if [ -f results.xml ]; then test-results publish results.xml; fi
jobs:
- name: Run goss tests
commands:
- if [ "$(grep VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '"' | cut -d. -f1-2)" != "22.04" ]; then exit 1; fi
- sudo curl -L https://github.com/aelsabbahy/goss/releases/latest/download/goss-linux-amd64 -o /usr/local/bin/goss
- sudo chmod +rx /usr/local/bin/goss
- checkout
- goss -g goss/goss.yaml --vars goss/vars.yml validate --max-concurrent 1 --format junit > results.xml
- goss -g goss/goss.yaml --vars goss/vars-jammy.yml validate --max-concurrent 1 --format junit > results.xml

- name: Linux Noble tests
dependencies:
- Linux Noble launch
execution_time_limit:
minutes: 10
task:
agent:
machine:
type: s1-agent-aws-stack-linux-noble
epilogue:
always:
commands:
- if [ -f results.xml ]; then test-results publish results.xml; fi
jobs:
- name: Run goss tests
commands:
- if [ "$(grep VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '"' | cut -d. -f1-2)" != "24.04" ]; then exit 1; fi
- sudo curl -L https://github.com/aelsabbahy/goss/releases/latest/download/goss-linux-amd64 -o /usr/local/bin/goss
- sudo chmod +rx /usr/local/bin/goss
- checkout
- goss -g goss/goss.yaml --vars goss/vars-noble.yml validate --max-concurrent 1 --format junit > results.xml

- name: Windows tests
dependencies:
Expand Down Expand Up @@ -197,13 +278,23 @@ after_pipeline:
- name: Submit Reports
commands:
- test-results gen-pipeline-report
- name: Destroy Linux stack
- name: Destroy Linux Focal stack
commands:
- checkout
- cache restore
- SEMAPHORE_AGENT_STACK_CONFIG=./ci/linux-focal-config.json npm run destroy:ci
- name: Destroy Linux Jammy stack
commands:
- checkout
- cache restore
- SEMAPHORE_AGENT_STACK_CONFIG=./ci/linux-jammy-config.json npm run destroy:ci
- name: Destroy Linux Noble stack
commands:
- checkout
- cache restore
- SEMAPHORE_AGENT_STACK_CONFIG=./ci/linux-config.json npm run destroy:ci
- SEMAPHORE_AGENT_STACK_CONFIG=./ci/linux-noble-config.json npm run destroy:ci
- name: Destroy Windows stack
commands:
- checkout
- cache restore
- SEMAPHORE_AGENT_STACK_CONFIG=./ci/windows-config.json npm run destroy:ci
- SEMAPHORE_AGENT_STACK_CONFIG=./ci/windows-config.json npm run destroy:ci
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,23 @@ AMI_INSTANCE_TYPE=t2.micro
AGENT_VERSION=v2.2.16
TOOLBOX_VERSION=v1.20.5
PACKER_OS=linux
UBUNTU_VERSION=focal

# Set Ubuntu name and version number based on UBUNTU_VERSION
ifeq ($(UBUNTU_VERSION),focal)
UBUNTU_NAME=focal
UBUNTU_VERSION_NUMBER=20.04
else ifeq ($(UBUNTU_VERSION),noble)
UBUNTU_NAME=noble
UBUNTU_VERSION_NUMBER=24.04
else ifeq ($(UBUNTU_VERSION),jammy)
UBUNTU_NAME=jammy
UBUNTU_VERSION_NUMBER=22.04
else
UBUNTU_NAME=focal
UBUNTU_VERSION_NUMBER=20.04
endif

INSTALL_ERLANG=true
SYSTEMD_RESTART_SECONDS=1800
VERSION=$(shell cat package.json | jq -r '.version')
Expand Down Expand Up @@ -62,6 +79,8 @@ packer.validate.linux:
-var "install_erlang=$(INSTALL_ERLANG)" \
-var "systemd_restart_seconds=$(SYSTEMD_RESTART_SECONDS)" \
-var "instance_type=$(AMI_INSTANCE_TYPE)" \
-var "ubuntu_name=$(UBUNTU_NAME)" \
-var "ubuntu_version=$(UBUNTU_VERSION_NUMBER)" \
.'

packer.validate.windows:
Expand Down Expand Up @@ -119,6 +138,8 @@ packer.build.linux:
-var "install_erlang=$(INSTALL_ERLANG)" \
-var "systemd_restart_seconds=$(SYSTEMD_RESTART_SECONDS)" \
-var "instance_type=$(AMI_INSTANCE_TYPE)" \
-var "ubuntu_name=$(UBUNTU_NAME)" \
-var "ubuntu_version=$(UBUNTU_VERSION_NUMBER)" \
.'

packer.build.windows:
Expand Down
17 changes: 14 additions & 3 deletions ci/build-ami.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ if [[ -z "${arch}" ]]; then
fi

packer_os=linux
ubuntu_version=""

if [[ ${os} == "windows" ]]; then
packer_os=windows
elif [[ ${os} == *"ubuntu-"* ]]; then
# Extract ubuntu version from os parameter (e.g., ubuntu-noble -> noble)
ubuntu_version=${os#*ubuntu-}
fi

version=$(cat package.json | jq -r '.version')
Expand All @@ -28,9 +33,15 @@ response=$(aws ec2 describe-images --filters "Name=name,Values=${image_name}")
images=$(echo $response | jq '.Images' | jq length)
if [[ ${images} == "0" ]]; then
echo "No images published with name ${image_name}. Creating it..."
make packer.init
make packer.validate PACKER_OS=${packer_os}
make packer.build PACKER_OS=${packer_os}
if [[ -n "${ubuntu_version}" ]]; then
make packer.init PACKER_OS=${packer_os} UBUNTU_VERSION=${ubuntu_version}
make packer.validate PACKER_OS=${packer_os} UBUNTU_VERSION=${ubuntu_version}
make packer.build PACKER_OS=${packer_os} UBUNTU_VERSION=${ubuntu_version}
else
make packer.init PACKER_OS=${packer_os}
make packer.validate PACKER_OS=${packer_os}
make packer.build PACKER_OS=${packer_os}
fi
else
echo "Image with name ${image_name} already exists. Not building anything."
fi
2 changes: 1 addition & 1 deletion ci/create-execution-policy-and-bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ echo "Bootstrapping application..."
# For the bootstrap part, it doesn't really matter which stack
# we are deploying, only that the CDK required resources are bootstrapped,
# so we just use the linux config for this.
SEMAPHORE_AGENT_STACK_CONFIG=./ci/linux-config.json npm run bootstrap -- aws://${aws_account_id}/${aws_region} \
SEMAPHORE_AGENT_STACK_CONFIG=./ci/linux-focal-config.json npm run bootstrap -- aws://${aws_account_id}/${aws_region} \
--cloudformation-execution-policies "${policy_arn}" \
--verbose
3 changes: 2 additions & 1 deletion ci/linux-config.json → ci/linux-focal-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"SEMAPHORE_AGENT_TOKEN_PARAMETER_NAME": "s1-agent-aws-stack-linux-token",
"SEMAPHORE_AGENT_USE_DYNAMIC_SCALING": "true",
"SEMAPHORE_AGENT_DISCONNECT_AFTER_JOB": "false",
"SEMAPHORE_AGENT_ASG_MAX_SIZE": "1"
"SEMAPHORE_AGENT_ASG_MAX_SIZE": "1",
"SEMAPHORE_AGENT_OS": "ubuntu-focal"
}
9 changes: 9 additions & 0 deletions ci/linux-jammy-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"SEMAPHORE_AGENT_STACK_NAME": "agent-aws-stack-linux-jammy",
"SEMAPHORE_ORGANIZATION": "semaphore",
"SEMAPHORE_AGENT_TOKEN_PARAMETER_NAME": "s1-agent-aws-stack-linux-jammy-token",
"SEMAPHORE_AGENT_USE_DYNAMIC_SCALING": "true",
"SEMAPHORE_AGENT_DISCONNECT_AFTER_JOB": "false",
"SEMAPHORE_AGENT_ASG_MAX_SIZE": "1",
"SEMAPHORE_AGENT_OS": "ubuntu-jammy"
}
9 changes: 9 additions & 0 deletions ci/linux-noble-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"SEMAPHORE_AGENT_STACK_NAME": "agent-aws-stack-linux-noble",
"SEMAPHORE_ORGANIZATION": "semaphore",
"SEMAPHORE_AGENT_TOKEN_PARAMETER_NAME": "s1-agent-aws-stack-linux-noble-token",
"SEMAPHORE_AGENT_USE_DYNAMIC_SCALING": "true",
"SEMAPHORE_AGENT_DISCONNECT_AFTER_JOB": "false",
"SEMAPHORE_AGENT_ASG_MAX_SIZE": "1",
"SEMAPHORE_AGENT_OS": "ubuntu-noble"
}
1 change: 1 addition & 0 deletions goss/goss.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ command:
docker-compose:
exit-status: 0
exec: "docker compose version"
timeout: 30000
python:
exit-status: 0
exec: "python --version"
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions goss/vars-jammy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
user: "semaphore"
awscli: "2.4.9"
python: "3.10.12"
3 changes: 3 additions & 0 deletions goss/vars-noble.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
user: "semaphore"
awscli: "2.4.9"
python: "3.12.3"
2 changes: 1 addition & 1 deletion lib/ami-hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const path = require("path");
const { execSync } = require('child_process');

function hash(os) {
packerOs = os == "ubuntu-focal" ? "linux" : os;
packerOs = os.startsWith("ubuntu-") ? "linux" : os;
hash = execSync(`find Makefile packer/${packerOs} -type f -exec md5sum "{}" + | awk '{print $1}' | sort | md5sum | awk '{print $1}'`, {
cwd: path.resolve(__dirname, '../')
});
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aws-semaphore-agent",
"version": "0.7.1",
"version": "0.8.0",
"bin": {
"aws-semaphore-agent": "bin/aws-semaphore-agent.js"
},
Expand Down
11 changes: 6 additions & 5 deletions packer/linux/ansible/roles/python/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
pkg:
- python3-pip

- name: Install botocore
ansible.builtin.pip:
name:
- boto3
- botocore
- name: Install botocore and boto3
ansible.builtin.apt:
pkg:
- python3-boto3
- python3-botocore
state: present
18 changes: 18 additions & 0 deletions packer/linux/ansible/ubuntu-jammy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
- name: Ubuntu Jammy 22.04
hosts: all
vars:
container_user: semaphore
become: true
become_user: root
roles:
- upgrade
- system_tools
- python
- erlang
- awscli
- cloudwatch_agent
- docker
- users
- agent
- cleanup
18 changes: 18 additions & 0 deletions packer/linux/ansible/ubuntu-noble.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
- name: Ubuntu Noble 24.04
hosts: all
vars:
container_user: semaphore
become: true
become_user: root
roles:
- upgrade
- system_tools
- python
- erlang
- awscli
- cloudwatch_agent
- docker
- users
- agent
- cleanup
Loading