actions: enable unit tests in PR check

Right now we only run UTs for agent. We need to run it for *ALL*
components.

Fixes: #1538
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
Peng Tao 2021-03-23 18:13:49 +08:00
parent 74192d179d
commit fc0f93aef9
3 changed files with 18 additions and 21 deletions

View File

@ -8,13 +8,11 @@ jobs:
os: [ubuntu-20.04] os: [ubuntu-20.04]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
env: env:
GO111MODULE: off
TRAVIS: "true" TRAVIS: "true"
TRAVIS_BRANCH: ${{ github.base_ref }} TRAVIS_BRANCH: ${{ github.base_ref }}
TRAVIS_PULL_REQUEST_BRANCH: ${{ github.head_ref }} TRAVIS_PULL_REQUEST_BRANCH: ${{ github.head_ref }}
TRAVIS_PULL_REQUEST_SHA : ${{ github.event.pull_request.head.sha }} TRAVIS_PULL_REQUEST_SHA : ${{ github.event.pull_request.head.sha }}
RUST_BACKTRACE: "1" RUST_BACKTRACE: "1"
RUST_AGENT: "yes"
target_branch: ${TRAVIS_BRANCH} target_branch: ${TRAVIS_BRANCH}
steps: steps:
- name: Install Go - name: Install Go
@ -25,9 +23,6 @@ jobs:
GOPATH: ${{ runner.workspace }}/kata-containers GOPATH: ${{ runner.workspace }}/kata-containers
- name: Setup GOPATH - name: Setup GOPATH
run: | run: |
gopath_org=$(go env GOPATH)/src/github.com/kata-containers/
mkdir -p ${gopath_org}
ln -s ${PWD} ${gopath_org}
echo "TRAVIS_BRANCH: ${TRAVIS_BRANCH}" echo "TRAVIS_BRANCH: ${TRAVIS_BRANCH}"
echo "TRAVIS_PULL_REQUEST_BRANCH: ${TRAVIS_PULL_REQUEST_BRANCH}" echo "TRAVIS_PULL_REQUEST_BRANCH: ${TRAVIS_PULL_REQUEST_BRANCH}"
echo "TRAVIS_PULL_REQUEST_SHA: ${TRAVIS_PULL_REQUEST_SHA}" echo "TRAVIS_PULL_REQUEST_SHA: ${TRAVIS_PULL_REQUEST_SHA}"
@ -47,25 +42,25 @@ jobs:
target_branch=${TRAVIS_BRANCH} target_branch=${TRAVIS_BRANCH}
- name: Setup - name: Setup
run: | run: |
cd ${GOPATH}/src/github.com/kata-containers/kata-containers && ./ci/setup.sh cd ${GOPATH}/src/github.com/${{ github.repository }} && ./ci/setup.sh
env: env:
GOPATH: ${{ runner.workspace }}/kata-containers GOPATH: ${{ runner.workspace }}/kata-containers
- name: Building rust - name: Building rust
run: | run: |
cd ${GOPATH}/src/github.com/kata-containers/kata-containers && ./ci/install_rust.sh cd ${GOPATH}/src/github.com/${{ github.repository }} && ./ci/install_rust.sh
PATH=$PATH:"$HOME/.cargo/bin" PATH=$PATH:"$HOME/.cargo/bin"
- name: Make clippy rustup target add x86_64-unknown-linux-musl
rustup component add rustfmt clippy
# Must build before static checks as we depend on some generated code in runtime and agent
- name: Build
run: | run: |
cd ${GOPATH}/src/github.com/kata-containers/kata-containers/src/agent && rustup target add x86_64-unknown-linux-musl && rustup component add rustfmt && rustup component add clippy && make clippy cd ${GOPATH}/src/github.com/${{ github.repository }} && make
- name: Static checks - name: Static Checks
run: | run: |
cd ${GOPATH}/src/github.com/kata-containers/kata-containers && ./ci/static-checks.sh cd ${GOPATH}/src/github.com/${{ github.repository }} && ./ci/static-checks.sh
- name: Build agent - name: Run Compiler Checks
run: | run: |
cd ${GOPATH}/src/github.com/kata-containers/kata-containers/src/agent && make cd ${GOPATH}/src/github.com/${{ github.repository }} && make check
- name: Run agent unit tests - name: Run Unit Tests
run: | run: |
cd ${GOPATH}/src/github.com/kata-containers/kata-containers/src/agent && make check cd ${GOPATH}/src/github.com/${{ github.repository }} && make test
- name: Build agent-ctl tool (must be buildable against current agent)
run: |
cd ${GOPATH}/src/github.com/kata-containers/kata-containers/tools/agent-ctl && make

View File

@ -141,6 +141,9 @@ clippy: $(GENERATED_CODE)
-Aclippy::redundant_allocation \ -Aclippy::redundant_allocation \
-D warnings -D warnings
format:
cargo fmt -- --check
##TARGET install: install agent ##TARGET install: install agent
install: install-services install: install-services
@ -157,7 +160,7 @@ test:
@cargo test --all --target $(TRIPLE) @cargo test --all --target $(TRIPLE)
##TARGET check: run test ##TARGET check: run test
check: test check: clippy format
##TARGET run: build and run agent ##TARGET run: build and run agent
run: run:

View File

@ -642,7 +642,6 @@ go-test: $(GENERATED_FILES)
go test -v -mod=vendor ./... go test -v -mod=vendor ./...
check-go-static: check-go-static:
$(QUIET_CHECK)../../ci/static-checks.sh
$(QUIET_CHECK)../../ci/go-no-os-exit.sh ./cli $(QUIET_CHECK)../../ci/go-no-os-exit.sh ./cli
$(QUIET_CHECK)../../ci/go-no-os-exit.sh ./virtcontainers $(QUIET_CHECK)../../ci/go-no-os-exit.sh ./virtcontainers