diff --git a/.github/workflows/dist-e2e.yml b/.github/workflows/dist-e2e.yml new file mode 100644 index 0000000..fc38db4 --- /dev/null +++ b/.github/workflows/dist-e2e.yml @@ -0,0 +1,76 @@ +on: + schedule: + - cron: '0 17 * * *' # every day at 5pm UTC + +jobs: + setup: + runs-on: ubuntu-latest + outputs: + all-dists: ${{ steps.get-all-dists.outputs.dists }} + steps: + - uses: actions/checkout@v3 + - id: get-all-dists + name: Get all distributions + run: | + cd dist + echo "dists=$(ls -ld */* | grep ^d | awk '{print $9}' | jq -cnMR '[inputs | select(length>0)]')" >> $GITHUB_OUTPUT + e2e: + # We use this runner because it is currently the only runner that supports nested virtualization. + # See https://github.com/actions/virtual-environments/issues/433 for more + # information + runs-on: macos-12 + timeout-minutes: 30 # If something hangs, timeout the job in 30 so we aren't billed for 6h * distributions * 10 (mac-os minute multiplier) + needs: + - setup + permissions: + id-token: write + contents: read + strategy: + fail-fast: false + matrix: + dist: ${{ fromJSON(needs.setup.outputs.all-dists) }} + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: arn:aws:iam::147803588724:role/github-action + aws-region: us-west-2 + + - name: Import e2e API TOKEN + run: | + e2e_api_token=$(aws secretsmanager get-secret-value --secret-id /prod/gh-actions/orchestrator-e2e-token --region us-west-2 | jq -r '.SecretString') + echo "::add-mask::${e2e_api_token}" + echo "TEST_API_TOKEN=${e2e_api_token}" >> $GITHUB_ENV + + - name: Cache Vagrant box + # Caches that are not accessed within the last week will be evicted + # If any or all of the vagrant files change a lot in a short period of time + # the cache may hit its 10GB limit at which point it will just start trimming + # cached items in order of oldest to newest. Worst case it will re-download a vagrant box + # (see https://github.com/actions/cache#cache-limits) + uses: actions/cache@v3 + with: + path: ~/.vagrant.d/boxes + key: ${{ runner.os }}-vagrant-${{ matrix.dist }}-${{ hashFiles('**/Vagrantfile') }} + + - name: Provision e2e environment + run: | + cd ./dist/${{ matrix.dist }} + vagrant box update + vagrant up --provision + + - name: Run e2e + env: + DIST: ${{ matrix.dist }} + run: | + cd ./dist/${{ matrix.dist }} + vagrant upload ../../e2e.sh + vagrant ssh -c "TEST_API_TOKEN=$TEST_API_TOKEN DIST=$DIST /bin/bash /home/vagrant/e2e.sh" + + - name: Destroy e2e environment + run: | + cd ./dist/${{ matrix.dist }} + vagrant destroy -f diff --git a/dist/amazon-linux/2/Vagrantfile b/dist/amazon-linux/2/Vagrantfile index d5e6790..c21c7f7 100644 --- a/dist/amazon-linux/2/Vagrantfile +++ b/dist/amazon-linux/2/Vagrantfile @@ -10,7 +10,7 @@ Vagrant.configure("2") do |config| # commercial use we need to sort out first. config.vm.provider "libvirt" do |vm| vm.memory = "8192" - vm.cpus = 8 + vm.cpus = 2 vm.memorybacking :access, :mode => "shared" end config.vm.synced_folder "../../../", "/vagrant" #, type: "virtiofs" diff --git a/dist/e2e.sh b/dist/e2e.sh new file mode 100755 index 0000000..703437e --- /dev/null +++ b/dist/e2e.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +# +# This script is primarily intended to be used with the Vagrant definitions in each dist folder +# A monitor should be setup in the account for which $TEST_API_TOKEN belongs to (testsignal is a good option) +# + +# Oddly enough even after yum remove or apt remove the orchestrator is still running. Clean that up +StopAndDisableOrchestrator() { + sudo systemctl stop metrist-orchestrator + sudo systemctl disable metrist-orchestrator + sudo systemctl daemon-reload +} + +RemoveOrchestrator(){ + StopAndDisableOrchestrator + + if type apt >/dev/null; then + sudo apt purge -y metrist-orchestrator + elif type yum >/dev/null; then + sudo yum remove -y metrist-orchestrator + fi +} + +Main() { + +# Sanitize DIST env var before using it for instance id - remove forward slashes, hyphens, and periods +DIST=${DIST//[\/\.\-]/} + +curl https://dist.metrist.io/install.sh >/tmp/install.sh + +cat <$latest - $SUDO yum localinstall ./$latest + $SUDO yum localinstall -y ./$latest cat </dev/null # Added by installation script. diff --git a/dist/ubuntu/20.04/Vagrantfile b/dist/ubuntu/20.04/Vagrantfile index 76fcebd..2dd7e98 100644 --- a/dist/ubuntu/20.04/Vagrantfile +++ b/dist/ubuntu/20.04/Vagrantfile @@ -10,7 +10,7 @@ Vagrant.configure("2") do |config| # commercial use we need to sort out first. config.vm.provider "libvirt" do |vm| vm.memory = "8192" - vm.cpus = 8 + vm.cpus = 2 vm.memorybacking :access, :mode => "shared" end config.vm.synced_folder "../../../", "/vagrant" #, type: "virtiofs" diff --git a/dist/ubuntu/22.04/Vagrantfile b/dist/ubuntu/22.04/Vagrantfile index d1d07ed..33dc78f 100644 --- a/dist/ubuntu/22.04/Vagrantfile +++ b/dist/ubuntu/22.04/Vagrantfile @@ -10,7 +10,7 @@ Vagrant.configure("2") do |config| # commercial use we need to sort out first. config.vm.provider "libvirt" do |vm| vm.memory = "8192" - vm.cpus = 8 + vm.cpus = 2 vm.memorybacking :access, :mode => "shared" end config.vm.synced_folder "../../../", "/vagrant" #, type: "virtiofs"