mirror of
https://github.com/replicatedhq/troubleshoot.git
synced 2026-02-14 18:29:53 +00:00
0 = all passed, 3 = at least one failure, 4 = no failures but at least 1 warn 1 as a catch all (generic errors), 2 for invalid input/specs etc ref https://github.com/replicatedhq/troubleshoot/issues/1131 docs https://github.com/replicatedhq/troubleshoot.sh/pull/489
321 lines
8.4 KiB
YAML
321 lines
8.4 KiB
YAML
on:
|
|
pull_request:
|
|
types:
|
|
- opened
|
|
- reopened
|
|
- synchronize
|
|
- ready_for_review
|
|
branches:
|
|
- main
|
|
push:
|
|
branches:
|
|
- "main"
|
|
tags:
|
|
- "v*.*.*"
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
fail_if_pull_request_is_draft:
|
|
if: github.event.pull_request.draft == true
|
|
runs-on: ubuntu-20.04
|
|
steps:
|
|
- name: Fails in order to indicate that pull request needs to be marked as ready to review and unit tests workflow needs to pass.
|
|
run: exit 1
|
|
|
|
test:
|
|
runs-on: ubuntu-20.04
|
|
steps:
|
|
- uses: actions/setup-go@v4
|
|
with:
|
|
go-version: "1.19"
|
|
|
|
- name: setup env
|
|
run: |
|
|
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
|
|
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
|
|
shell: bash
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- run: make test
|
|
|
|
test-integration:
|
|
runs-on: ubuntu-20.04
|
|
steps:
|
|
- uses: actions/setup-go@v4
|
|
with:
|
|
go-version: "1.19"
|
|
|
|
- name: setup env
|
|
run: |
|
|
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
|
|
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
|
|
shell: bash
|
|
|
|
- uses: actions/checkout@v3
|
|
- uses: replicatedhq/action-k3s@main
|
|
id: k3s
|
|
with:
|
|
version: v1.23.6-k3s1
|
|
|
|
- run: make test-integration
|
|
|
|
ensure-schemas-are-generated:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/setup-go@v4
|
|
with:
|
|
go-version: "1.19"
|
|
- name: setup env
|
|
run: |
|
|
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
|
|
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
|
|
shell: bash
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
- run: make check-schemas
|
|
|
|
compile-preflight:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/setup-go@v4
|
|
with:
|
|
go-version: "1.19"
|
|
- name: setup env
|
|
run: |
|
|
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
|
|
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
|
|
shell: bash
|
|
- uses: actions/checkout@v3
|
|
- run: make generate preflight
|
|
- uses: actions/upload-artifact@v3
|
|
with:
|
|
name: preflight
|
|
path: bin/preflight
|
|
|
|
validate-preflight:
|
|
runs-on: ubuntu-latest
|
|
needs: compile-preflight
|
|
steps:
|
|
- uses: replicatedhq/action-k3s@main
|
|
id: k3s
|
|
with:
|
|
version: v1.23.6-k3s1
|
|
- name: Download preflight binary
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: preflight
|
|
path: bin/
|
|
- run: chmod +x bin/preflight
|
|
- run: |
|
|
set +e
|
|
./bin/preflight --interactive=false --format=json https://preflight.replicated.com > result.json
|
|
EXIT_CODE=$?
|
|
cat result.json
|
|
|
|
EXIT_STATUS=0
|
|
if [ $EXIT_CODE -ne 3 ]; then
|
|
echo "Expected exit code of 3 (some checks failed), got $EXIT_CODE"
|
|
EXIT_STATUS=1
|
|
fi
|
|
|
|
if grep -q "was not collected" result.json; then
|
|
echo "Some files were not collected"
|
|
EXIT_STATUS=1
|
|
fi
|
|
|
|
if (( `jq '.pass | length' result.json` < 1 )); then
|
|
echo "No passing preflights found"
|
|
EXIT_STATUS=1
|
|
fi
|
|
|
|
if (( `jq '.warn | length' result.json` < 1 )); then
|
|
echo "No warnings found"
|
|
EXIT_STATUS=1
|
|
fi
|
|
|
|
if (( `jq '.fail | length' result.json` < 1 )); then
|
|
echo "No failed preflights found"
|
|
EXIT_STATUS=1
|
|
fi
|
|
|
|
exit $EXIT_STATUS
|
|
|
|
validate-preflight-e2e:
|
|
runs-on: ubuntu-latest
|
|
needs: compile-preflight
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: replicatedhq/action-k3s@main
|
|
id: k3s
|
|
with:
|
|
version: v1.23.6-k3s1
|
|
- name: Download preflight binary
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: preflight
|
|
path: bin/
|
|
- run: chmod +x bin/preflight
|
|
- run: make preflight-e2e-test
|
|
|
|
compile-supportbundle:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/setup-go@v4
|
|
with:
|
|
go-version: "1.19"
|
|
- name: setup env
|
|
run: |
|
|
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
|
|
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
|
|
shell: bash
|
|
- uses: actions/checkout@v3
|
|
- run: make generate support-bundle
|
|
- uses: actions/upload-artifact@v3
|
|
with:
|
|
name: support-bundle
|
|
path: bin/support-bundle
|
|
|
|
validate-supportbundle:
|
|
runs-on: ubuntu-latest
|
|
needs: compile-supportbundle
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: replicatedhq/action-k3s@main
|
|
id: k3s
|
|
with:
|
|
version: v1.23.6-k3s1
|
|
- name: Download support-bundle binary
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: support-bundle
|
|
path: bin/
|
|
- run: chmod +x bin/support-bundle
|
|
- run: ./bin/support-bundle ./examples/support-bundle/sample-collectors.yaml
|
|
- run: ./bin/support-bundle ./examples/support-bundle/sample-supportbundle.yaml
|
|
- run: ./bin/support-bundle https://kots.io
|
|
|
|
validate-supportbundle-e2e:
|
|
runs-on: ubuntu-latest
|
|
needs: compile-supportbundle
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: replicatedhq/action-k3s@main
|
|
id: k3s
|
|
with:
|
|
version: v1.23.6-k3s1
|
|
- name: Download support bundle binary
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: support-bundle
|
|
path: bin/
|
|
- run: chmod +x bin/support-bundle
|
|
- run: make support-bundle-e2e-test
|
|
|
|
compile-collect:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/setup-go@v4
|
|
with:
|
|
go-version: "1.19"
|
|
- name: setup env
|
|
run: |
|
|
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
|
|
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
|
|
shell: bash
|
|
- uses: actions/checkout@v3
|
|
- run: make generate collect
|
|
- uses: actions/upload-artifact@v3
|
|
with:
|
|
name: collect
|
|
path: bin/collect
|
|
|
|
goreleaser-test:
|
|
runs-on: ubuntu-latest
|
|
if: startsWith(github.ref, 'refs/tags/v') != true
|
|
strategy:
|
|
matrix:
|
|
goarch: [amd64, arm64]
|
|
goos: [darwin, linux, windows]
|
|
include:
|
|
- goarch: arm
|
|
goos: linux
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- uses: actions/setup-go@v4
|
|
with:
|
|
go-version: "1.19"
|
|
|
|
- name: Run GoReleaser
|
|
uses: goreleaser/goreleaser-action@v4
|
|
with:
|
|
version: "v0.183.0"
|
|
args: build --rm-dist --snapshot --config deploy/.goreleaser.yaml --single-target
|
|
env:
|
|
GOARCH: ${{ matrix.goarch }}
|
|
GOOS: ${{ matrix.goos }}
|
|
|
|
goreleaser:
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- validate-preflight
|
|
- validate-preflight-e2e
|
|
- validate-supportbundle
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- uses: azure/docker-login@v1
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USER }}
|
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
|
|
|
- uses: actions/setup-go@v4
|
|
with:
|
|
go-version: "1.19"
|
|
|
|
- uses: sigstore/cosign-installer@main
|
|
with:
|
|
cosign-release: "v1.2.1"
|
|
|
|
- name: Get Cosign Key
|
|
run: |
|
|
echo $COSIGN_KEY | base64 -d > ./cosign.key
|
|
env:
|
|
COSIGN_KEY: ${{secrets.COSIGN_KEY}}
|
|
|
|
- name: Generate SBOM
|
|
run: |
|
|
make sbom
|
|
env:
|
|
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
|
|
COSIGN_KEY: ${{ secrets.COSIGN_KEY }}
|
|
|
|
- name: Run GoReleaser
|
|
uses: goreleaser/goreleaser-action@v4
|
|
with:
|
|
version: "v0.183.0"
|
|
args: release --rm-dist --config deploy/.goreleaser.yaml
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Update new preflight version in krew-index
|
|
uses: rajatjindal/krew-release-bot@v0.0.46
|
|
with:
|
|
krew_template_file: deploy/krew/preflight.yaml
|
|
- name: Update new support-bundle version in krew-index
|
|
uses: rajatjindal/krew-release-bot@v0.0.46
|
|
with:
|
|
krew_template_file: deploy/krew/support-bundle.yaml
|