Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR-5793 - Rework tests #161

Merged
merged 17 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Split short/long tests
  • Loading branch information
upils committed Nov 28, 2023
commit 7a8d709c95539f1edc2a0a274685c9d21af4ef8a
Empty file added .coverage/.gitkeep
Empty file.
52 changes: 47 additions & 5 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,64 @@ name: Build and Tests

on: [push, pull_request]

concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
build:
test:
runs-on: ubuntu-22.04
strategy:
matrix:
test-scenario: [short, long]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- name: install-go
run: sudo snap install go --classic

- name: build
run: go build ./...

- name: apt-update
run: sudo apt update

- name: install-test-dependencies
run: sudo apt install -y snapd germinate mtools debootstrap eatmydata fdisk gdisk qemu-system-aarch64 qemu-user-static ubuntu-dev-tools
- name: test
run: sudo go test -timeout 0 -v -race -coverprofile=coverage.out -covermode=atomic ./...
- name: Upload coverage to Codecov
run: bash <(curl -s https://codecov.io/bash)

- name: short tests
if: ${{ matrix.test-scenario == 'short' }}
run: sudo go test -timeout 0 -v -test.short -coverprofile=.coverage/coverage-short.out -covermode=atomic ./...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this work? Since I see some conditionals for when testing.Short() is on. But does this mean that the long tests execute all the long AND short tests? Or is there a way to just get the long ones run?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the "long tests" are also executing the short ones. Unfortunately there is no practical way to exclude short ones. But since short ones takes less than 10s this is negligible comparing to the long ones. Moreover, since I upload the coverage in both cases, this is nice that long tests also cover the short ones so the final coverage is the complete one (and not only the coverage of long tests).


- name: long tests
if: ${{ matrix.test-scenario == 'long' }}
run: sudo go test -timeout 0 -v -coverprofile=.coverage/coverage-long.out -covermode=atomic ./...

- name: Upload the coverage results
uses: actions/upload-artifact@v3
with:
name: coverage-files
path: ".coverage/coverage*.out"

code-coverage:
needs: [test]
runs-on: ubuntu-22.04
steps:
- name: Download the coverage files
uses: actions/download-artifact@v3
with:
name: coverage-files
path: .coverage/

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
# uploading to codecov occasionally fails, so continue running the test
# workflow regardless of the upload
continue-on-error: true
with:
fail_ci_if_error: true
flags: unittests
name: codecov-umbrella
files: .coverage/coverage-*.out
verbose: true