2021-03-18 13:01:07 +00:00
|
|
|
name: "Validations"
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
|
|
|
push:
|
2022-03-02 17:51:37 +00:00
|
|
|
branches:
|
|
|
|
- main
|
2021-03-18 13:01:07 +00:00
|
|
|
pull_request:
|
|
|
|
|
|
|
|
env:
|
2022-02-09 16:08:24 +00:00
|
|
|
GO_VERSION: "1.17.x"
|
2021-03-18 13:01:07 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
|
|
|
|
Static-Analysis:
|
2021-04-22 20:20:21 +00:00
|
|
|
# Note: changing this job name requires making the same update in the .github/workflows/release.yaml pipeline
|
2021-03-18 13:01:07 +00:00
|
|
|
name: "Static analysis"
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
steps:
|
|
|
|
- uses: actions/setup-go@v2
|
|
|
|
with:
|
|
|
|
go-version: ${{ env.GO_VERSION }}
|
|
|
|
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Restore tool cache
|
|
|
|
id: tool-cache
|
|
|
|
uses: actions/cache@v2.1.3
|
|
|
|
with:
|
|
|
|
path: ${{ github.workspace }}/.tmp
|
|
|
|
key: ${{ runner.os }}-tool-${{ hashFiles('Makefile') }}
|
|
|
|
|
|
|
|
- name: Restore go cache
|
|
|
|
id: go-cache
|
|
|
|
uses: actions/cache@v2.1.3
|
|
|
|
with:
|
|
|
|
path: ~/go/pkg/mod
|
|
|
|
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-go-${{ env.GO_VERSION }}-
|
|
|
|
|
|
|
|
- name: (cache-miss) Bootstrap all project dependencies
|
|
|
|
if: steps.tool-cache.outputs.cache-hit != 'true' || steps.go-cache.outputs.cache-hit != 'true'
|
|
|
|
run: make bootstrap
|
|
|
|
|
|
|
|
- name: Bootstrap CI environment dependencies
|
|
|
|
run: make ci-bootstrap
|
|
|
|
|
|
|
|
- name: Run static analysis
|
|
|
|
run: make static-analysis
|
|
|
|
|
|
|
|
Unit-Test:
|
2021-04-22 20:20:21 +00:00
|
|
|
# Note: changing this job name requires making the same update in the .github/workflows/release.yaml pipeline
|
2021-03-18 13:01:07 +00:00
|
|
|
name: "Unit tests"
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
steps:
|
|
|
|
- uses: actions/setup-go@v2
|
|
|
|
with:
|
|
|
|
go-version: ${{ env.GO_VERSION }}
|
|
|
|
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Restore tool cache
|
|
|
|
id: tool-cache
|
|
|
|
uses: actions/cache@v2.1.3
|
|
|
|
with:
|
|
|
|
path: ${{ github.workspace }}/.tmp
|
|
|
|
key: ${{ runner.os }}-tool-${{ hashFiles('Makefile') }}
|
|
|
|
|
|
|
|
- name: Restore go cache
|
|
|
|
id: go-cache
|
|
|
|
uses: actions/cache@v2.1.3
|
|
|
|
with:
|
|
|
|
path: ~/go/pkg/mod
|
|
|
|
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-go-${{ env.GO_VERSION }}-
|
|
|
|
|
|
|
|
- name: (cache-miss) Bootstrap all project dependencies
|
|
|
|
if: steps.tool-cache.outputs.cache-hit != 'true' || steps.go-cache.outputs.cache-hit != 'true'
|
|
|
|
run: make bootstrap
|
|
|
|
|
|
|
|
- name: Bootstrap CI environment dependencies
|
|
|
|
run: make ci-bootstrap
|
|
|
|
|
|
|
|
- name: Build cache key for java test-fixture blobs (for unit tests)
|
|
|
|
run: make java-packages-fingerprint
|
|
|
|
|
|
|
|
- name: Restore Java test-fixture cache
|
|
|
|
id: unit-java-cache
|
|
|
|
uses: actions/cache@v2.1.3
|
|
|
|
with:
|
|
|
|
path: syft/pkg/cataloger/java/test-fixtures/java-builds/packages
|
|
|
|
key: ${{ runner.os }}-unit-java-cache-${{ hashFiles( 'syft/pkg/cataloger/java/test-fixtures/java-builds/packages.fingerprint' ) }}
|
|
|
|
|
|
|
|
- name: Run unit tests
|
|
|
|
run: make unit
|
|
|
|
|
|
|
|
- uses: actions/upload-artifact@v2
|
|
|
|
with:
|
|
|
|
name: unit-test-results
|
|
|
|
path: test/results/**/*
|
|
|
|
|
|
|
|
Integration-Test:
|
2021-04-22 20:20:21 +00:00
|
|
|
# Note: changing this job name requires making the same update in the .github/workflows/release.yaml pipeline
|
2021-03-18 13:01:07 +00:00
|
|
|
name: "Integration tests"
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
steps:
|
|
|
|
- uses: actions/setup-go@v2
|
|
|
|
with:
|
|
|
|
go-version: ${{ env.GO_VERSION }}
|
|
|
|
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Restore tool cache
|
|
|
|
id: tool-cache
|
|
|
|
uses: actions/cache@v2.1.3
|
|
|
|
with:
|
|
|
|
path: ${{ github.workspace }}/.tmp
|
|
|
|
key: ${{ runner.os }}-tool-${{ hashFiles('Makefile') }}
|
|
|
|
|
|
|
|
- name: Restore go cache
|
|
|
|
id: go-cache
|
|
|
|
uses: actions/cache@v2.1.3
|
|
|
|
with:
|
|
|
|
path: ~/go/pkg/mod
|
|
|
|
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-go-${{ env.GO_VERSION }}-
|
|
|
|
|
|
|
|
- name: (cache-miss) Bootstrap all project dependencies
|
|
|
|
if: steps.tool-cache.outputs.cache-hit != 'true' || steps.go-cache.outputs.cache-hit != 'true'
|
|
|
|
run: make bootstrap
|
|
|
|
|
|
|
|
- name: Bootstrap CI environment dependencies
|
|
|
|
run: make ci-bootstrap
|
|
|
|
|
|
|
|
- name: Validate syft output against the CycloneDX schema
|
|
|
|
run: make validate-cyclonedx-schema
|
|
|
|
|
|
|
|
- name: Build key for tar cache
|
|
|
|
run: make integration-fingerprint
|
|
|
|
|
|
|
|
- name: Restore integration test cache
|
|
|
|
uses: actions/cache@v2.1.3
|
|
|
|
with:
|
|
|
|
path: ${{ github.workspace }}/test/integration/test-fixtures/cache
|
|
|
|
key: ${{ runner.os }}-integration-test-cache-${{ hashFiles('test/integration/test-fixtures/cache.fingerprint') }}
|
|
|
|
|
|
|
|
- name: Run integration tests
|
|
|
|
run: make integration
|
|
|
|
|
|
|
|
Benchmark-Test:
|
|
|
|
name: "Benchmark tests"
|
|
|
|
runs-on: ubuntu-20.04
|
2021-03-18 19:43:05 +00:00
|
|
|
# note: we want benchmarks to run on pull_request events in order to publish results to a sticky comment, and
|
|
|
|
# we also want to run on push such that merges to main are recorded to the cache. For this reason we don't filter
|
|
|
|
# the job by event.
|
2021-03-18 13:01:07 +00:00
|
|
|
steps:
|
|
|
|
- uses: actions/setup-go@v2
|
|
|
|
with:
|
|
|
|
go-version: ${{ env.GO_VERSION }}
|
|
|
|
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Restore tool cache
|
|
|
|
id: tool-cache
|
|
|
|
uses: actions/cache@v2.1.3
|
|
|
|
with:
|
|
|
|
path: ${{ github.workspace }}/.tmp
|
|
|
|
key: ${{ runner.os }}-tool-${{ hashFiles('Makefile') }}
|
|
|
|
|
|
|
|
- name: Restore go cache
|
|
|
|
id: go-cache
|
|
|
|
uses: actions/cache@v2.1.3
|
|
|
|
with:
|
|
|
|
path: ~/go/pkg/mod
|
|
|
|
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-go-${{ env.GO_VERSION }}-
|
|
|
|
|
|
|
|
- name: (cache-miss) Bootstrap all project dependencies
|
|
|
|
if: steps.tool-cache.outputs.cache-hit != 'true' || steps.go-cache.outputs.cache-hit != 'true'
|
|
|
|
run: make bootstrap
|
|
|
|
|
|
|
|
- name: Bootstrap CI environment dependencies
|
|
|
|
run: make ci-bootstrap
|
|
|
|
|
|
|
|
- name: Restore base benchmark result
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: test/results/benchmark-main.txt
|
|
|
|
# use base sha for PR or new commit hash for main push in benchmark result key
|
|
|
|
key: ${{ runner.os }}-bench-${{ (github.event.pull_request.base.sha != github.event.after) && github.event.pull_request.base.sha || github.event.after }}
|
|
|
|
|
|
|
|
- name: Run benchmark tests
|
|
|
|
id: benchmark
|
|
|
|
run: |
|
|
|
|
REF_NAME=${GITHUB_REF##*/} make benchmark
|
2021-03-24 11:35:14 +00:00
|
|
|
OUTPUT=$(make show-benchstat)
|
|
|
|
OUTPUT="${OUTPUT//'%'/'%25'}" # URL encode all '%' characters
|
|
|
|
OUTPUT="${OUTPUT//$'\n'/'%0A'}" # URL encode all '\n' characters
|
|
|
|
OUTPUT="${OUTPUT//$'\r'/'%0D'}" # URL encode all '\r' characters
|
|
|
|
echo "::set-output name=result::$OUTPUT"
|
2021-03-18 13:01:07 +00:00
|
|
|
|
|
|
|
- uses: actions/upload-artifact@v2
|
|
|
|
with:
|
2021-03-23 19:03:25 +00:00
|
|
|
name: benchmark-test-results
|
2021-03-18 13:01:07 +00:00
|
|
|
path: test/results/**/*
|
|
|
|
|
|
|
|
- name: Update PR benchmark results comment
|
|
|
|
uses: marocchino/sticky-pull-request-comment@v2
|
2021-03-29 15:11:23 +00:00
|
|
|
continue-on-error: true
|
2021-03-18 13:01:07 +00:00
|
|
|
with:
|
|
|
|
header: benchmark
|
|
|
|
message: |
|
|
|
|
### Benchmark Test Results
|
|
|
|
|
|
|
|
<details>
|
|
|
|
<summary>Benchmark results from the latest changes vs base branch</summary>
|
|
|
|
|
|
|
|
```
|
|
|
|
${{ steps.benchmark.outputs.result }}
|
|
|
|
```
|
|
|
|
|
|
|
|
</details>
|
|
|
|
|
|
|
|
Build-Snapshot-Artifacts:
|
|
|
|
name: "Build snapshot artifacts"
|
2021-03-23 14:28:57 +00:00
|
|
|
runs-on: ubuntu-20.04
|
2021-03-18 13:01:07 +00:00
|
|
|
steps:
|
|
|
|
- uses: actions/setup-go@v2
|
|
|
|
with:
|
|
|
|
go-version: ${{ env.GO_VERSION }}
|
|
|
|
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
|
2021-10-26 13:42:35 +00:00
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v1
|
|
|
|
|
2021-03-18 13:01:07 +00:00
|
|
|
- name: Restore tool cache
|
|
|
|
id: tool-cache
|
|
|
|
uses: actions/cache@v2.1.3
|
|
|
|
with:
|
|
|
|
path: ${{ github.workspace }}/.tmp
|
|
|
|
key: ${{ runner.os }}-tool-${{ hashFiles('Makefile') }}
|
|
|
|
|
|
|
|
- name: Restore go cache
|
|
|
|
id: go-cache
|
|
|
|
uses: actions/cache@v2.1.3
|
|
|
|
with:
|
|
|
|
path: ~/go/pkg/mod
|
|
|
|
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-go-${{ env.GO_VERSION }}-
|
|
|
|
|
|
|
|
- name: (cache-miss) Bootstrap all project dependencies
|
|
|
|
if: steps.tool-cache.outputs.cache-hit != 'true' || steps.go-cache.outputs.cache-hit != 'true'
|
|
|
|
run: make bootstrap
|
|
|
|
|
|
|
|
- name: Build snapshot artifacts
|
|
|
|
run: make snapshot
|
|
|
|
|
|
|
|
- uses: actions/upload-artifact@v2
|
|
|
|
with:
|
|
|
|
name: artifacts
|
|
|
|
path: snapshot/**/*
|
|
|
|
|
|
|
|
Acceptance-Linux:
|
2021-04-22 20:20:21 +00:00
|
|
|
# Note: changing this job name requires making the same update in the .github/workflows/release.yaml pipeline
|
2021-03-18 13:01:07 +00:00
|
|
|
name: "Acceptance tests (Linux)"
|
|
|
|
needs: [Build-Snapshot-Artifacts]
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- uses: actions/download-artifact@v2
|
|
|
|
with:
|
|
|
|
name: artifacts
|
|
|
|
path: snapshot
|
|
|
|
|
2022-02-01 21:58:47 +00:00
|
|
|
- name: Run comparison tests (Linux)
|
|
|
|
run: make compare-linux
|
|
|
|
|
|
|
|
- name: Build key for image cache
|
|
|
|
run: make install-fingerprint
|
|
|
|
|
|
|
|
- name: Restore install.sh test image cache
|
|
|
|
id: install-test-image-cache
|
|
|
|
uses: actions/cache@v2.1.3
|
|
|
|
with:
|
|
|
|
path: ${{ github.workspace }}/test/install/cache
|
|
|
|
key: ${{ runner.os }}-install-test-image-cache-${{ hashFiles('test/install/cache.fingerprint') }}
|
|
|
|
|
|
|
|
- name: Load test image cache
|
|
|
|
if: steps.install-test-image-cache.outputs.cache-hit == 'true'
|
|
|
|
run: make install-test-cache-load
|
|
|
|
|
|
|
|
- name: Run install.sh tests (Linux)
|
|
|
|
run: make install-test
|
|
|
|
|
|
|
|
- name: (cache-miss) Create test image cache
|
|
|
|
if: steps.install-test-image-cache.outputs.cache-hit != 'true'
|
|
|
|
run: make install-test-cache-save
|
|
|
|
|
2021-03-18 13:01:07 +00:00
|
|
|
|
|
|
|
Acceptance-Mac:
|
2021-04-22 20:20:21 +00:00
|
|
|
# Note: changing this job name requires making the same update in the .github/workflows/release.yaml pipeline
|
2021-03-18 13:01:07 +00:00
|
|
|
name: "Acceptance tests (Mac)"
|
|
|
|
needs: [Build-Snapshot-Artifacts]
|
|
|
|
runs-on: macos-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- uses: actions/download-artifact@v2
|
|
|
|
with:
|
|
|
|
name: artifacts
|
|
|
|
path: snapshot
|
|
|
|
|
2022-02-01 21:58:47 +00:00
|
|
|
- name: Restore docker image cache for compare testing
|
|
|
|
id: mac-compare-testing-cache
|
2021-03-23 19:03:25 +00:00
|
|
|
uses: actions/cache@v2.1.3
|
|
|
|
with:
|
2021-04-16 13:20:07 +00:00
|
|
|
path: image.tar
|
2022-02-01 21:58:47 +00:00
|
|
|
key: ${{ runner.os }}-${{ hashFiles('test/compare/mac.sh') }}
|
|
|
|
|
|
|
|
- name: Run comparison tests (Mac)
|
|
|
|
run: make compare-mac
|
2021-03-23 19:03:25 +00:00
|
|
|
|
2022-02-01 21:58:47 +00:00
|
|
|
- name: Run install.sh tests (Mac)
|
|
|
|
run: make install-test-ci-mac
|
2021-03-18 13:01:07 +00:00
|
|
|
|
|
|
|
Cli-Linux:
|
2021-04-22 20:20:21 +00:00
|
|
|
# Note: changing this job name requires making the same update in the .github/workflows/release.yaml pipeline
|
2021-03-18 13:01:07 +00:00
|
|
|
name: "CLI tests (Linux)"
|
|
|
|
needs: [Build-Snapshot-Artifacts]
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
steps:
|
2021-10-21 16:49:36 +00:00
|
|
|
- uses: actions/setup-go@v2
|
|
|
|
with:
|
|
|
|
go-version: ${{ env.GO_VERSION }}
|
|
|
|
|
2021-03-18 13:01:07 +00:00
|
|
|
- uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Restore go cache
|
|
|
|
id: go-cache
|
|
|
|
uses: actions/cache@v2.1.3
|
|
|
|
with:
|
|
|
|
path: ~/go/pkg/mod
|
|
|
|
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-go-${{ env.GO_VERSION }}-
|
|
|
|
|
2022-02-23 02:45:12 +00:00
|
|
|
- name: Restore tool cache
|
|
|
|
id: tool-cache
|
|
|
|
uses: actions/cache@v2.1.3
|
|
|
|
with:
|
|
|
|
path: ${{ github.workspace }}/.tmp
|
|
|
|
key: ${{ runner.os }}-tool-${{ hashFiles('Makefile') }}
|
|
|
|
|
|
|
|
- name: (cache-miss) Bootstrap all project dependencies
|
|
|
|
if: steps.tool-cache.outputs.cache-hit != 'true' || steps.go-cache.outputs.cache-hit != 'true'
|
|
|
|
run: make bootstrap
|
2021-03-18 13:01:07 +00:00
|
|
|
|
|
|
|
- name: Build key for tar cache
|
|
|
|
run: make cli-fingerprint
|
|
|
|
|
|
|
|
- name: Restore CLI test cache
|
|
|
|
uses: actions/cache@v2.1.3
|
|
|
|
with:
|
|
|
|
path: ${{ github.workspace }}/test/cli/test-fixtures/cache
|
|
|
|
key: ${{ runner.os }}-cli-test-cache-${{ hashFiles('test/cli/test-fixtures/cache.fingerprint') }}
|
|
|
|
|
|
|
|
- uses: actions/download-artifact@v2
|
|
|
|
with:
|
|
|
|
name: artifacts
|
|
|
|
path: snapshot
|
|
|
|
|
|
|
|
- name: Run CLI Tests (Linux)
|
2021-03-20 11:33:13 +00:00
|
|
|
run: make cli
|