Skip to content

Commit

Permalink
Merge pull request #186 from mkalcok/revert-184-coverage
Browse files Browse the repository at this point in the history
Revert "Coverage"
  • Loading branch information
fnordahl authored Sep 30, 2024
2 parents 6c1c3cf + b90ab20 commit 37b59a4
Show file tree
Hide file tree
Showing 23 changed files with 19 additions and 269 deletions.
70 changes: 2 additions & 68 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ jobs:
- name: Lint
run: |
autoconf
./configure --disable-dep-check
make check-lint
build:
Expand Down Expand Up @@ -61,10 +59,7 @@ jobs:
--classic
- name: Build snap
run: |
autoconf
./configure --enable-coverage
make $MICROOVN_SNAP
run: make $MICROOVN_SNAP

- name: Upload artifacts
if: always()
Expand Down Expand Up @@ -136,66 +131,5 @@ jobs:
sudo lxd init --auto
snap list
- name: Configure repository
run: |
autoconf
./configure --enable-coverage --disable-dep-check
- name: Run system tests
run: SKIP_SNAP_REBUILD=yes make tests/${{ matrix.test-file }}

- name: Upload test coverage
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.test-file }}_coverage
path: ${{ github.workspace }}/.coverage
include-hidden-files: true
retention-days: 1

generate-coverage:
name: Generate coverage profile
needs:
- metadata
- system-tests
# 'ubuntu-latest' currently resolves to '22.04' [0] and since we require "Go >=1.20"
# for coverage tools, we need to use explicit 'ubuntu-24.04' image name.
# [0] https://github.com/actions/runner-images/issues/10636
runs-on: ubuntu-24.04
env:
COVERAGE_DIR: ${{ github.workspace }}/.coverage
COVERAGE_MERGED: ${{ github.workspace }}/.coverage/_merged
COVERAGE_MERGED_PROFILE: ${{ github.workspace }}/.coverage/_merged/profile.out
steps:
- name: Install dependencies
run: |
sudo apt install -yqq golang
go install github.com/boumenot/[email protected]
- name: Checkout code
uses: actions/checkout@v4

- name: Download test coverage data
uses: actions/download-artifact@v4
with:
path: ${{ env.COVERAGE_DIR }}
pattern: "*_coverage"

- name: Merge test coverage data
run: |
mkdir -p "$COVERAGE_MERGED"
coverage_inputs=$(find "$COVERAGE_DIR" -type d -name coverage | tr '\n' ',' | sed 's/,$//g')
go tool covdata merge -i="$coverage_inputs" -o="$COVERAGE_MERGED"
go tool covdata textfmt -i="$COVERAGE_MERGED" -o="$COVERAGE_MERGED_PROFILE"
- name: Generate cobertura.xml
run: |
cd microovn/
$HOME/go/bin/gocover-cobertura < "$COVERAGE_MERGED_PROFILE" > "$COVERAGE_DIR/cobertura.xml"
- name: Upload cobertura.xml
uses: actions/upload-artifact@v4
with:
name: cobertura.xml
path: ${{ env.COVERAGE_DIR }}/cobertura.xml
include-hidden-files: true

run: .bats/bats-core/bin/bats tests/${{ matrix.test-file }}
29 changes: 0 additions & 29 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,30 +1 @@
*.snap

# Files that are generated by configure script
Makefile
snap/snapcraft.yaml
snapcraft/commands/daemon.start
snapcraft/commands/microovn

# autoconf files
autom4te.cache
/autoscan.log
/autoscan-*.log
/aclocal.m4
/compile
/config.cache
/config.guess
/config.h.in
/config.log
/config.status
/config.sub
/configure
/configure~
/configure.scan
/depcomp
/install-sh
/missing
/stamp-h1

# Test coverage files
.coverage/
16 changes: 3 additions & 13 deletions Makefile.in → Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ MICROOVN_SOURCES := $(shell find microovn/ -type f)
COMMAND_WRAPPERS := $(shell find snapcraft/ -type f)
SNAP_SOURCES := $(shell find snap/ -type f)

export MICROOVN_COVERAGE_DST := $(CURDIR)/.coverage
export MICROOVN_COVERAGE_ENABLED := @GO_COVERAGE_ENABLED@

check: check-lint check-system

check-tabs:
Expand All @@ -30,18 +27,11 @@ $(ALL_TESTS): $(MICROOVN_SNAP)
check-system: $(ALL_TESTS)

$(MICROOVN_SNAP): $(MICROOVN_SOURCES) $(SNAP_SOURCES) $(COMMAND_WRAPPERS)
@if [ "$(SKIP_SNAP_REBUILD)" = "yes" ]; then \
echo "Skipping snap build"; \
else \
echo "Building the snap"; \
snapcraft pack -v -o $(MICROOVN_SNAP); \
fi
echo "Building the snap"; \
snapcraft pack -v -o $(MICROOVN_SNAP)

clean:
rm -f $(MICROOVN_SNAP_PATH); \
snapcraft clean

distclean: clean
git clean -fdX

.PHONY: $(ALL_TESTS) clean check-system check-lint check-tabs distclean
.PHONY: $(ALL_TESTS) clean check-system check-lint check-tabs
50 changes: 0 additions & 50 deletions configure.ac

This file was deleted.

