SP-4487: fix scanoss.json skip patterns for fingerprinting and negati… #924
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build/Test Local Container | |
| # Build a docker image on demand and run a local test (connecting to api.osskb.org) | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - "main" | |
| pull_request: | |
| branches: | |
| - "main" | |
| env: | |
| IMAGE_BASE: scanoss/scanoss-py-base | |
| IMAGE_NAME: scanoss/scanoss-py | |
| IMAGE_JENKINS: scanoss/scanoss-py-jenkins | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v6 | |
| # Setup and build the python package | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.9.x" | |
| - name: Install Dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements-dev.txt | |
| - name: Build Package | |
| run: make dist | |
| - name: Setup Docker buildx | |
| uses: docker/setup-buildx-action@v4 | |
| # Build Docker image with Buildx - Base | |
| - name: Build Docker Image - No Entrypoint | |
| id: build-no-ep | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| push: false | |
| tags: ${{ env.IMAGE_BASE }}:latest | |
| target: no_entry_point | |
| outputs: type=docker,dest=/tmp/scanoss-py-base.tar | |
| # Build Docker image with Buildx - Jenkins | |
| - name: Build Docker Image - Jenkins | |
| id: build-je | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| push: false | |
| tags: ${{ env.IMAGE_JENKINS }}:latest | |
| target: jenkins | |
| outputs: type=docker,dest=/tmp/scanoss-py-jenkins.tar | |
| # Build Docker image with Buildx - Entrypoint | |
| - name: Build Docker Image - With Entrypoint | |
| id: build-with-ep | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| push: false | |
| tags: ${{ env.IMAGE_NAME }}:latest | |
| target: with_entry_point | |
| outputs: type=docker,dest=/tmp/scanoss-py.tar | |
| - name: Test Docker Image - No Entrypoint | |
| run: | | |
| docker load --input /tmp/scanoss-py-base.tar | |
| docker image ls -a | |
| docker run ${{ env.IMAGE_BASE }} scanoss-py version | |
| - name: Test Docker Image - Jenkins | |
| run: | | |
| docker load --input /tmp/scanoss-py-jenkins.tar | |
| docker image ls -a | |
| docker run ${{ env.IMAGE_JENKINS }} scanoss-py version | |
| - name: Test Docker Image - With Entrypoint | |
| run: | | |
| docker load --input /tmp/scanoss-py.tar | |
| docker image ls -a | |
| docker run ${{ env.IMAGE_NAME }} version | |
| docker run ${{ env.IMAGE_NAME }} utils fast | |
| echo "Running file scan on tests" | |
| docker run -e SCANOSS_API_KEY="${{ secrets.SC_API_KEY }}" -v "$(pwd)":"/scanoss" ${{ env.IMAGE_NAME }} scan -o results.json tests | |
| id_count=$(cat results.json | grep '"id":' | wc -l) | |
| echo "ID Count: $id_count" | |
| if [[ $id_count -lt 1 ]]; then | |
| echo "Error: Scan test did not produce any results. Failing" | |
| exit 1 | |
| fi | |
| echo "Running fingerprinting on tests" | |
| docker run -v "$(pwd)":"/scanoss" ${{ env.IMAGE_NAME }} wfp --skip-headers -o fingers.wfp tests | |
| wfp_count=$(cat fingers.wfp | grep 'file=' | wc -l) | |
| echo "WFP Count: $wfp_count" | |
| if [[ $wfp_count -lt 1 ]]; then | |
| echo "Error: WFP test did not produce any results. Failing" | |
| exit 1 | |
| fi | |
| echo "Running dependency scan on tests" | |
| docker run -e SCANOSS_API_KEY="${{ secrets.SC_API_KEY }}" -v "$(pwd)":"/scanoss" ${{ env.IMAGE_NAME }} scan --dependencies-only -o results.json tests | |
| dep_count=$(python3 -c "import json,sys; d=json.load(open('results.json')); print(sum(len(v.get('dependencies',[])) for f in d.values() for v in f))" 2>/dev/null || echo 0) | |
| echo "Dependency count: $dep_count" | |
| if [[ $dep_count -lt 1 ]]; then | |
| echo "Error: Dependency scan did not find any dependencies. Failing" | |
| exit 1 | |
| fi | |