Skip to content

Build wheels during unit test CI jobs and upload SLSA attestations #45

Build wheels during unit test CI jobs and upload SLSA attestations

Build wheels during unit test CI jobs and upload SLSA attestations #45

Workflow file for this run

# Copyright (c) 2024 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
name: Test Runner Unit Tests
on:
push: null
pull_request:
branches:
- main
permissions: read-all
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
unit-test:
runs-on: [ k8-runners ]
steps:
- uses: step-security/harden-runner@v2
with:
egress-policy: audit
- uses: actions/checkout@v4
- uses: docker/login-action@v3
with:
registry: ${{ secrets.REGISTRY }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Install requirements
run: |
sudo apt-get update -y
sudo apt-get install python3.8-venv -y
python -m venv venv
source venv/bin/activate
venv/bin/python -m pip install pytest hypothesis
venv/bin/python -m pip install -r requirements.txt
working-directory: ${{ github.workspace }}/test-runner
- name: Unit Test
run: venv/bin/python -m pytest tests/utest.py -W ignore::UserWarning
working-directory: ${{ github.workspace }}/test-runner
env:
REGISTRY: ${{ secrets.REGISTRY }}
build:
name: Build wheel
runs-on: ubuntu-latest
permissions:
id-token: write
attestations: write
contents: read
strategy:
fail-fast: false
matrix:
python-version:
- "3.12"
steps:
- name: Harden Runner
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
egress-policy: audit
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel build
- name: Build
run: |
python -m build .
- name: Get built filenames
id: filename
run: |
echo "tar=$(cd dist/ && echo *.tar.gz)" >> $GITHUB_OUTPUT
echo "whl=$(cd dist/ && echo *.tar.gz)" >> $GITHUB_OUTPUT
- name: Attest Build Provenance for tar
uses: actions/attest-build-provenance@897ed5eab6ed058a474202017ada7f40bfa52940 # v1.0.0
with:
subject-path: "dist/${{ steps.filename.outputs.tar }}"
- name: Attest Build Provenance for whl
uses: actions/attest-build-provenance@897ed5eab6ed058a474202017ada7f40bfa52940 # v1.0.0
with:
subject-path: "dist/${{ steps.filename.outputs.whl }}"