pygmy #2053
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: pygmy | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
pull_request: | |
branches: | |
- main | |
release: | |
types: | |
- created | |
schedule: | |
- cron: "0 0 * * *" | |
jobs: | |
basic: | |
runs-on: ubuntu-22.04 | |
env: | |
GO111MODULE: on | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: '1.21' | |
- name: Install | |
run: go mod download | |
env: | |
GO111MODULE: on | |
- name: Diff | |
run: diff -u <(echo -n) <(gofmt -d $(find . -not -path "./vendor/*" -name "*.go")); | |
- name: Vet | |
run: go vet $(go list ./...); | |
- name: Lint | |
run: docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.61.0 golangci-lint run -v --timeout 3m | |
- name: Build | |
run: make build | |
- name: Test | |
run: go test -v ./... | |
# windows: | |
# runs-on: windows-2019 | |
# steps: | |
# - uses: actions/checkout@v3 | |
# - uses: actions/setup-go@v4 | |
# with: | |
# stable: 'false' | |
# go-version: '1.16' | |
# - name: Switch Docker daemon mode to Linux | |
# run: Start-Process $Env:ProgramFiles\Docker\Docker\DockerCli.exe -ArgumentList "-SwitchLinuxEngine" | |
# - name: Build | |
# run: docker build -t pygmy. | |
# - name: Run status command | |
# run: builds/${PYGMY_PATH} --config examples/pygmy.basic.yml status; | |
# - name: Run version command | |
# run: builds/${PYGMY_PATH} --config examples/pygmy.basic.yml version; | |
full: | |
runs-on: ubuntu-22.04 | |
env: | |
GO111MODULE: on | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
stable: 'false' | |
go-version: '1.21' | |
# Establish some SSH keys. | |
- name: Setup SSH | |
run: | | |
eval $(ssh-agent); | |
ssh-keygen -t rsa -q -f "$HOME/.ssh/id_rsa" -N ""; | |
ssh-keygen -t ed25519 -q -f "$HOME/.ssh/id_pwd" -N "passphrase"; | |
ssh-add; | |
ssh-add -l; | |
- name: Setup git | |
run: git config --global url."https://github.com/".insteadOf "[email protected]:"; | |
- name: Install | |
run: go mod download | |
env: | |
GO111MODULE: on | |
- name: Install Lando | |
run: | | |
wget https://files.devwithlando.io/lando-stable.deb; | |
sudo dpkg -i --ignore-depends=docker-ce lando-stable.deb; | |
- name: Install expect and dockerize via brew | |
run: | | |
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"; | |
brew install expect; | |
brew install dockerize; | |
echo "/home/linuxbrew/.linuxbrew/bin" >> $GITHUB_PATH; | |
- name: Compile | |
run: | | |
go build -o pygmy-linux-amd64; | |
./pygmy-linux-amd64 version; | |
- name: Switch pygmy configs from vanilla to basic | |
run: | | |
./pygmy-linux-amd64 status; | |
./pygmy-linux-amd64 clean; | |
./pygmy-linux-amd64 --config examples/pygmy.basic.yml pull; | |
./pygmy-linux-amd64 --config examples/pygmy.basic.yml up; | |
sleep 10; | |
./pygmy-linux-amd64 --config examples/pygmy.basic.yml status; | |
- name: Show pygmy image versions | |
run: | | |
docker ps -a --filter "label=pygmy.name" | |
- name: Export configuration | |
run: | | |
./pygmy-linux-amd64 --config examples/pygmy.basic.yml export -o ./exported-config.yml | |
cat ./exported-config.yml | |
- name: Resolv file test | |
run: | | |
stat /usr/lib/systemd/resolved.conf.d/docker.amazee.io.conf; | |
grep "127.0.0.1" /usr/lib/systemd/resolved.conf.d/docker.amazee.io.conf; | |
grep "docker.amazee.io" /usr/lib/systemd/resolved.conf.d/docker.amazee.io.conf; | |
- name: Test JSON output | |
run: | | |
./pygmy-linux-amd64 --config examples/pygmy.basic.yml status --json > pygmy.json | |
cat pygmy.json | jq '.service_status["amazeeio-dnsmasq"].running' | grep 'true' | |
cat pygmy.json | jq '.service_status["amazeeio-dnsmasq"].image' | grep 'pygmystack/dnsmasq' | |
cat pygmy.json | jq '.service_status["amazeeio-haproxy"].running' | grep 'true' | |
cat pygmy.json | jq '.service_status["amazeeio-haproxy"].image' | grep 'ygmystack/haproxy' | |
cat pygmy.json | jq '.service_status["amazeeio-mailhog"].running' | grep 'true' | |
cat pygmy.json | jq '.service_status["amazeeio-mailhog"].image' | grep 'pygmystack/mailhog' | |
cat pygmy.json | jq '.service_status["amazeeio-ssh-agent"].running' | grep 'true' | |
cat pygmy.json | jq '.service_status["amazeeio-ssh-agent"].image' | grep 'pygmystack/ssh-agent' | |
- name: haproxy test | |
run: | | |
curl http://docker.amazee.io/stats | grep 'class=px' | grep 'mailhog.docker.amazee.io'; | |
curl http://docker.amazee.io/stats | grep 'HAProxy version'; | |
- name: dnsmasq version | |
run: | | |
docker exec amazeeio-dnsmasq sh -c 'dnsmasq -v' | grep 'Dnsmasq version' | |
- name: ssh version | |
run: | | |
docker exec amazeeio-ssh-agent sh -c 'ssh -V' | |
- name: Test the amazeeio-network for expected results | |
run: | | |
docker network inspect amazeeio-network | jq '.[].Name' | grep "amazeeio-network"; | |
docker network inspect amazeeio-network | jq '.[].Containers' | jq '.[].Name' | grep "amazeeio-haproxy"; | |
docker network inspect amazeeio-network | jq '.[].Containers' | jq '.[].Name' | grep "amazeeio-mailhog"; | |
docker network inspect amazeeio-network | jq '.[].Containers' | jq '.[].IPv4Address'; | |
docker network inspect amazeeio-network | jq '.[].Containers' | jq '.[].IPv4Address' | grep "10.99.99."; | |
- name: Test for configured container tags. | |
run: | | |
docker inspect amazeeio-dnsmasq | jq '.[].Config.Labels["pygmy.hocuspocus"]' | grep "42"; | |
docker inspect amazeeio-dnsmasq | jq '.[].Config.Labels["pygmy.abracadabra"]' | grep "1"; | |
docker inspect amazeeio-dnsmasq | jq '.[].Config.Labels["pygmy.opensesame"]' | grep "correct"; | |
docker inspect amazeeio-haproxy | jq '.[].Config.Labels["pygmy.hocuspocus"]' | grep "42"; | |
docker inspect amazeeio-haproxy | jq '.[].Config.Labels["pygmy.abracadabra"]' | grep "1"; | |
docker inspect amazeeio-haproxy | jq '.[].Config.Labels["pygmy.opensesame"]' | grep "correct"; | |
docker inspect amazeeio-ssh-agent | jq '.[].Config.Labels["pygmy.hocuspocus"]' | grep "42"; | |
docker inspect amazeeio-ssh-agent | jq '.[].Config.Labels["pygmy.abracadabra"]' | grep "1"; | |
docker inspect amazeeio-ssh-agent | jq '.[].Config.Labels["pygmy.opensesame"]' | grep "correct"; | |
docker inspect amazeeio-mailhog | jq '.[].Config.Labels["pygmy.hocuspocus"]' | grep "42"; | |
docker inspect amazeeio-mailhog | jq '.[].Config.Labels["pygmy.abracadabra"]' | grep "1"; | |
docker inspect amazeeio-mailhog | jq '.[].Config.Labels["pygmy.opensesame"]' | grep "correct"; | |
- name: Switch pygmy configs from basic to overrides | |
run: | | |
./pygmy-linux-amd64 --config examples/pygmy.basic.yml status; | |
./pygmy-linux-amd64 --config examples/pygmy.basic.yml clean; | |
./pygmy-linux-amd64 --config examples/pygmy.overrides.yml pull; | |
./pygmy-linux-amd64 --config examples/pygmy.overrides.yml up; | |
sleep 10; | |
./pygmy-linux-amd64 --config examples/pygmy.overrides.yml status; | |
- name: Test the container image overrides configuration | |
run: | | |
echo "Checking image references in started containers..."; | |
docker container inspect amazeeio-dnsmasq | jq '.[].Config.Image' | grep "ghcr.io/pygmystack/dnsmasq:main"; | |
docker container inspect amazeeio-haproxy | jq '.[].Config.Image' | grep 'ghcr.io/pygmystack/haproxy:main'; | |
docker container inspect amazeeio-mailhog | jq '.[].Config.Image' | grep "ghcr.io/pygmystack/mailhog:main"; | |
docker container inspect amazeeio-ssh-agent | jq '.[].Config.Image' | grep "ghcr.io/pygmystack/ssh-agent:main"; | |
- name: Switch pygmy configs from overrides to vanilla | |
run: | | |
./pygmy-linux-amd64 --config examples/pygmy.overrides.yml status; | |
./pygmy-linux-amd64 --config examples/pygmy.overrides.yml clean; | |
./pygmy-linux-amd64 pull; | |
./pygmy-linux-amd64 up; | |
sleep 10; | |
./pygmy-linux-amd64 status; | |
- name: SSH Key test | |
id: ssh-key-test | |
run: | | |
./pygmy-linux-amd64 addkey /home/runner/.ssh/id_rsa; | |
sleep 10 | |
./pygmy-linux-amd64 status; | |
./pygmy-linux-amd64 status | grep 'RSA'; | |
docker run --rm -i --volumes-from amazeeio-ssh-agent ghcr.io/pygmystack/ssh-agent:latest /usr/bin/ssh-add -l | grep 'RSA'; | |
continue-on-error: true | |
# - name: SSH encrypted Key test | |
# id: ssh-enc-key-test | |
# run: | | |
# expect -f .github/workflows/expect.exp; | |
# sleep 10 | |
# ./pygmy-linux-amd64 status; | |
# ./pygmy-linux-amd64 status | grep 'ED25519'; | |
# docker run --rm -i --volumes-from amazeeio-ssh-agent ghcr.io/pygmystack/ssh-agent:latest /usr/bin/ssh-add -l | grep 'ED25519'; | |
# continue-on-error: true | |
# - name: Check & dump on SSH failures | |
# if: steps.ssh-key-test.outcome != 'success' || steps.ssh-enc-key-test.outcome != 'success' | |
# run: | | |
# docker logs amazeeio-ssh-agent | |
# ./pygmy-linux-amd64 export -o ./exported-config-err.yml | |
# cat ./exported-config-err.yml | |
# exit 1 | |
- name: Clone the official examples | |
run: | | |
git clone --recurse-submodules https://github.com/uselagoon/lagoon-examples.git | |
- name: "[Example] Drupal OpenSearch" | |
run: | | |
cd lagoon-examples/drupal-opensearch; | |
docker compose -p drupal-opensearch up -d; | |
docker compose -p drupal-opensearch exec -T cli composer install; | |
dockerize -wait http://drupal-opensearch.docker.amazee.io:80 -timeout 10s; | |
curl -I http://drupal-opensearch.docker.amazee.io; | |
curl -I http://drupal-opensearch.docker.amazee.io | grep -i "x-lagoon"; | |
../../pygmy-linux-amd64 status | grep '\- http://drupal-opensearch.docker.amazee.io'; | |
docker compose -p drupal-base down; | |
docker compose -p drupal-base rm; | |
cd ../../; | |
- name: "[Example] Drupal Postgres" | |
run: | | |
cd lagoon-examples/drupal-postgres; | |
docker compose -p drupal-postgres up -d; | |
docker compose -p drupal-postgres exec -T cli composer install; | |
dockerize -wait http://drupal-postgres.docker.amazee.io:80 -timeout 10s; | |
curl -I http://drupal-postgres.docker.amazee.io; | |
curl -I http://drupal-postgres.docker.amazee.io | grep -i "x-lagoon"; | |
../../pygmy-linux-amd64 status | grep '\- http://drupal-postgres.docker.amazee.io'; | |
docker compose -p drupal-postgres down; | |
docker compose -p drupal-postgres rm; | |
cd ../../; | |
# - name: Node | |
# run: | | |
# cd lagoon-examples/node-example; | |
# npm install; | |
# docker compose -p node up -d; | |
# curl -I http://node.docker.amazee.io; | |
# curl -I http://node.docker.amazee.io | grep -i "x-lagoon"; | |
# ../../pygmy-linux-amd64 --config ../../examples/pygmy.basic.yml status | grep '\- http://node.docker.amazee.io'; | |
# docker compose -p node down; | |
# docker compose -p node rm; | |
# cd ../../; | |
- name: Lando test - running Pygmy along-side Lando | |
run: | | |
cd lagoon-examples/drupal-base; | |
lando start || true; | |
dockerize -wait http://drupal-base.lndo.site:8000 -timeout 10s; | |
curl -I http://drupal-base.lndo.site:8000; | |
curl -I http://drupal-base.lndo.site:8000 | grep -i "x-lagoon"; | |
lando destroy -y; | |
cd ../../; | |
- name: Test the stop command | |
run: | | |
./pygmy-linux-amd64 down | grep 'Successfully removed amazeeio'; | |
./pygmy-linux-amd64 status | grep '\[ \] amazeeio-' | grep 'is not running'; | |
./pygmy-linux-amd64 status | grep 'Running as container amazeeio-' && false || true; | |
./pygmy-linux-amd64 --config examples/pygmy.basic.yml up; | |
./pygmy-linux-amd64 --config examples/pygmy.basic.yml status | grep 'Running as container amazeeio-' && true || false; | |
- name: Test the down command | |
run: | | |
./pygmy-linux-amd64 --config examples/pygmy.basic.yml stop | grep 'Successfully stopped amazeeio'; | |
./pygmy-linux-amd64 --config examples/pygmy.basic.yml status | grep '\[ \] amazeeio-' | grep 'is not running'; | |
./pygmy-linux-amd64 --config examples/pygmy.basic.yml status | grep 'Running as container amazeeio-' && false || true; | |
./pygmy-linux-amd64 --config examples/pygmy.basic.yml up; | |
./pygmy-linux-amd64 --config examples/pygmy.basic.yml status | grep 'Running as container amazeeio-' && true || false; | |
- name: Cowsay test | |
run: ./pygmy-linux-amd64 --config examples/pygmy.basic.yml up | grep 'holy ship' || true; | |
- name: Cleanup pygmy | |
run: ./pygmy-linux-amd64 --config examples/pygmy.basic.yml clean; | |
- name: Cleanup after tests. | |
run: | | |
docker system prune --all --force | |
docker volume prune --force |