3 changes: 0 additions & 3 deletions docs/.custom_wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ VMs
Virtualization
YY
appctl
autoconf
backport
bugfixes
codebase
Expand All @@ -38,7 +37,6 @@ installable
lifecycle
linter
linters
lxd
manpage
northd
ovs
Expand All @@ -48,7 +46,6 @@ reST
reStructuredText
readthedocs
schemas
snapcraft
submodules
systemd
unencrypted
Expand Down
25 changes: 6 additions & 19 deletions docs/developers/building.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,23 @@ want to test your changes locally.
Build requirements
------------------

MicroOVN is distributed as a snap and most of the build requirements are handled
by ``snapcraft`` automatically. However your build host will need:
MicroOVN is distributed as a snap and the only requirements for building it
are ``Make`` and ``snapcraft``. You can install them with:

* make
* autoconf
* snapcraft
* lxd
.. code-block:: none
Bootstrap the build environment
-------------------------------
sudo apt install make
sudo snap install snapcraft --classic
Snapcraft requires ``LXD`` to build snaps. So if your system does not have LXD
installed and initiated, you can check out either `LXD getting started
guides`_ or go with following default setup:

.. code-block:: none
sudo snap install lxd
lxd init --auto
Before you can build MicroOVN, you will need to configure the build with:

.. code-block:: none
autoconf
./configure
You can check available ``Optional Features`` in the output of
``./configure --help``, and reconfigure the build environment any time by
running ``./configure`` with the desired feature flags.

Build MicroOVN
--------------

Expand Down
13 changes: 0 additions & 13 deletions docs/developers/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,6 @@ is supported through the use of the ``LXC_REMOTE`` `LXD environment`_ variable.
To avoid interleaving output from these parallel test suites, you can
specify the ``-O`` argument as well.

Test coverage information
~~~~~~~~~~~~~~~~~~~~~~~~~

When MicroOVN build is configured with the code coverage support via
``./configure --enable-coverage`` (see more information about bootstrapping
and configuring build environment in :doc:`Build MicroOVN <building>` page),
all functional tests will automatically collect coverage information, when
executed via ``make``. You can find collected data in the ``.coverage/``
directory, where it's organised in a ``<test_name>/<container_name>/coverage``
structure. For more information about the coverage data format and what you can
do with it, see `Go Coverage Documentation`_.

Clean up
~~~~~~~~

Expand Down Expand Up @@ -167,4 +155,3 @@ Any leftover containers will be named according to:
.. _LXD remotes: https://documentation.ubuntu.com/lxd/en/latest/remotes/
.. _LXD environment: https://documentation.ubuntu.com/lxd/en/latest/environment/
.. _golangci-lint: https://golangci-lint.run/
.. _Go Coverage Documentation: https://go.dev/doc/build-cover#working
14 changes: 8 additions & 6 deletions snap/snapcraft.yaml.in → snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -279,25 +279,28 @@ parts:
ovs_pkg_version=$(
dpkg-deb -f \
$CRAFT_PART_SRC/../../ovs/stage_packages/openvswitch-switch*.deb Version)

git_version=$(
git -C $CRAFT_PROJECT_DIR describe \
--always \
--dirty \
--abbrev=10)
# Set Snap's version string
# Note (mkalcok): Short version string does not include potential package snapshot hash.
# This is required because Snap's version string is limited to 32 chars
# and inclusion of snapshot hash violates this boundary.
ovn_pkg_short_version=$(echo $ovn_pkg_version | sed -rne 's/([0-9.]+)[-+~].*$$/\1/p')
craftctl set version=${ovn_pkg_short_version}+snap@PACKAGE_VERSION@
craftctl set version=${ovn_pkg_short_version}+snap${git_version}
version_package=github.com/canonical/microovn/microovn/version
go_ldflags="-X '${version_package}.MicroOvnVersion=@PACKAGE_VERSION@' \
go_ldflags="-X '${version_package}.MicroOvnVersion=${git_version}' \
-X '${version_package}.OvnVersion=${ovn_pkg_version}' \
-X '${version_package}.OvsVersion=${ovs_pkg_version}'"
# Build the binaries
go build -o "${CRAFT_PART_INSTALL}/bin/microovn" \
@GO_COVERAGE_ARG@ \
-ldflags "$go_ldflags" \
./cmd/microovn
go build -o "${CRAFT_PART_INSTALL}/bin/microovnd" \
@GO_COVERAGE_ARG@ \
-ldflags "$go_ldflags" \
-tags=libsqlite3 \
./cmd/microovnd
Expand Down Expand Up @@ -340,7 +343,6 @@ parts:
usr/lib/: lib/
prime:
- commands/*
- -commands/*.in
- ./*.env
- bin/jq
- lib/*/libjq.so*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/bin/sh
@GO_COVERAGE_OUTPUT@

export DQLITE_SOCKET="@snap.${SNAP_INSTANCE_NAME}.dqlite"
export OVS_RUNDIR="${SNAP_COMMON}/run/switch/"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
#!/bin/sh
@GO_COVERAGE_OUTPUT@

exec microovn --state-dir "${SNAP_COMMON}/state" "$@"
3 changes: 0 additions & 3 deletions snapcraft/coverage_include

This file was deleted.

1 change: 0 additions & 1 deletion tests/scaleup_cluster.bats
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ setup() {
}

teardown() {
collect_coverage $TEST_CONTAINERS
delete_containers $TEST_CONTAINERS
}

Expand Down
1 change: 0 additions & 1 deletion tests/test_helper/bats/lifecycle.bats
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ setup_file() {
}

teardown_file() {
collect_coverage $TEST_CONTAINERS
delete_containers $TEST_CONTAINERS
}

Expand Down
Loading

0 comments on commit 37b59a4

Please sign in to comment.