-
Notifications
You must be signed in to change notification settings - Fork 19
63 lines (53 loc) · 1.65 KB
/
container-local-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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