Merge pull request #81 from scanoss/feature/mdaloia/update-docs #231
This file contains 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_NAME: scanoss/scanoss-py | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
# Setup and build the python package | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10.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@v3 | |
# Build Docker image with Buildx | |
- name: Build Docker Image | |
id: build-and-push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: false | |
tags: ${{ env.IMAGE_NAME }}:latest | |
outputs: type=docker,dest=/tmp/scanoss-py.tar | |
- name: Test Docker Image | |
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 | |
docker run -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 |