Skip to content

Commit

Permalink
🧹 split CLI tests into a separate job (#3203)
Browse files Browse the repository at this point in the history
* split CLI tests into a separate job

Signed-off-by: Ivan Milchev <[email protected]>

* fix Makefile

Signed-off-by: Ivan Milchev <[email protected]>

* make sure action runs when makefile changes

Signed-off-by: Ivan Milchev <[email protected]>

* make sure action runs when action changes

Signed-off-by: Ivan Milchev <[email protected]>

* do not execute providers tests twice

Signed-off-by: Ivan Milchev <[email protected]>

---------

Signed-off-by: Ivan Milchev <[email protected]>
  • Loading branch information
imilchev authored Feb 5, 2024
1 parent 64f89af commit cf84191
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/pr-test-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
- '**.go'
- '**.mod'
- 'go.sum'
- 'Makefile'
- '.github/workflows/pr-test-lint.yml'

jobs:
# Check if there is any dirty change for go mod tidy
Expand Down Expand Up @@ -91,6 +93,39 @@ jobs:
name: test-results
path: report.xml

go-test-cli:
runs-on: self-hosted
timeout-minutes: 120
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Import environment variables from file
run: cat ".github/env" >> $GITHUB_ENV

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ">=${{ env.golang-version }}"
cache: false

- name: 'Set up gcloud CLI'
uses: 'google-github-actions/setup-gcloud@v2'

- name: Set provider env
run: echo "PROVIDERS_PATH=${PWD}/.providers" >> $GITHUB_ENV
- name: Display Provider PAth
run: echo $PROVIDERS_PATH

- name: Test cnquery CLI
run: make test/go-cli/plain-ci

- uses: actions/upload-artifact@v4 # upload test results
if: success() || failure() # run this step even if previous step failed
with:
name: test-results-cli
path: report.xml

go-bench:
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/main'
Expand Down
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -600,10 +600,16 @@ benchmark/go:
test/go: cnquery/generate test/go/plain

test/go/plain:
go test -cover $(shell go list ./... | grep -v '/providers/')
go test -cover $(shell go list ./... | grep -v '/providers/' | grep -v '/test/cli')

test/go/plain-ci: prep/tools providers/build providers/test
gotestsum --junitfile report.xml --format pkgname -- -cover $(shell go list ./... | grep -v '/vendor/' | grep -v '/providers/')
test/go/plain-ci: prep/tools providers/build
gotestsum --junitfile report.xml --format pkgname -- -cover $(shell go list ./... | grep -v '/vendor/' | grep -v '/providers/' | grep -v '/test/cli')

test/go-cli/plain:
go test -cover $(shell go list ./... | grep 'test/cli')

test/go-cli/plain-ci: prep/tools providers/build
gotestsum --junitfile report.xml --format pkgname -- -cover $(shell go list ./... | grep 'test/cli')

.PHONY: test/lint/staticcheck
test/lint/staticcheck:
Expand Down

0 comments on commit cf84191

Please sign in to comment.