Skip to content

Commit

Permalink
ci: add codecov workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
rst0git committed Jul 16, 2024
1 parent 0b95c36 commit 346f42f
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 15 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Codecov

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
name: Code coverage
steps:

- name: Checkout
uses: actions/checkout@v4
with:
# needed for codecov
fetch-depth: 0

- name: Build CRIU criu-dev
run: |
sudo apt-get install -y libprotobuf-dev libprotobuf-c-dev protobuf-c-compiler protobuf-compiler python3-protobuf libnl-3-dev libnet-dev libcap-dev curl unzip
git clone --depth=1 --single-branch -b criu-dev https://github.com/checkpoint-restore/criu.git
make -j"$(nproc)" -C criu
sudo make -C criu install-criu PREFIX=/usr
- name: Install Go 1.22.x
uses: actions/setup-go@v5
with:
go-version: 1.22.x

- name: Install protoc-gen-go
run: sudo env "GOBIN=/usr/bin" go install google.golang.org/protobuf/cmd/protoc-gen-go@latest

- name: Run tests and collect coverage
run: |
sudo -E make test
sudo -E make -C scripts/magic-gen test
# First update protobuf. It is too old in the Ubuntu image.
curl -Lo protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v23.4/protoc-23.4-linux-x86_64.zip
sudo unzip -o protoc.zip -d /usr
# We need to use the protobuf definitions from the criu-dev
# branch as it might have changed.
sudo -E make -C scripts/proto-gen proto-update GIT_BRANCH=criu-dev
sudo -E make -C scripts/proto-gen
sudo -E make -C crit clean bin/crit
sudo -E make -C crit unit-test
sudo -E make -C test crit-test
# Run actual test as root as it uses CRIU.
sudo -E make coverage
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
file: test/.coverage/coverage.out
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
8 changes: 0 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,3 @@ jobs:
fi
sudo -E make -C crit unit-test
sudo -E make -C test crit-test
- name: Check code coverage
if: ${{ matrix.go-version == '1.22.x' && matrix.criu_branch == 'criu-dev' && github.repository == 'checkpoint-restore/go-criu' }}
run: |
# Run actual test as root as it uses CRIU.
sudo -E make coverage
# Upload coverage results to codecov
sudo -E make codecov
9 changes: 2 additions & 7 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,11 @@ coverage: $(COVERAGE_BINARIES) $(TEST_PAYLOAD)
# We do not want to upload coverage for autogenerated files (*.pb.go)
sed -i '/\.pb\.go/d' ${COVERAGE_PATH}/coverage.out

codecov:
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
./codecov --nonZero -f "$(COVERAGE_PATH)/coverage.out"

clean:
@rm -f $(TEST_BINARIES) $(COVERAGE_BINARIES) codecov
@rm -f $(TEST_BINARIES) $(COVERAGE_BINARIES)
@rm -rf image $(COVERAGE_PATH)
@make -C crit/ clean
@make -C loop/ clean
@make -C mmapper/ clean

.PHONY: all clean coverage codecov crit-test phaul-test
.PHONY: all clean coverage crit-test phaul-test

0 comments on commit 346f42f

Please sign in to comment.