Skip to content

Commit

Permalink
remove redundant tests (#1677)
Browse files Browse the repository at this point in the history
* remove redundant tests

* fix workflow syntax error

* fix workflow syntax error

* fix k3s version for tests

* fix k3s version for tests

* f

* add vet to test-integration

---------

Co-authored-by: Dexter Yan <[email protected]>
  • Loading branch information
xavpaice and DexterYan authored Nov 8, 2024
1 parent 40eef3c commit 2f62240
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 123 deletions.
121 changes: 12 additions & 109 deletions .github/workflows/build-test-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,6 @@ jobs:
- 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-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: "1.22"
- name: setup env
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
shell: bash
- name: Run linters
run: make install-golangci-lint lint
- name: Run tests
run: make test

test-integration:
runs-on: ubuntu-latest
steps:
Expand All @@ -63,8 +44,8 @@ jobs:
- uses: replicatedhq/action-k3s@main
id: k3s
with:
version: v1.24.1-k3s1

version: v1.31.2-k3s1
# test-integration includes unit tests
- run: make test-integration

ensure-schemas-are-generated:
Expand Down Expand Up @@ -104,54 +85,6 @@ jobs:
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@v4
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
Expand All @@ -160,7 +93,7 @@ jobs:
- uses: replicatedhq/action-k3s@main
id: k3s
with:
version: v1.23.6-k3s1
version: v1.31.2-k3s1
- name: Download preflight binary
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -193,25 +126,6 @@ jobs:
name: support-bundle
path: bin/support-bundle

validate-supportbundle:
runs-on: ubuntu-latest
needs: compile-supportbundle
steps:
- uses: actions/checkout@v4
- uses: replicatedhq/action-k3s@main
id: k3s
with:
version: v1.23.6-k3s1
- name: Download support-bundle binary
uses: actions/download-artifact@v4
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
Expand All @@ -220,27 +134,20 @@ jobs:
- uses: replicatedhq/action-k3s@main
id: k3s
with:
version: v1.23.6-k3s1
version: v1.31.2-k3s1
- name: Download support bundle binary
uses: actions/download-artifact@v4
with:
name: support-bundle
path: bin/
- run: chmod +x bin/support-bundle
- run: make support-bundle-e2e-test

validate-supportbundle-e2e-go-test:
runs-on: ubuntu-latest
needs: compile-supportbundle
steps:
- uses: actions/setup-go@v5
with:
go-version: "1.22"
- name: setup env
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
shell: bash

# Additional e2e tests for support bundle that run in Go, these create a Kind cluster
validate-supportbundle-e2e-go:
runs-on: ubuntu-latest
needs: compile-supportbundle
steps:
- uses: actions/checkout@v4
- name: Download support bundle binary
uses: actions/download-artifact@v4
Expand Down Expand Up @@ -308,9 +215,8 @@ jobs:
goreleaser:
runs-on: ubuntu-latest
needs:
- validate-preflight
- validate-preflight-e2e
- validate-supportbundle
- validate-supportbundle-e2e
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout
Expand Down Expand Up @@ -367,15 +273,12 @@ jobs:
validate-pr-tests:
runs-on: ubuntu-latest
needs:
- test
- test-integration
- run-examples
- compile-collect
- validate-preflight
- validate-preflight-e2e
- validate-supportbundle
- validate-supportbundle-e2e
- validate-supportbundle-e2e-go-test
- validate-supportbundle-e2e-go
- ensure-schemas-are-generated
steps:
- run: echo "All PR tests passed"
Expand Down
16 changes: 2 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ test: generate fmt vet
# Go tests that require a K8s instance
# TODOLATER: merge with test, so we get unified coverage reports? it'll add 21~sec to the test job though...
.PHONY: test-integration
test-integration:
go test -v --tags "integration exclude_graphdriver_devicemapper exclude_graphdriver_btrfs" ${BUILDPATHS}
test-integration: generate fmt vet
go test -v --tags="integration exclude_graphdriver_devicemapper exclude_graphdriver_btrfs" ${BUILDPATHS}

.PHONY: preflight-e2e-test
preflight-e2e-test:
Expand Down Expand Up @@ -237,18 +237,6 @@ scan:
--ignore-unfixed \
./

.PHONY: lint
lint: vet
golangci-lint run --new -c .golangci.yaml --build-tags ${BUILDTAGS} ${BUILDPATHS}

.PHONY: lint-and-fix
lint-and-fix: fmt vet
golangci-lint run --new --fix -c .golangci.yaml --build-tags ${BUILDTAGS} ${BUILDPATHS}

.PHONY: install-golangci-lint
install-golangci-lint:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}

.PHONY: watch
watch: npm-install
bin/watch.js
Expand Down

0 comments on commit 2f62240

Please sign in to comment.