Skip to content

Commit

Permalink
ci(test): add trivy tests (#1400)
Browse files Browse the repository at this point in the history
* ci(test): add trivy tests

* update workflow

* fix defsec replacement

* run integration tests only on ubuntu
  • Loading branch information
nikpivkin authored Aug 15, 2023
1 parent 25163a9 commit 2930198
Showing 1 changed file with 95 additions and 0 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/test-trivy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: test trivy
on:
push:
branches-ignore:
- "master"
pull_request:

env:
TRIVY_DIR: "trivy-repo"
DEFSEC_DIR: "defsec-repo"

jobs:
test:
name: Test trivy
defaults:
run:
working-directory: ${{ env.TRIVY_DIR }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]

steps:
- name: Checkout defsec
uses: actions/checkout@v3
with:
repository: aquasecurity/defsec
path: ${{ env.DEFSEC_DIR }}

- name: Checkout trivy
uses: actions/checkout@v3
with:
repository: aquasecurity/trivy
path: ${{ env.TRIVY_DIR }}

- uses: actions/setup-go@v4
with:
go-version-file: "${{ env.TRIVY_DIR }}/go.mod"
cache-dependency-path: "${{ env.TRIVY_DIR }}/go.sum"

- name: Replace defsec
run: |
go mod edit -replace "github.com/aquasecurity/defsec=../${{ env.DEFSEC_DIR }}"
- name: Install tools
uses: aquaproj/[email protected]
with:
aqua_version: v2.8.0
working_directory: ${{ env.TRIVY_DIR }}

- name: Run unit tests
run: mage test:unit

integration:
name: Integration Tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.TRIVY_DIR }}
steps:
- name: Checkout defsec
uses: actions/checkout@v3
with:
repository: aquasecurity/defsec
path: ${{ env.DEFSEC_DIR }}

- name: Checkout trivy
uses: actions/checkout@v3
with:
repository: aquasecurity/trivy
path: ${{ env.TRIVY_DIR }}

- uses: actions/setup-go@v4
with:
go-version-file: "${{ env.TRIVY_DIR }}/go.mod"
cache-dependency-path: "${{ env.TRIVY_DIR }}/go.sum"

- name: Replace defsec
run: |
go mod edit -replace "github.com/aquasecurity/defsec=../${{ env.DEFSEC_DIR }}"
- name: Install tools
uses: aquaproj/[email protected]
with:
aqua_version: v2.8.0
working_directory: ${{ env.TRIVY_DIR }}

- name: Run integration tests
run: mage test:integration

- name: Run k8s integration tests
run: mage test:k8s

- name: Run module integration tests
run: mage test:module

0 comments on commit 2930198

Please sign in to comment.