2022-01-01 17:24:52 +00:00
|
|
|
name: Test fleetctl preview
|
|
|
|
|
2022-05-02 11:42:20 +00:00
|
|
|
# Tests the `fleetctl preview` command with latest npm released version of fleetctl.
|
|
|
|
|
2022-01-01 17:24:52 +00:00
|
|
|
on:
|
|
|
|
workflow_dispatch: # Manual
|
|
|
|
schedule:
|
|
|
|
- cron: '0 2 * * *' # Nightly 2AM UTC
|
|
|
|
|
2022-03-25 18:19:42 +00:00
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
|
2022-01-01 17:24:52 +00:00
|
|
|
jobs:
|
|
|
|
test-preview:
|
|
|
|
timeout-minutes: 60
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
# Doesn't work on Windows because Linux Docker containers are not supported.
|
2022-09-13 13:48:21 +00:00
|
|
|
os: [ubuntu-20.04, ubuntu-22.04, macos-11, macos-12]
|
2022-01-01 17:24:52 +00:00
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
steps:
|
2022-08-25 21:26:02 +00:00
|
|
|
|
|
|
|
# Docker needs to be installed manually on macOS.
|
|
|
|
# From https://github.com/docker/for-mac/issues/2359#issuecomment-943131345
|
|
|
|
# FIXME: lock Docker version to 4.10.0 as newer versions fail to initialize
|
2022-01-01 17:24:52 +00:00
|
|
|
- name: Install Docker
|
2022-08-29 15:50:16 +00:00
|
|
|
timeout-minutes: 20
|
2022-01-01 17:24:52 +00:00
|
|
|
if: contains(matrix.os, 'macos')
|
|
|
|
run: |
|
2022-08-25 21:26:02 +00:00
|
|
|
curl -L https://raw.githubusercontent.com/Homebrew/homebrew-cask/c65030146a5cf2070c2499b6c68e2c3495c99731/Casks/docker.rb > docker.rb
|
|
|
|
brew install --cask docker.rb
|
2022-01-01 17:24:52 +00:00
|
|
|
sudo /Applications/Docker.app/Contents/MacOS/Docker --unattended --install-privileged-components
|
|
|
|
open -a /Applications/Docker.app --args --unattended --accept-license
|
|
|
|
echo "Waiting for Docker to start up..."
|
2022-08-25 21:26:02 +00:00
|
|
|
while ! /Applications/Docker.app/Contents/Resources/bin/docker info &>/dev/null; do
|
|
|
|
sleep 1;
|
|
|
|
done
|
2022-01-01 17:24:52 +00:00
|
|
|
echo "Docker is ready."
|
|
|
|
|
|
|
|
- name: Start tunnel
|
|
|
|
run: |
|
|
|
|
npm install -g localtunnel
|
|
|
|
lt --port 1337 &
|
|
|
|
sleep 5
|
|
|
|
|
|
|
|
- name: Test fleetctl preview
|
|
|
|
run: |
|
|
|
|
npm install -g fleetctl
|
|
|
|
fleetctl preview
|
|
|
|
sleep 10
|
|
|
|
fleetctl get hosts | tee hosts.txt
|
|
|
|
[ $( cat hosts.txt | grep online | wc -l) -eq 8 ]
|
|
|
|
shell: bash
|
2022-05-02 11:42:20 +00:00
|
|
|
|
|
|
|
- name: Slack Notification
|
|
|
|
if: failure()
|
|
|
|
uses: slackapi/slack-github-action@16b6c78ee73689a627b65332b34e5d409c7299da # v1.18.0
|
|
|
|
with:
|
|
|
|
payload: |
|
|
|
|
{
|
|
|
|
"text": "${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head.html_url }}",
|
|
|
|
"blocks": [
|
|
|
|
{
|
|
|
|
"type": "section",
|
|
|
|
"text": {
|
|
|
|
"type": "mrkdwn",
|
|
|
|
"text": "Fleetctl preview test result: ${{ job.status }}\nhttps://github.com/fleetdm/fleet/actions/runs/${{ github.run_id }}\n${{ github.event.pull_request.html_url || github.event.head.html_url }}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
env:
|
|
|
|
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_G_PLATFORM_WEBHOOK_URL }}
|
|
|
|
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
|
2022-05-16 21:39:31 +00:00
|
|
|
|
|
|
|
- name: Get fleet logs
|
2022-07-11 11:12:33 +00:00
|
|
|
if: always()
|
2022-05-16 21:39:31 +00:00
|
|
|
run: |
|
|
|
|
FLEET_LICENSE_KEY=foo docker compose -f ~/.fleet/preview/docker-compose.yml logs fleet01 fleet02 > fleet-logs.txt
|
|
|
|
# Copying logs, otherwise the upload-artifact action uploads the logs in a hidden folder (.fleet)
|
|
|
|
cp ~/.fleet/preview/orbit.log orbit.log
|
|
|
|
cp -r ~/.fleet/preview/logs osquery_result_status_logs
|
|
|
|
shell: bash
|
|
|
|
|
|
|
|
- name: Upload logs
|
|
|
|
if: always()
|
2022-06-22 19:07:08 +00:00
|
|
|
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v2
|
2022-05-16 21:39:31 +00:00
|
|
|
with:
|
|
|
|
name: ${{ matrix.os }}-log
|
|
|
|
path: |
|
|
|
|
fleet-logs.txt
|
|
|
|
orbit.log
|
2022-08-25 21:26:02 +00:00
|
|
|
osquery_result_status_logs
|