mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-09-14 05:40:16 +00:00
Run PR validation check only when needed & use docker cache during build (#876)
* Improve PR validation checks
This commit is contained in:
35
.github/workflows/build.yml
vendored
35
.github/workflows/build.yml
vendored
@@ -15,15 +15,23 @@ jobs:
|
|||||||
name: CLI executable build
|
name: CLI executable build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
- name: Check out code into the Go module directory
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 2
|
||||||
|
|
||||||
|
- name: Check modified files
|
||||||
|
id: modified_files
|
||||||
|
run: devops/check_modified_files.sh cli/
|
||||||
|
|
||||||
- name: Set up Go 1.17
|
- name: Set up Go 1.17
|
||||||
|
if: steps.modified_files.outputs.matched == 'true'
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: '1.17'
|
go-version: '1.17'
|
||||||
|
|
||||||
- name: Check out code into the Go module directory
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Build CLI
|
- name: Build CLI
|
||||||
|
if: steps.modified_files.outputs.matched == 'true'
|
||||||
run: make cli
|
run: make cli
|
||||||
|
|
||||||
build-agent:
|
build-agent:
|
||||||
@@ -32,6 +40,23 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Check out code into the Go module directory
|
- name: Check out code into the Go module directory
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 2
|
||||||
|
|
||||||
- name: Build Agent
|
- name: Check modified files
|
||||||
run: make agent-docker
|
id: modified_files
|
||||||
|
run: devops/check_modified_files.sh agent/ shared/ tap/ ui/ Dockerfile
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
if: steps.modified_files.outputs.matched == 'true'
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
if: steps.modified_files.outputs.matched == 'true'
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: false
|
||||||
|
tags: up9inc/mizu:devlatest
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
|
23
.github/workflows/test.yml
vendored
23
.github/workflows/test.yml
vendored
@@ -19,14 +19,16 @@ jobs:
|
|||||||
name: Unit Tests
|
name: Unit Tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
- name: Check out code into the Go module directory
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 2
|
||||||
|
|
||||||
- name: Set up Go 1.17
|
- name: Set up Go 1.17
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: '^1.17'
|
go-version: '^1.17'
|
||||||
|
|
||||||
- name: Check out code into the Go module directory
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Install libpcap
|
- name: Install libpcap
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
@@ -40,16 +42,31 @@ jobs:
|
|||||||
- name: 'Set up Cloud SDK'
|
- name: 'Set up Cloud SDK'
|
||||||
uses: 'google-github-actions/setup-gcloud@v0'
|
uses: 'google-github-actions/setup-gcloud@v0'
|
||||||
|
|
||||||
|
- name: Check CLI modified files
|
||||||
|
id: cli_modified_files
|
||||||
|
run: devops/check_modified_files.sh cli/
|
||||||
|
|
||||||
- name: CLI Test
|
- name: CLI Test
|
||||||
|
if: github.event_name == 'push' || steps.cli_modified_files.outputs.matched == 'true'
|
||||||
run: make test-cli
|
run: make test-cli
|
||||||
|
|
||||||
|
- name: Check Agent modified files
|
||||||
|
id: agent_modified_files
|
||||||
|
run: devops/check_modified_files.sh agent/
|
||||||
|
|
||||||
- name: Agent Test
|
- name: Agent Test
|
||||||
|
if: github.event_name == 'push' || steps.agent_modified_files.outputs.matched == 'true'
|
||||||
run: make test-agent
|
run: make test-agent
|
||||||
|
|
||||||
- name: Shared Test
|
- name: Shared Test
|
||||||
run: make test-shared
|
run: make test-shared
|
||||||
|
|
||||||
|
- name: Check extensions modified files
|
||||||
|
id: ext_modified_files
|
||||||
|
run: devops/check_modified_files.sh tap/extensions/
|
||||||
|
|
||||||
- name: Extensions Test
|
- name: Extensions Test
|
||||||
|
if: github.event_name == 'push' || steps.ext_modified_files.outputs.matched == 'true'
|
||||||
run: make test-extensions
|
run: make test-extensions
|
||||||
|
|
||||||
- name: Upload coverage to Codecov
|
- name: Upload coverage to Codecov
|
||||||
|
45
devops/check_modified_files.sh
Executable file
45
devops/check_modified_files.sh
Executable file
@@ -0,0 +1,45 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
paths_arr=( "$@" )
|
||||||
|
|
||||||
|
printf "\n========== List modified files ==========\n"
|
||||||
|
echo "$(git diff --name-only HEAD^ HEAD)"
|
||||||
|
|
||||||
|
printf "\n========== List paths to match and check existence ==========\n"
|
||||||
|
for path in ${paths_arr[*]}
|
||||||
|
do
|
||||||
|
if [ -f "$path" ] || [ -d "$path" ]; then
|
||||||
|
echo "$path - found"
|
||||||
|
else
|
||||||
|
echo "$path - does not found - exiting with failure"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
printf "\n========== Check paths of modified files ==========\n"
|
||||||
|
git diff --name-only HEAD^ HEAD > files.txt
|
||||||
|
matched=false
|
||||||
|
while IFS= read -r file
|
||||||
|
do
|
||||||
|
for path in ${paths_arr[*]}
|
||||||
|
do
|
||||||
|
if [[ $file == $path* ]]; then
|
||||||
|
echo "$file - match path: $path"
|
||||||
|
matched=true
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [[ $matched == true ]]; then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
echo "$file - does not match any given path"
|
||||||
|
fi
|
||||||
|
done < files.txt
|
||||||
|
|
||||||
|
printf "\n========== Result ==========\n"
|
||||||
|
if [[ $matched = true ]]; then
|
||||||
|
echo "match found"
|
||||||
|
echo "::set-output name=matched::true"
|
||||||
|
else
|
||||||
|
echo "no match found"
|
||||||
|
echo "::set-output name=matched::false"
|
||||||
|
fi
|
Reference in New Issue
Block a user