diff --git a/.github/labeler.yml b/.github/labeler.yml index 8f32ae25390..95ce0cc73c6 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -37,3 +37,8 @@ pkg:syft-enclave: - changed-files: - any-glob-to-any-file: - 'packages/syft-enclave/**' + +pkg:syft-restrict: + - changed-files: + - any-glob-to-any-file: + - 'packages/syft-restrict/**' diff --git a/.github/workflows/cd-monorepo.yml b/.github/workflows/cd-monorepo.yml index 977c7556024..14db3a2a799 100644 --- a/.github/workflows/cd-monorepo.yml +++ b/.github/workflows/cd-monorepo.yml @@ -17,6 +17,11 @@ on: - minor - major + release_syft_restrict: + description: Release syft-restrict + type: boolean + default: true + release_syft_permissions: description: Release syft-permissions type: boolean @@ -61,14 +66,26 @@ jobs: secrets: inherit # Release order follows dependency graph: - # 1. syft-permissions (no internal deps) - # 2. syft-perms (depends on syft-permissions) - # 3. syft-job + syft-dataset (depend on syft-perms) — parallel - # 4. syft-bg (depends on syft-job) - # 5. syft-client (depends on all above) + # 1. syft-restrict (no internal deps) + # 2. syft-permissions (no internal deps) + # 3. syft-perms (depends on syft-permissions) + # 4. syft-job + syft-dataset (depend on syft-perms) — parallel + # 5. syft-bg (depends on syft-job) + # 6. syft-client (depends on all above) + # + + release-syft-restrict: + needs: [call-linting-tests, call-unit-tests, call-integration-tests] + if: >- + !cancelled() && !failure() && + inputs.release_syft_restrict == true + uses: ./.github/workflows/cd-syft-restrict.yml + with: + bump_type: ${{ inputs.bump_type }} + secrets: inherit release-syft-permissions: - needs: [call-linting-tests, call-unit-tests, call-integration-tests] + needs: [release-syft-restrict] if: >- !cancelled() && !failure() && inputs.release_syft_permissions == true diff --git a/.github/workflows/cd-syft-restrict.yml b/.github/workflows/cd-syft-restrict.yml new file mode 100644 index 00000000000..2078f0ce6ff --- /dev/null +++ b/.github/workflows/cd-syft-restrict.yml @@ -0,0 +1,73 @@ +name: CD - Syft Restrict + +on: + workflow_dispatch: + inputs: + bump_type: + description: Version bump type + type: choice + default: patch + options: + - patch + - minor + - major + workflow_call: + inputs: + bump_type: + type: string + required: true + +concurrency: + group: 'CD - Syft Restrict' + cancel-in-progress: false + +jobs: + deploy-syft-restrict: + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - uses: actions/checkout@v6 + + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: '3.12' + + - name: Install uv + uses: astral-sh/setup-uv@v7 + + - name: Configure git user + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + + - name: Bump version + run: | + git pull + pip install packaging + OUTPUT=$(python scripts/bump_version.py syft-restrict ${{ inputs.bump_type }}) + VERSION=$(echo "$OUTPUT" | sed -n '1p') + MODIFIED=$(echo "$OUTPUT" | sed -n '2p') + echo "VERSION=$VERSION" >> $GITHUB_ENV + echo "MODIFIED=$MODIFIED" >> $GITHUB_ENV + echo "Bumped syft-restrict to $VERSION (modified: $MODIFIED)" + + - name: Build package + working-directory: packages/syft-restrict + run: uv build --out-dir dist + + - name: Publish to PyPI + working-directory: packages/syft-restrict + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_PASS_SYFT_RESTRICT }} + run: uvx twine upload --verbose dist/* + + - name: Commit and tag + run: | + git add ${{ env.MODIFIED }} + git commit -m "Release syft-restrict v${{ env.VERSION }}" + git tag "syft-restrict/v${{ env.VERSION }}" + git push origin --follow-tags diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 2f0a61d816a..65c596f52eb 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -179,3 +179,26 @@ jobs: - name: Run migration tests run: just test-unit-migration + + restrict-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v5 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Install the project + run: uv sync --all-extras + + - name: Install just + run: | + curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /usr/local/bin + + - name: Run restrict tests + run: just test-unit-restrict diff --git a/Justfile b/Justfile index 132ada82358..6ba3cc92c3b 100644 --- a/Justfile +++ b/Justfile @@ -34,6 +34,10 @@ test-unit-migration: #!/bin/bash uv run pytest -n auto ./packages/syft-migration/tests +test-unit-restrict: + #!/bin/bash + uv run pytest -n auto ./packages/syft-restrict/tests + test-unit-enclave: #!/bin/bash