fleet/.github/workflows/fleetctl-preview-latest.yml
Roberto Dip 2397d744a2
fix conditional clauses to run workflows (#7580)
In https://github.com/fleetdm/fleet/pull/7399 we accidentally:

1. added a condition to `.github/workflows/fleet-and-orbit.yml`  that always evaluates to `false` making this workflow always fail
2. modified the condition of `.github/workflows/fleetctl-preview-latest.yml` 

This reverts those changes.
2022-09-06 10:20:45 -03:00

96 lines
3.2 KiB
YAML

name: Test latest changes in fleetctl preview
# Tests the `fleetctl preview` command with latest changes in fleetctl and
# docs/01-Using-Fleet/standard-query-library/standard-query-library.yml
on:
push:
branches:
- main
- patch-*
paths:
- 'cmd/fleetctl/**.go'
- 'pkg/**.go'
- 'server/service/**.go'
- 'server/context/**.go'
- 'orbit/**.go'
- 'ee/fleetctl/**.go'
- 'docs/01-Using-Fleet/standard-query-library/standard-query-library.yml'
pull_request:
paths:
- 'cmd/fleetctl/**.go'
- 'pkg/**.go'
- 'server/service/**.go'
- 'server/context/**.go'
- 'orbit/**.go'
- 'ee/fleetctl/**.go'
- 'docs/01-Using-Fleet/standard-query-library/standard-query-library.yml'
workflow_dispatch: # Manual
permissions:
contents: read
jobs:
test-preview:
timeout-minutes: 60
strategy:
matrix:
# Doesn't work on Windows because Linux Docker containers are not supported.
os: [ubuntu-latest, macos-latest]
go-version: ['1.17.9']
runs-on: ${{ matrix.os }}
steps:
# 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
- name: Install Docker
timeout-minutes: 20
if: contains(matrix.os, 'macos')
run: |
curl -L https://raw.githubusercontent.com/Homebrew/homebrew-cask/c65030146a5cf2070c2499b6c68e2c3495c99731/Casks/docker.rb > docker.rb
brew install --cask docker.rb
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..."
while ! /Applications/Docker.app/Contents/Resources/bin/docker info &>/dev/null; do
sleep 1;
done
echo "Docker is ready."
- name: Install Go
uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout Code
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v2
- name: Build Fleetctl
run: make fleetctl
- name: Run fleetctl preview
shell: bash
run: |
./build/fleetctl preview --std-query-lib-file-path $(pwd)/docs/01-Using-Fleet/standard-query-library/standard-query-library.yml
sleep 10
./build/fleetctl get hosts | tee hosts.txt
[ $( cat hosts.txt | grep online | wc -l) -eq 8 ]
- name: Get fleet logs
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()
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v2
with:
name: ${{ matrix.os }}-log
path: |
fleet-logs.txt
orbit.log
osquery_result_status_logs