Skip to content

Commit

Permalink
feat: Model signing unit tests on all runners (#75)
Browse files Browse the repository at this point in the history
* Model signing unit tests on all runners

Signed-off-by: laurentsimon <laurentsimon@google.com>

* Use bash for windows

Signed-off-by: laurentsimon <laurentsimon@google.com>

* Scripts for env setup and activate

Signed-off-by: laurentsimon <laurentsimon@google.com>

* Missing scripts

Signed-off-by: laurentsimon <laurentsimon@google.com>

* Default bash

Signed-off-by: laurentsimon <laurentsimon@google.com>

* use multiprocessing fork only for Linux

Signed-off-by: laurentsimon <laurentsimon@google.com>

* OS requirements

Signed-off-by: laurentsimon <laurentsimon@google.com>

* Seperate requirements for each runner

Signed-off-by: laurentsimon <laurentsimon@google.com>

* Generate Linux requirements

Signed-off-by: laurentsimon <laurentsimon@google.com>

* Use runner.os

Signed-off-by: laurentsimon <laurentsimon@google.com>

* Use runner.os

Signed-off-by: laurentsimon <laurentsimon@google.com>

* Use runner.os

Signed-off-by: laurentsimon <laurentsimon@google.com>

* Use runner.os

Signed-off-by: laurentsimon <laurentsimon@google.com>

* Remove warning from file

Signed-off-by: laurentsimon <laurentsimon@google.com>

* Fix test requirement

Signed-off-by: laurentsimon <laurentsimon@google.com>

* Removr Windows tests

Signed-off-by: laurentsimon <laurentsimon@google.com>

---------

Signed-off-by: laurentsimon <laurentsimon@google.com>
  • Loading branch information
laurentsimon authored Dec 5, 2023
1 parent 5db4c04 commit 50922ed
Show file tree
Hide file tree
Showing 14 changed files with 511 additions and 144 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/scripts/venv_activate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

# shellcheck source=/dev/null
source venv/bin/activate || source venv/Scripts/activate
6 changes: 6 additions & 0 deletions .github/workflows/scripts/venv_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

python -m venv venv

# shellcheck source=/dev/null
source venv/bin/activate || source venv/Scripts/activate
13 changes: 8 additions & 5 deletions .github/workflows/slsa_for_ml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ on:

permissions: read-all

defaults:
run:
shell: bash

jobs:
train:
name: Train model and save as ${{ github.event.inputs.model_type }}
Expand All @@ -28,19 +32,18 @@ jobs:
with:
python-version: 3.11
cache: pip
cache-dependency-path: slsa_for_models/install/requirements.txt
cache-dependency-path: slsa_for_models/install/requirements_${{ runner.os }}.txt
- name: Install dependencies
run: |
set -euo pipefail
python -m venv venv
source venv/bin/activate
python -m pip install --require-hashes -r slsa_for_models/install/requirements.txt
bash .github/workflows/scripts/venv_setup.sh
python -m pip install --require-hashes -r slsa_for_models/install/requirements_${{ runner.os }}.txt
- name: Build model
env:
MODEL_TYPE: ${{ github.event.inputs.model_type }}
run: |
set -euo pipefail
source venv/bin/activate
bash .github/workflows/scripts/venv_activate.sh
python slsa_for_models/main.py "$MODEL_TYPE"
- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
Expand Down
23 changes: 15 additions & 8 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,37 @@ on:

permissions: {}

defaults:
run:
shell: bash

jobs:
model-signing-unit-tests:
name: Run unit tests for signing
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # Don't cancel other jobs if one fails
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1
with:
python-version: 3.11
cache: pip
cache-dependency-path: |
model_signing/install/requirements.txt
model_signing/install/requirements.test.txt
model_signing/install/requirements_${{ runner.os }}.txt
model_signing/install/requirements_test_${{ runner.os }}.txt
- name: Install dependencies
run: |
set -euo pipefail
python -m venv venv
source venv/bin/activate
python -m pip install --require-hashes -r model_signing/install/requirements.txt
python -m pip install --require-hashes -r model_signing/install/requirements.test.txt
bash .github/workflows/scripts/venv_setup.sh
python -m pip install --require-hashes -r model_signing/install/requirements_${{ runner.os }}.txt
python -m pip install --require-hashes -r model_signing/install/requirements_test_${{ runner.os }}.txt
- name: Run unit tests
run: |
set -euo pipefail
source venv/bin/activate
bash .github/workflows/scripts/venv_activate.sh
# NOTE: option --full-trace may be useful for troubleshooting.
# TODO(#68): Remove the need to create this folder.
mkdir testdata
Expand Down
24 changes: 15 additions & 9 deletions .github/workflows/validate_deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,30 @@ on:

permissions: {}

defaults:
run:
shell: bash

jobs:
model-signing:
name: Test model signing dependencies
runs-on: ubuntu-latest
runs-on: ${{ runner.os }}}
strategy:
fail-fast: false # Don't cancel other jobs if one fails
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1
with:
python-version: 3.11
cache: pip
cache-dependency-path: model_signing/install/requirements.txt
cache-dependency-path: model_signing/install/requirements_${{ runner.os }}.txt
- name: Install dependencies
run: |
set -euo pipefail
python -m venv venv
source venv/bin/activate
python -m pip install --require-hashes -r model_signing/install/requirements.txt
bash .github/workflows/scripts/venv_setup.sh
python -m pip install --require-hashes -r model_signing/install/requirements_${{ runner.os }}.txt
slsa-for-ml:
name: Test SLSA for ML demo dependencies
Expand All @@ -35,10 +42,9 @@ jobs:
with:
python-version: 3.11
cache: pip
cache-dependency-path: slsa_for_models/install/requirements.txt
cache-dependency-path: slsa_for_models/install/requirements_${{ runner.os }}.txt
- name: Install dependencies
run: |
set -euo pipefail
python -m venv venv
source venv/bin/activate
python -m pip install --require-hashes -r slsa_for_models/install/requirements.txt
bash .github/workflows/scripts/venv_setup.sh
python -m pip install --require-hashes -r slsa_for_models/install/requirements_${{ runner.os }}.txt
Loading

0 comments on commit 50922ed

Please sign in to comment.